Skip to content

Commit

Permalink
add more explicit approval test to cpp catch2 version
Browse files Browse the repository at this point in the history
  • Loading branch information
emilybache committed Apr 2, 2024
1 parent f422473 commit 661b131
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cpp-catch2/README.md
Original file line number Diff line number Diff line change
@@ -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
-----
Expand Down
11 changes: 11 additions & 0 deletions cpp-catch2/test/gildedrose_catch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item> items;
Expand All @@ -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<Item> items;
items.push_back(Item("foo", 0, 0));
GildedRose app(items);
app.updateQuality();
auto item = app.items[0];
ApprovalTests::Approvals::verify(item);
}

0 comments on commit 661b131

Please sign in to comment.