diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-01-12 14:49:36 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-01-12 14:50:02 +0300 |
commit | fb6bd8864411ee27db05ceadcb80f690f44e48dd (patch) | |
tree | 7f5354d1272612a32c28bfda4c03259970c402b7 /source/blender/blenlib/tests | |
parent | 46e049d0ce2bce2f53ddc41a0dbbea2969d00a5d (diff) |
Revert "BLI: Refactor vector types & functions to use templates"
Includes unwanted changes
This reverts commit 46e049d0ce2bce2f53ddc41a0dbbea2969d00a5d.
Diffstat (limited to 'source/blender/blenlib/tests')
5 files changed, 5 insertions, 153 deletions
diff --git a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc index eac3faa6d15..70e3a99e57a 100644 --- a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc +++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc @@ -21,9 +21,10 @@ extern "C" { #define DO_RANDOM_TESTS 0 #include "BLI_array.hh" +#include "BLI_double2.hh" #include "BLI_math_boolean.hh" #include "BLI_math_mpq.hh" -#include "BLI_math_vec_mpq_types.hh" +#include "BLI_mpq2.hh" #include "BLI_vector.hh" #include "BLI_delaunay_2d.h" diff --git a/source/blender/blenlib/tests/BLI_math_vec_types_test.cc b/source/blender/blenlib/tests/BLI_math_vec_types_test.cc deleted file mode 100644 index 8aa1f90fde2..00000000000 --- a/source/blender/blenlib/tests/BLI_math_vec_types_test.cc +++ /dev/null @@ -1,149 +0,0 @@ -/* Apache License, Version 2.0 */ - -#include "testing/testing.h" - -#include "BLI_math_vec_types.hh" - -namespace blender::tests { - -using namespace blender::math; - -TEST(math_vec_types, ScalarConstructorUnsigned) -{ - float2 u(5u); - EXPECT_EQ(u[0], 5.0f); - EXPECT_EQ(u[1], 5.0f); -} - -TEST(math_vec_types, ScalarConstructorInt) -{ - float2 i(-5); - EXPECT_EQ(i[0], -5.0f); - EXPECT_EQ(i[1], -5.0f); -} - -TEST(math_vec_types, ScalarConstructorFloat) -{ - float2 f(5.2f); - EXPECT_FLOAT_EQ(f[0], 5.2f); - EXPECT_FLOAT_EQ(f[1], 5.2f); -} - -TEST(math_vec_types, ScalarConstructorDouble) -{ - float2 d(5.2); - EXPECT_FLOAT_EQ(d[0], 5.2f); - EXPECT_FLOAT_EQ(d[1], 5.2f); -} - -TEST(math_vec_types, MultiScalarConstructorVec2) -{ - int2 i(5.5f, -1.8); - EXPECT_EQ(i[0], 5); - EXPECT_EQ(i[1], -1); -} - -TEST(math_vec_types, MultiScalarConstructorVec3) -{ - int3 i(5.5f, -1.8, 6u); - EXPECT_EQ(i[0], 5); - EXPECT_EQ(i[1], -1); - EXPECT_EQ(i[2], 6); -} - -TEST(math_vec_types, MultiScalarConstructorVec4) -{ - int4 i(5.5f, -1.8, 6u, 0.888f); - EXPECT_EQ(i[0], 5); - EXPECT_EQ(i[1], -1); - EXPECT_EQ(i[2], 6); - EXPECT_EQ(i[3], 0); -} - -TEST(math_vec_types, MixedScalarVectorConstructorVec3) -{ - float3 fl_v2(float2(5.5f), 1.8f); - EXPECT_FLOAT_EQ(fl_v2[0], 5.5f); - EXPECT_FLOAT_EQ(fl_v2[1], 5.5f); - EXPECT_FLOAT_EQ(fl_v2[2], 1.8f); - - float3 v2_fl(1.8f, float2(5.5f)); - EXPECT_FLOAT_EQ(v2_fl[0], 1.8f); - EXPECT_FLOAT_EQ(v2_fl[1], 5.5f); - EXPECT_FLOAT_EQ(v2_fl[2], 5.5f); -} - -TEST(math_vec_types, MixedScalarVectorConstructorVec4) -{ - int4 v2_fl_fl(float2(1), 2, 3); - EXPECT_EQ(v2_fl_fl[0], 1); - EXPECT_EQ(v2_fl_fl[1], 1); - EXPECT_EQ(v2_fl_fl[2], 2); - EXPECT_EQ(v2_fl_fl[3], 3); - - float4 fl_v2_fl(1, int2(2), 3); - EXPECT_EQ(fl_v2_fl[0], 1); - EXPECT_EQ(fl_v2_fl[1], 2); - EXPECT_EQ(fl_v2_fl[2], 2); - EXPECT_EQ(fl_v2_fl[3], 3); - - double4 fl_fl_v2(1, 2, double2(3)); - EXPECT_EQ(fl_fl_v2[0], 1); - EXPECT_EQ(fl_fl_v2[1], 2); - EXPECT_EQ(fl_fl_v2[2], 3); - EXPECT_EQ(fl_fl_v2[3], 3); - - int4 v2_v2(float2(1), uint2(2)); - EXPECT_EQ(v2_v2[0], 1); - EXPECT_EQ(v2_v2[1], 1); - EXPECT_EQ(v2_v2[2], 2); - EXPECT_EQ(v2_v2[3], 2); - - float4 v3_fl(uint3(1), 2); - EXPECT_EQ(v3_fl[0], 1); - EXPECT_EQ(v3_fl[1], 1); - EXPECT_EQ(v3_fl[2], 1); - EXPECT_EQ(v3_fl[3], 2); - - uint4 fl_v3(1, float3(2)); - EXPECT_EQ(fl_v3[0], 1); - EXPECT_EQ(fl_v3[1], 2); - EXPECT_EQ(fl_v3[2], 2); - EXPECT_EQ(fl_v3[3], 2); -} - -TEST(math_vec_types, ComponentMasking) -{ - int4 i(0, 1, 2, 3); - float2 f2 = float2(i); - EXPECT_EQ(f2[0], 0.0f); - EXPECT_EQ(f2[1], 1.0f); -} - -TEST(math_vec_types, PointerConversion) -{ - float array[3] = {1.0f, 2.0f, 3.0f}; - float3 farray(array); - EXPECT_EQ(farray[0], 1.0f); - EXPECT_EQ(farray[1], 2.0f); - EXPECT_EQ(farray[2], 3.0f); -} - -TEST(math_vec_types, PointerArrayConversion) -{ - float array[1][3] = {{1.0f, 2.0f, 3.0f}}; - float(*ptr)[3] = array; - float3 fptr(ptr); - EXPECT_EQ(fptr[0], 1.0f); - EXPECT_EQ(fptr[1], 2.0f); - EXPECT_EQ(fptr[2], 3.0f); -} - -TEST(math_vec_types, VectorTypeConversion) -{ - double2 d(int2(float2(5.75f, -1.57f))); - EXPECT_EQ(d[0], 5.0); - EXPECT_EQ(d[1], -1.0); -} - -} // namespace blender::tests diff --git a/source/blender/blenlib/tests/BLI_memory_utils_test.cc b/source/blender/blenlib/tests/BLI_memory_utils_test.cc index 74e54151a06..207f310d902 100644 --- a/source/blender/blenlib/tests/BLI_memory_utils_test.cc +++ b/source/blender/blenlib/tests/BLI_memory_utils_test.cc @@ -1,6 +1,6 @@ /* Apache License, Version 2.0 */ -#include "BLI_math_vec_types.hh" +#include "BLI_float3.hh" #include "BLI_memory_utils.hh" #include "BLI_strict_flags.h" #include "testing/testing.h" diff --git a/source/blender/blenlib/tests/BLI_mesh_boolean_test.cc b/source/blender/blenlib/tests/BLI_mesh_boolean_test.cc index 2b8fb3dbea4..d759f0c3be4 100644 --- a/source/blender/blenlib/tests/BLI_mesh_boolean_test.cc +++ b/source/blender/blenlib/tests/BLI_mesh_boolean_test.cc @@ -11,8 +11,8 @@ #include "BLI_array.hh" #include "BLI_map.hh" #include "BLI_math_mpq.hh" -#include "BLI_math_vec_mpq_types.hh" #include "BLI_mesh_boolean.hh" +#include "BLI_mpq3.hh" #include "BLI_vector.hh" #ifdef WITH_GMP diff --git a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc index d2d76593129..68111fb8eb1 100644 --- a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc +++ b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc @@ -10,8 +10,8 @@ #include "BLI_array.hh" #include "BLI_math_mpq.hh" -#include "BLI_math_vec_mpq_types.hh" #include "BLI_mesh_intersect.hh" +#include "BLI_mpq3.hh" #include "BLI_task.h" #include "BLI_vector.hh" |