ConditionalFunctionExecutorTest.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-13
  6. * Changed: 2023-02-22
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std-core-test.hpp>
  11. #include <ls-std/ls-std-core.hpp>
  12. using namespace ls::std::core;
  13. using namespace test::core;
  14. using namespace ::std;
  15. using namespace ::testing;
  16. namespace
  17. {
  18. class ConditionalFunctionExecutorTest : public Test
  19. {
  20. protected:
  21. ConditionalFunctionExecutorTest() = default;
  22. ~ConditionalFunctionExecutorTest() override = default;
  23. void SetUp() override
  24. {}
  25. void TearDown() override
  26. {}
  27. };
  28. TEST_F(ConditionalFunctionExecutorTest, execute)
  29. {
  30. shared_ptr<MathOddValidator> validator = make_shared<MathOddValidator>();
  31. int inputNumber = 3;
  32. ConditionalFunctionExecutor{true}.execute([validator, inputNumber] { validator->validate(inputNumber); });
  33. ASSERT_TRUE(validator->isOdd());
  34. }
  35. TEST_F(ConditionalFunctionExecutorTest, execute_no_execution)
  36. {
  37. shared_ptr<MathOddValidator> validator = make_shared<MathOddValidator>();
  38. int inputNumber = 3;
  39. ConditionalFunctionExecutor{false}.execute([validator, inputNumber] { validator->validate(inputNumber); });
  40. ASSERT_FALSE(validator->isOdd());
  41. }
  42. }