diff options
Diffstat (limited to 'tests/test_vector.cpp')
| -rw-r--r-- | tests/test_vector.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_vector.cpp b/tests/test_vector.cpp index 1d7b91a..364ce31 100644 --- a/tests/test_vector.cpp +++ b/tests/test_vector.cpp @@ -1,6 +1,8 @@ #include "linalg_error.hpp" +#include "norms.hpp" #include "vector.hpp" +#include <catch2/catch_approx.hpp> #include <catch2/catch_test_macros.hpp> #include <type_traits> @@ -86,3 +88,11 @@ TEST_CASE("Vector arithmetic enforces shape compatibility", "[vector]") { CHECK_THROWS_AS(a + short_vec, DimensionMismatchError); CHECK_THROWS_AS(linalg::dot(a, short_vec), DimensionMismatchError); } + +TEST_CASE("Vector 2-norm matches manually computed values", "[vector][norms]") { + const Vector v{3.0, 4.0}; + CHECK(linalg::norm2(v) == Catch::Approx(5.0)); + + const Vector zero(5); + CHECK(linalg::norm2(zero) == Catch::Approx(0.0)); +} |