diff --git a/.gitignore b/.gitignore index 1ff57af1..95bd72b9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ obj *.sln.DotSettings.user .vs vendor +.idea +*.iml diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index 65020b89..bd89b333 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -2,3 +2,4 @@ add_subdirectory(cpp_catch2_approvaltest) add_subdirectory(cpp_catch2_unittest) add_subdirectory(cpp_googletest_approvaltest) add_subdirectory(cpp_googletest_unittest) +add_subdirectory(cpp_texttest) diff --git a/cpp/test/cpp_texttest/CMakeLists.txt b/cpp/test/cpp_texttest/CMakeLists.txt new file mode 100644 index 00000000..d9eb71ea --- /dev/null +++ b/cpp/test/cpp_texttest/CMakeLists.txt @@ -0,0 +1,15 @@ +set(TEST_NAME GildedRoseTextTests) +add_executable(${TEST_NAME} GildedRoseTextTests.cc) +target_sources(${TEST_NAME} PRIVATE GildedRoseTextTests.cc) +target_link_libraries(${TEST_NAME} lib src) +set_property(TARGET ${TEST_NAME} PROPERTY CXX_STANDARD 11) +add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) + +# Set compiler option /FC for Visual Studio to to make the __FILE__ macro expand to full path. +# The __FILE__ macro is used by Catch2 to get the path to current test file. +# Links: +# * https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019 +# * https://docs.microsoft.com/en-us/cpp/build/reference/fc-full-path-of-source-code-file-in-diagnostics?view=vs-2019 +if (MSVC) + target_compile_options(${TEST_NAME} PRIVATE "/FC") +endif() diff --git a/cpp/test/cpp_texttest/GildedRoseTextTests.cc b/cpp/test/cpp_texttest/GildedRoseTextTests.cc new file mode 100644 index 00000000..e47f1058 --- /dev/null +++ b/cpp/test/cpp_texttest/GildedRoseTextTests.cc @@ -0,0 +1,44 @@ +#include +#include "GildedRose.h" + +int +print_item(Item *item) +{ + return printf("%s, %d, %d\n", item->name.c_str(), item->sellIn, item->quality); +} + +int main() +{ + vector items; + + items.emplace_back("+5 Dexterity Vest", 10, 20); + items.emplace_back("Aged Brie", 2, 0); + items.emplace_back("Elixir of the Mongoose", 5, 7); + items.emplace_back("Sulfuras, Hand of Ragnaros", 0, 80); + items.emplace_back("Sulfuras, Hand of Ragnaros", -1, 80); + items.emplace_back("Backstage passes to a TAFKAL80ETC concert", 15, 20); + items.emplace_back("Backstage passes to a TAFKAL80ETC concert", 10, 49); + items.emplace_back("Backstage passes to a TAFKAL80ETC concert", 5, 49); + + // this Conjured item doesn't yet work properly + items.emplace_back("Conjured Mana Cake", 3, 6); + + puts("OMGHAI!"); + + GildedRose app(items); + + for (int day = 0; day <= 30; day++) + { + printf("-------- day %d --------\n", day); + printf("name, sellIn, quality\n"); + for (auto & item : items) + { + print_item(&item); + } + printf("\n"); + app.updateQuality(); + } + return 0; +} + +