diff options
| author | y-jan137 <yousefjan24000@gmail.com> | 2026-03-12 16:40:43 +0300 |
|---|---|---|
| committer | y-jan137 <yousefjan24000@gmail.com> | 2026-03-12 16:40:43 +0300 |
| commit | 38004f74df5b2dbcb07e6ad5ac2272f16882e018 (patch) | |
| tree | 119c13cab68e3f38c77a737a7f15a3dad74c1343 /tests/test_vector.cpp | |
| parent | 11568ad166dc9312593fa4caf05aaa4a11f21b17 (diff) | |
Add basic ops
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)); +} |