From e5335130703e649c6356e93881aa3114b165b9b3 Mon Sep 17 00:00:00 2001 From: Maksims Svecovs Date: Tue, 6 Feb 2024 17:32:26 +0000 Subject: [PATCH] [test] Add more transpose coverage Vertical and horizontal scalar loops have to be exercised separately Signed-off-by: Maksims Svecovs --- test/api/test_transpose.cpp | 57 ++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/test/api/test_transpose.cpp b/test/api/test_transpose.cpp index 94ec882ee..2e3868eb7 100644 --- a/test/api/test_transpose.cpp +++ b/test/api/test_transpose.cpp @@ -14,22 +14,21 @@ class TestTranspose final { explicit TestTranspose(size_t padding) : padding_(padding) {} void scalar_test() { - // Scalar path will be exercised only if width is smaller than number of - // lanes in a vector - size_t src_width = test::Options::vector_lanes() - 1; - // Set height to be different than width but still smaller than vector_lanes - size_t src_height = - inplace ? src_width : test::Options::vector_lanes() - 2; - test(src_width, src_height); + size_t first_dim = test::Options::vector_lanes() - 1; + size_t second_dim = + inplace ? first_dim : test::Options::vector_lanes() + 1; + // Exercise horizontal scalar path + test(first_dim, second_dim); + // Exercise vertical scalar path + test(second_dim, first_dim); } void vector_test() { - // Vector path will be exercised even for +1 because of - // try_avoid_tail_loop() - size_t src_width = test::Options::vector_lanes() + 1; + // Make at least two full vector passes + size_t src_width = 2 * test::Options::vector_lanes(); // Set height to be different from width but still bigger than vector_lanes size_t src_height = - inplace ? src_width : test::Options::vector_lanes() + 2; + inplace ? src_width : test::Options::vector_lanes() + 1; test(src_width, src_height); } @@ -77,6 +76,34 @@ class TestTranspose final { size_t padding_; }; +class TestNotImplemented { + public: + template + static void wrong_dimensions() { + const size_t width = 1; + const size_t height = 2; + size_t stride = width * sizeof(ElementType); + + ElementType source[width * height] = {0xFF}; + + ASSERT_EQ(INTRINSICCV_ERROR_NOT_IMPLEMENTED, + intrinsiccv_transpose(source, stride, source, stride, width, + height, sizeof(ElementType))); + } + + template + static void wrong_type() { + const size_t width = 1, height = 1; + size_t stride = width * sizeof(WrongType); + + WrongType source[width * height] = {0xFF}; + + ASSERT_EQ(INTRINSICCV_ERROR_NOT_IMPLEMENTED, + intrinsiccv_transpose(source, stride, source, stride, width, + height, sizeof(WrongType))); + } +}; + template class Transpose : public testing::Test {}; @@ -128,3 +155,11 @@ TYPED_TEST(Transpose, NullPointer) { test::test_null_args(intrinsiccv_transpose, src, sizeof(TypeParam), dst, sizeof(TypeParam), 1, 1, sizeof(TypeParam)); } + +TYPED_TEST(Transpose, NotImplementedDims) { + TestNotImplemented::wrong_dimensions(); +} + +TEST(Transpose, NotImplementedType) { + TestNotImplemented::wrong_type<__uint128_t>(); +} -- GitLab