|
| 1 | + |
| 2 | +#include <wsjcpp_core.h> |
| 3 | +#include <wsjcpp_unit_tests.h> |
| 4 | + |
| 5 | +// --------------------------------------------------------------------- |
| 6 | +// UnitTestExtractFilepath |
| 7 | + |
| 8 | +class UnitTestExtractFilepath : public WsjcppUnitTestBase { |
| 9 | + public: |
| 10 | + UnitTestExtractFilepath(); |
| 11 | + virtual bool doBeforeTest() override; |
| 12 | + virtual void executeTest() override; |
| 13 | + virtual bool doAfterTest() override; |
| 14 | +}; |
| 15 | + |
| 16 | +REGISTRY_WSJCPP_UNIT_TEST(UnitTestExtractFilepath) |
| 17 | + |
| 18 | +UnitTestExtractFilepath::UnitTestExtractFilepath() |
| 19 | + : WsjcppUnitTestBase("UnitTestExtractFilepath") { |
| 20 | +} |
| 21 | + |
| 22 | +// --------------------------------------------------------------------- |
| 23 | + |
| 24 | +bool UnitTestExtractFilepath::doBeforeTest() { |
| 25 | + // do something before test |
| 26 | + return true; |
| 27 | +} |
| 28 | + |
| 29 | +// --------------------------------------------------------------------- |
| 30 | + |
| 31 | +void UnitTestExtractFilepath::executeTest() { |
| 32 | + struct LTest { |
| 33 | + LTest( |
| 34 | + const std::string &sFullpath, |
| 35 | + const std::string &sFilename |
| 36 | + ) { |
| 37 | + this->sFullpath = sFullpath; |
| 38 | + this->sFilename = sFilename; |
| 39 | + }; |
| 40 | + std::string sFullpath; |
| 41 | + std::string sFilename; |
| 42 | + }; |
| 43 | + std::vector<LTest> tests; |
| 44 | + tests.push_back(LTest(".//../bin/some/../file.txt", "file.txt")); |
| 45 | + |
| 46 | + for (int i = 0; i < tests.size(); i++) { |
| 47 | + LTest t = tests[i]; |
| 48 | + std::string sTestId = "test" + std::to_string(i); |
| 49 | + |
| 50 | + compare(sTestId, WsjcppCore::extractFilename(t.sFullpath), t.sFilename); |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +// --------------------------------------------------------------------- |
| 55 | + |
| 56 | +bool UnitTestExtractFilepath::doAfterTest() { |
| 57 | + // do somethig after test |
| 58 | + return true; |
| 59 | +} |
| 60 | + |
| 61 | + |
0 commit comments