ConditionalFunctionExecutorTest.cpp 1.3 KB

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