ConditionalFunctionExecutorTest.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-13
  6. * Changed: 2023-05-17
  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. public:
  22. ConditionalFunctionExecutorTest() = default;
  23. ~ConditionalFunctionExecutorTest() override = default;
  24. };
  25. TEST_F(ConditionalFunctionExecutorTest, execute)
  26. {
  27. auto validator = make_shared<MathOddValidator>();
  28. int inputNumber = 3;
  29. ConditionalFunctionExecutor{true}.execute([validator, inputNumber] { validator->validate(inputNumber); });
  30. ASSERT_TRUE(validator->isOdd());
  31. }
  32. TEST_F(ConditionalFunctionExecutorTest, execute_no_execution)
  33. {
  34. auto validator = make_shared<MathOddValidator>();
  35. int inputNumber = 3;
  36. ConditionalFunctionExecutor{false}.execute([validator, inputNumber] { validator->validate(inputNumber); });
  37. ASSERT_FALSE(validator->isOdd());
  38. }
  39. }