|
| 1 | +#ifndef CUKEBINS_HPP_ |
| 2 | +#define CUKEBINS_HPP_ |
| 3 | + |
| 4 | +#include "internal/StepManager.hpp" |
| 5 | +#include "internal/ContextManager.hpp" |
| 6 | +#include "internal/CukeCommands.hpp" |
| 7 | + |
| 8 | +#define CUKE_STEP_CLASS_NAME_(feature_class, step_name) feature_class##_##step_name##_Step |
| 9 | + |
| 10 | +#ifdef GTEST_INCLUDE_GTEST_GTEST_H_ |
| 11 | +#include "internal/drivers/GTestDriver.hpp" |
| 12 | +#else // No test framework |
| 13 | +#include "internal/drivers/FakeDriver.hpp" |
| 14 | +#endif |
| 15 | + |
| 16 | +#define CUKE_TEST_REAL_NAME_(step_name) CUKE_TEST_NAME_PREFIX_ #step_name |
| 17 | + |
| 18 | +// TODO: parent_class and parent_id should not be needed |
| 19 | +#define CUKE_STEP_(feature_class, step_name, step_matcher, parent_class, parent_id) \ |
| 20 | + class CUKE_STEP_CLASS_NAME_(feature_class, step_name) CUKE_STEPCLASS_INHERITANCE_(parent_class) { \ |
| 21 | + public: \ |
| 22 | + CUKE_STEP_CLASS_NAME_(feature_class, step_name)() CUKE_INHERITED_CONSTRUCTOR_(parent_class) {} \ |
| 23 | + private: \ |
| 24 | + virtual void CUKE_STEPCLASS_TESTBODY_NAME_ (); \ |
| 25 | + static const int cukeRegId; \ |
| 26 | + CUKE_STEPCLASS_OTHER_DECLARATIONS_(feature_class, step_name) \ |
| 27 | + }; \ |
| 28 | + const int CUKE_STEP_CLASS_NAME_(feature_class, step_name)::cukeRegId = \ |
| 29 | + ::cukebins::internal::registerStep(step_matcher, CUKE_TEST_FULLNAME_(feature_class, step_name)); \ |
| 30 | + CUKE_STEPCLASS_OTHER_DEFINITION_(feature_class, step_name, parent_class, parent_id) \ |
| 31 | + void CUKE_STEP_CLASS_NAME_(feature_class, step_name):: CUKE_STEPCLASS_TESTBODY_NAME_ () |
| 32 | + |
| 33 | +#define CUKE_STEP_F_(feature_class, step_name, step_matcher) \ |
| 34 | + CUKE_STEP_(feature_class, step_name, step_matcher, \ |
| 35 | + feature_class, ::testing::internal::GetTypeId<feature_class>()) |
| 36 | +#define CUKE_STEP_C_(context, step_name, step_matcher) CUKE_STEP_F_(context##_DefaultFixture, step_name, step_matcher) |
| 37 | + |
| 38 | +#define GIVEN_F(fixture, step_name, step_matcher) CUKE_STEP_F_(fixture, step_name, step_matcher) |
| 39 | +#define WHEN_F(fixture, step_name, step_matcher) CUKE_STEP_F_(fixture, step_name, step_matcher) |
| 40 | +#define THEN_F(fixture, step_name, step_matcher) CUKE_STEP_F_(fixture, step_name, step_matcher) |
| 41 | + |
| 42 | +#define GIVEN_C(context, step_name, step_matcher) CUKE_STEP_C_(context, step_name, step_matcher) |
| 43 | +#define WHEN_C(context, step_name, step_matcher) CUKE_STEP_C_(context, step_name, step_matcher) |
| 44 | +#define THEN_C(context, step_name, step_matcher) CUKE_STEP_C_(context, step_name, step_matcher) |
| 45 | + |
| 46 | +#define GIVEN(context, step_name, step_matcher) GIVEN_C(context, step_name, step_matcher) |
| 47 | +#define WHEN(context, step_name, step_matcher) WHEN_C(context, step_name, step_matcher) |
| 48 | +#define THEN(context, step_name, step_matcher) THEN_C(context, step_name, step_matcher) |
| 49 | + |
| 50 | +#define CUKE_FIXTURE(FixtureName, ...) \ |
| 51 | + class FixtureName : public ::cukebins::internal::CukeFixture<__VA_ARGS__> |
| 52 | + |
| 53 | +#define CUKE_CONTEXT(ContextName) \ |
| 54 | + struct ContextName; \ |
| 55 | + CUKE_FIXTURE(ContextName##_DefaultFixture, ContextName) {}; \ |
| 56 | + struct ContextName |
| 57 | + |
| 58 | +#endif /* CUKEBINS_HPP_ */ |
0 commit comments