From 661b131832520518f55b2e3ecfd2bfedae611ede Mon Sep 17 00:00:00 2001 From: emily Date: Tue, 2 Apr 2024 16:54:07 +0200 Subject: [PATCH] add more explicit approval test to cpp catch2 version --- cpp-catch2/README.md | 3 ++- cpp-catch2/test/gildedrose_catch.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cpp-catch2/README.md b/cpp-catch2/README.md index 66b941cb..ce8bfb01 100644 --- a/cpp-catch2/README.md +++ b/cpp-catch2/README.md @@ -1,10 +1,11 @@ C++ version of Gilded Rose with Catch 2 and Approvals ====================================================== -This is a C++ start of the ApprovalTest version of the Gilded Rose Refactoring Kata. See +This is a C++ start of the Gilded Rose Refactoring Kata. See the [top level readme](https://github.com/emilybache/GildedRose-Refactoring-Kata) for a general description of the exercise. +There are two (failing) unit tests included here. One uses only the catch2 framework, the other additionally uses [ApprovalTests](https://github.com/approvals/approvaltests.cpp). You should choose one of these tests to work with and delete the other. CMake ----- diff --git a/cpp-catch2/test/gildedrose_catch.cpp b/cpp-catch2/test/gildedrose_catch.cpp index 753b153b..af562b40 100644 --- a/cpp-catch2/test/gildedrose_catch.cpp +++ b/cpp-catch2/test/gildedrose_catch.cpp @@ -11,6 +11,7 @@ std::ostream& operator<<(std::ostream& os, const Item& obj) << ", quality: " << obj.quality; } +// This is a normal unit test using Catch2 TEST_CASE("UpdateQuality") { vector items; @@ -19,3 +20,13 @@ TEST_CASE("UpdateQuality") { app.updateQuality(); REQUIRE("fixme" == app.items[0].name); } + +// This is an Approval test using https://github.com/approvals/approvaltests.cpp +TEST_CASE("UpdateQualityApprovalTest") { + vector items; + items.push_back(Item("foo", 0, 0)); + GildedRose app(items); + app.updateQuality(); + auto item = app.items[0]; + ApprovalTests::Approvals::verify(item); +}