test_is_any_of.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #include "test_precomp.hpp"
  5. #include "../src/util/util.hpp"
  6. namespace opencv_test { namespace {
  7. /**
  8. * Tests whether the `cvv::util::isAnyOf()` function (from /src/util/util.hpp) correctly recognises
  9. * the first parameter as element or not element of the data structure in the second parameter
  10. * for the following structures:
  11. * - Initializer lists with `int int`
  12. * - Initializer lists with `long int`
  13. * - Vectors of `int int`
  14. * - Vectors of `long int`
  15. */
  16. using cvv::util::isAnyOf;
  17. TEST(IsAnyOfTest, InitializerListIntInt)
  18. {
  19. EXPECT_EQ(isAnyOf(3, { 1, 2, 3, 4 }), true);
  20. EXPECT_EQ(isAnyOf(3, { 1, 2, 4 }), false);
  21. }
  22. TEST(IsAnyOfTest, InitializerListLongInt)
  23. {
  24. EXPECT_EQ(isAnyOf(3, { 1L, 2L, 3L, 4L }), true);
  25. EXPECT_EQ(isAnyOf(3, { 1L, 2L, 4L }), false);
  26. }
  27. TEST(IsAnyOfTest, VectorIntInt)
  28. {
  29. EXPECT_EQ(isAnyOf(3, std::vector<int>{ 1, 2, 3, 4 }), true);
  30. EXPECT_EQ(isAnyOf(3, std::vector<int>{ 1, 2, 4 }), false);
  31. }
  32. TEST(IsAnyOfTest, VectorLongInt)
  33. {
  34. EXPECT_EQ(isAnyOf(3, std::vector<long>{ 1, 2, 3, 4 }), true);
  35. EXPECT_EQ(isAnyOf(3, std::vector<long>{ 1, 2, 4 }), false);
  36. }
  37. }} // namespace