Created
May 23, 2024 16:42
-
-
Save emilybache/f821973c2321a37caa161457de8d2d09 to your computer and use it in GitHub Desktop.
If you just want to do the Gilded Rose refactoring in C++ and would like a Combination Approvals test to lean on. Use this with the 'cpp_catch2' version.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <catch2/catch.hpp> | |
#include "ApprovalTests.hpp" | |
#include "GildedRose.h" | |
std::ostream &operator<<(std::ostream &os, const Item &obj) { | |
return os | |
<< "name: " << obj.name | |
<< ", sellIn: " << obj.sellIn | |
<< ", quality: " << obj.quality; | |
} | |
static Item updateItem(string name, int sellIn, int quality); | |
TEST_CASE("UpdateQuality") | |
{ | |
vector<string> names = {"foo", "Aged Brie", "Backstage passes to a TAFKAL80ETC concert", "Sulfuras, Hand of Ragnaros"}; | |
vector<int> sellIns = {-1, 0, 5, 6, 10, 11}; | |
vector<int> qualitys = {0, 1, 2, 49, 50}; | |
ApprovalTests::CombinationApprovals::verifyAllCombinations( | |
updateItem, | |
names, | |
sellIns, | |
qualitys | |
); | |
} | |
static Item updateItem(string name, int sellIn, int quality) { | |
vector<Item> items; | |
items.push_back(Item(name, sellIn, quality)); | |
GildedRose app(items); | |
app.updateQuality(); | |
auto item = app.items[0]; | |
return item; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment