ConditionalFunctionExecutorTest.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 ls::std::core::ConditionalFunctionExecutor;
  13. using std::make_shared;
  14. using std::shared_ptr;
  15. using test::core::MathOddValidator;
  16. using testing::Test;
  17. namespace
  18. {
  19. class ConditionalFunctionExecutorTest : public Test
  20. {
  21. protected:
  22. ConditionalFunctionExecutorTest() = default;
  23. ~ConditionalFunctionExecutorTest() override = default;
  24. void SetUp() override
  25. {}
  26. void TearDown() override
  27. {}
  28. };
  29. TEST_F(ConditionalFunctionExecutorTest, execute)
  30. {
  31. shared_ptr<MathOddValidator> validator = make_shared<MathOddValidator>();
  32. int inputNumber = 3;
  33. ConditionalFunctionExecutor{true}.execute([validator, inputNumber] { validator->validate(inputNumber); });
  34. ASSERT_TRUE(validator->isOdd());
  35. }
  36. TEST_F(ConditionalFunctionExecutorTest, execute_no_execution)
  37. {
  38. shared_ptr<MathOddValidator> validator = make_shared<MathOddValidator>();
  39. int inputNumber = 3;
  40. ConditionalFunctionExecutor{false}.execute([validator, inputNumber] { validator->validate(inputNumber); });
  41. ASSERT_FALSE(validator->isOdd());
  42. }
  43. }