aboutsummaryrefslogtreecommitdiff
path: root/tests/test_vector.cpp
diff options
context:
space:
mode:
authory-jan137 <yousefjan24000@gmail.com>2026-03-12 16:40:43 +0300
committery-jan137 <yousefjan24000@gmail.com>2026-03-12 16:40:43 +0300
commit38004f74df5b2dbcb07e6ad5ac2272f16882e018 (patch)
tree119c13cab68e3f38c77a737a7f15a3dad74c1343 /tests/test_vector.cpp
parent11568ad166dc9312593fa4caf05aaa4a11f21b17 (diff)
Add basic ops
Diffstat (limited to 'tests/test_vector.cpp')
-rw-r--r--tests/test_vector.cpp10
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));
+}