STLUtilsTest.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-17
  6. * Changed: 2020-08-17
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include "../../../source/utils/STLUtils.hpp"
  11. #include <vector>
  12. #include <list>
  13. #include <string>
  14. namespace {
  15. class STLUtilsTest : public ::testing::Test {
  16. protected:
  17. STLUtilsTest() = default;
  18. ~STLUtilsTest() override = default;
  19. void SetUp() override {}
  20. void TearDown() override {}
  21. };
  22. TEST_F(STLUtilsTest, contains)
  23. {
  24. std::vector<int> values {1, 13, 7, 8};
  25. std::list<std::string> names {"Tim", "Alex", "Nadine"};
  26. ASSERT_TRUE((ls_std::STLUtils<std::vector<int>, int>::contains(values, 1)));
  27. ASSERT_TRUE((ls_std::STLUtils<std::vector<int>, int>::contains(values, 13)));
  28. ASSERT_TRUE((ls_std::STLUtils<std::vector<int>, int>::contains(values, 7)));
  29. ASSERT_TRUE((ls_std::STLUtils<std::vector<int>, int>::contains(values, 8)));
  30. ASSERT_TRUE((ls_std::STLUtils<std::list<std::string>, std::string>::contains(names, "Tim")));
  31. ASSERT_TRUE((ls_std::STLUtils<std::list<std::string>, std::string>::contains(names, "Alex")));
  32. ASSERT_TRUE((ls_std::STLUtils<std::list<std::string>, std::string>::contains(names, "Nadine")));
  33. }
  34. TEST_F(STLUtilsTest, containsNegative)
  35. {
  36. std::vector<int> values{1, 13, 7, 8};
  37. std::list<std::string> names{"Tim", "Alex", "Nadine"};
  38. ASSERT_FALSE((ls_std::STLUtils<std::vector<int>, int>::contains(values, 55)));
  39. ASSERT_FALSE((ls_std::STLUtils<std::vector<int>, int>::contains(values, 9)));
  40. ASSERT_FALSE((ls_std::STLUtils<std::list<std::string>, std::string>::contains(names, "Lena")));
  41. ASSERT_FALSE((ls_std::STLUtils<std::list<std::string>, std::string>::contains(names, "Mirco")));
  42. }
  43. }