From 10ba6b2bd64be8c9e74ee8b2c704cbf7ef99c81b Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Mon, 20 Jun 2022 18:42:31 -0700 Subject: [PATCH] Remove utest --- .gitignore | 1 + .gitmodules | 3 --- CMakeLists.txt | 2 +- external/utest | 1 - quicktex/Matrix.h | 8 +++----- tests/ctest/TestMatrix.cpp | 7 ++++--- 6 files changed, 9 insertions(+), 13 deletions(-) delete mode 160000 external/utest diff --git a/.gitignore b/.gitignore index cf82aae..9886e1b 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ compile_commands.json CTestTestfile.cmake _deps cmake-build-* +*.a diff --git a/.gitmodules b/.gitmodules index 007937d..49f1431 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "external/xsimd"] path = external/xsimd url = https://github.com/xtensor-stack/xsimd.git -[submodule "external/utest"] - path = external/utest - url = https://github.com/sheredom/utest.h.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 1874ed8..a4d691a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,4 +11,4 @@ add_subdirectory(quicktex) add_subdirectory(tests) enable_testing () -add_test (NAME MyTest COMMAND Test) \ No newline at end of file +add_test (NAME QuicktexTest COMMAND Test) \ No newline at end of file diff --git a/external/utest b/external/utest deleted file mode 160000 index 06abbd1..0000000 --- a/external/utest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 06abbd1978f7e9c5f61642d80b9d300e3a8c4ccf diff --git a/quicktex/Matrix.h b/quicktex/Matrix.h index a297e47..dd7daa8 100644 --- a/quicktex/Matrix.h +++ b/quicktex/Matrix.h @@ -35,9 +35,7 @@ template using Vec = Matrix; // region helper concepts template -concept operable = requires(L &l, R &r, Op &op) { - { op(l, r) } -> std::same_as; - }; +concept operable = requires(L &l, R &r, Op &op) { op(l, r); }; template concept is_matrix = requires(V &v) { @@ -121,7 +119,7 @@ class Matrix : public VecBase>, M> { * Create a vector from a scalar value * @param scalar value to populate with */ - Matrix(const T &scalar) { std::fill(this->all_begin(), this->all_end(), scalar); } + Matrix(const T &scalar) { std::fill(this->begin(), this->end(), scalar); } /** * Create a vector from an iterator @@ -431,7 +429,7 @@ class Matrix : public VecBase>, M> { linear_iterator(V *matrix = nullptr, size_t index = 0) : base(index), _matrix(matrix){}; auto operator*() const { return _matrix->element(this->_index); } - auto *operator->() const { &(_matrix->element(this->_index)); } + auto *operator->() const { return &(_matrix->element(this->_index)); } friend bool operator==(const linear_iterator &lhs, const linear_iterator &rhs) { return (lhs._matrix == rhs._matrix) && (lhs._index == rhs._index); diff --git a/tests/ctest/TestMatrix.cpp b/tests/ctest/TestMatrix.cpp index 826bf95..3ee866e 100644 --- a/tests/ctest/TestMatrix.cpp +++ b/tests/ctest/TestMatrix.cpp @@ -54,6 +54,7 @@ TEST(Vec_float, mul) { auto b = Vec{3.0f, 1.5f, 0.0f}; expect_matrix_eq(a * b, {3.0f, 2.25f, 0.0f}); + expect_matrix_eq(a * 2, {2.0f, 3.00f, 4.0f}); } TEST(Vec_float, div) { @@ -61,6 +62,7 @@ TEST(Vec_float, div) { auto b = Vec{2.0f, 1.5f, 1.0f}; expect_matrix_eq(a / b, {0.5f, 1.0f, 2.0f}); + expect_matrix_eq(a / 2, {0.5f, 0.75f, 1.0f}); } TEST(Vec_float, vsum) { @@ -79,9 +81,8 @@ TEST(Vec_float, dot) { TEST(Vec_float, abs) { auto a = Vec{1.0f, -5.0f, -1.0f}; - auto expected = Vec{1.0f, 5.0f, 1.0f}; - expect_matrix_eq(a.abs(), expected); + expect_matrix_eq(a.abs(), {1.0f, 5.0f, 1.0f}); } TEST(Vec_float, clamp) { @@ -132,7 +133,7 @@ TEST(Vec_int, getters) { EXPECT_EQ(a.element(i), a[i]); } - EXPECT_EQ(a.get_column(0), a); // the 0th column of a column-vector is itself + expect_matrix_eq(a.get_column(0), a); // the 0th column of a column-vector is itself } TEST(Vec_int, copy) {