From e3c693c6148eeee3c3b1adf7e3b2b6412152e818 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Mon, 4 Jun 2018 12:59:08 +0200 Subject: [PATCH] Complete TinyVector unit tests --- tests/test_TinyVector.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/test_TinyVector.cpp b/tests/test_TinyVector.cpp index 5e29a8e5d..feb4fe26c 100644 --- a/tests/test_TinyVector.cpp +++ b/tests/test_TinyVector.cpp @@ -5,4 +5,42 @@ TEST_CASE("TinyVector", "[algebra]") { TinyVector<3,int> v(1,2,3); REQUIRE(((v[0] == 1) and (v[1] == 2) and (v[2] == 3))); + REQUIRE(v.dimension() == 3); + + const TinyVector<3,int> z = zero; + REQUIRE(((z[0] == 0) and (z[1] == 0) and (z[2] == 0))); + + v = TinyVector<3,int>(3,2,4); + TinyVector<3,int> w(1,2,6); + REQUIRE((v,w)==31); + + w = 2*v; + REQUIRE(((w[0] == 2*v[0]) and (w[1]==2*v[1]) and (w[2]==2*v[2]))); + + TinyVector<3,int> x = v; + REQUIRE(x==v); + + x = TinyVector<3,int> (6,4,8); + REQUIRE(x==w); + REQUIRE(x!=v); + + x=v; + REQUIRE(x==v); + + x+=w; + REQUIRE(x==3*v); + + x=v+w; + REQUIRE(x==3*v); + + x-=w; + REQUIRE(x==v); + + x=w-v; + REQUIRE(x==v); + + TinyVector<3,int> z1; z1 = zero; + REQUIRE(((z1[0] == 0) and (z1[1] == 0) and (z1[2] == 0))); + + REQUIRE( Catch::Detail::stringify(x) == "(3,2,4)"); } -- GitLab