diff --git a/Ada/.gitignore b/Ada/.gitignore deleted file mode 100644 index c1446c8c..00000000 --- a/Ada/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -*.o -*.ali -b~*.ads -b~*.adb -program -gilded_rose_tester diff --git a/Ada/Makefile b/Ada/Makefile deleted file mode 100644 index e2fef701..00000000 --- a/Ada/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -AHVEN_INCLUDE:=-aI/usr/share/ada/adainclude/ahven -aI/usr/include/ahven -AHVEN_LIBS:=-aO/usr/lib/x86_64-linux-gnu/ada/adalib/ahven -aO/usr/lib/ahven -aO/usr/lib -shared -ADAFLAGS:=-gnat2012 $(AHVEN_INCLUDE) $(AHVEN_LIBS) -LIBS:=-largs -lahven - -.PHONY: all -all: gilded_rose_tester program - -.PHONY: gilded_rose_tester -gilded_rose_tester: - @gnatmake -q $(ADAFLAGS) gilded_rose_tester $(LIBS) - -.PHONY: test -test: gilded_rose_tester - @./gilded_rose_tester - -.PHONY: program -program: - @gnatmake -q $(ADAFLAGS) program $(LIBS) - -.PHONY: clean -clean: - @gnatclean -q gilded_rose_tester program diff --git a/Ada/README.txt b/Ada/README.txt deleted file mode 100644 index f0865543..00000000 --- a/Ada/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -You will need the following programs: - - - GNU make (on Debian-like systems do 'apt-get install make') - - gcc with Ada enabled ('apt-get install gnat') - - the ahven unit-test framework ('apt-get install libahven5-dev') - -'make test' runs your tests once. - diff --git a/Ada/ThirtyDays.txt b/Ada/ThirtyDays.txt deleted file mode 100644 index a04e48ac..00000000 --- a/Ada/ThirtyDays.txt +++ /dev/null @@ -1,373 +0,0 @@ -OMGHAI! --------- day 0 -------- -name, sellIn, quality -+5 Dexterity Vest, 10, 20 -Aged Brie, 2, 0 -Elixir of the Mongoose, 5, 7 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 15, 20 -Backstage passes to a TAFKAL80ETC concert, 10, 49 -Backstage passes to a TAFKAL80ETC concert, 5, 49 -Conjured Mana Cake, 3, 6 - --------- day 1 -------- -name, sellIn, quality -+5 Dexterity Vest, 9, 19 -Aged Brie, 1, 1 -Elixir of the Mongoose, 4, 6 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 14, 21 -Backstage passes to a TAFKAL80ETC concert, 9, 50 -Backstage passes to a TAFKAL80ETC concert, 4, 50 -Conjured Mana Cake, 2, 5 - --------- day 2 -------- -name, sellIn, quality -+5 Dexterity Vest, 8, 18 -Aged Brie, 0, 2 -Elixir of the Mongoose, 3, 5 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 13, 22 -Backstage passes to a TAFKAL80ETC concert, 8, 50 -Backstage passes to a TAFKAL80ETC concert, 3, 50 -Conjured Mana Cake, 1, 4 - --------- day 3 -------- -name, sellIn, quality -+5 Dexterity Vest, 7, 17 -Aged Brie, -1, 4 -Elixir of the Mongoose, 2, 4 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 12, 23 -Backstage passes to a TAFKAL80ETC concert, 7, 50 -Backstage passes to a TAFKAL80ETC concert, 2, 50 -Conjured Mana Cake, 0, 3 - --------- day 4 -------- -name, sellIn, quality -+5 Dexterity Vest, 6, 16 -Aged Brie, -2, 6 -Elixir of the Mongoose, 1, 3 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 11, 24 -Backstage passes to a TAFKAL80ETC concert, 6, 50 -Backstage passes to a TAFKAL80ETC concert, 1, 50 -Conjured Mana Cake, -1, 1 - --------- day 5 -------- -name, sellIn, quality -+5 Dexterity Vest, 5, 15 -Aged Brie, -3, 8 -Elixir of the Mongoose, 0, 2 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 10, 25 -Backstage passes to a TAFKAL80ETC concert, 5, 50 -Backstage passes to a TAFKAL80ETC concert, 0, 50 -Conjured Mana Cake, -2, 0 - --------- day 6 -------- -name, sellIn, quality -+5 Dexterity Vest, 4, 14 -Aged Brie, -4, 10 -Elixir of the Mongoose, -1, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 9, 27 -Backstage passes to a TAFKAL80ETC concert, 4, 50 -Backstage passes to a TAFKAL80ETC concert, -1, 0 -Conjured Mana Cake, -3, 0 - --------- day 7 -------- -name, sellIn, quality -+5 Dexterity Vest, 3, 13 -Aged Brie, -5, 12 -Elixir of the Mongoose, -2, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 8, 29 -Backstage passes to a TAFKAL80ETC concert, 3, 50 -Backstage passes to a TAFKAL80ETC concert, -2, 0 -Conjured Mana Cake, -4, 0 - --------- day 8 -------- -name, sellIn, quality -+5 Dexterity Vest, 2, 12 -Aged Brie, -6, 14 -Elixir of the Mongoose, -3, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 7, 31 -Backstage passes to a TAFKAL80ETC concert, 2, 50 -Backstage passes to a TAFKAL80ETC concert, -3, 0 -Conjured Mana Cake, -5, 0 - --------- day 9 -------- -name, sellIn, quality -+5 Dexterity Vest, 1, 11 -Aged Brie, -7, 16 -Elixir of the Mongoose, -4, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 6, 33 -Backstage passes to a TAFKAL80ETC concert, 1, 50 -Backstage passes to a TAFKAL80ETC concert, -4, 0 -Conjured Mana Cake, -6, 0 - --------- day 10 -------- -name, sellIn, quality -+5 Dexterity Vest, 0, 10 -Aged Brie, -8, 18 -Elixir of the Mongoose, -5, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 5, 35 -Backstage passes to a TAFKAL80ETC concert, 0, 50 -Backstage passes to a TAFKAL80ETC concert, -5, 0 -Conjured Mana Cake, -7, 0 - --------- day 11 -------- -name, sellIn, quality -+5 Dexterity Vest, -1, 8 -Aged Brie, -9, 20 -Elixir of the Mongoose, -6, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 4, 38 -Backstage passes to a TAFKAL80ETC concert, -1, 0 -Backstage passes to a TAFKAL80ETC concert, -6, 0 -Conjured Mana Cake, -8, 0 - --------- day 12 -------- -name, sellIn, quality -+5 Dexterity Vest, -2, 6 -Aged Brie, -10, 22 -Elixir of the Mongoose, -7, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 3, 41 -Backstage passes to a TAFKAL80ETC concert, -2, 0 -Backstage passes to a TAFKAL80ETC concert, -7, 0 -Conjured Mana Cake, -9, 0 - --------- day 13 -------- -name, sellIn, quality -+5 Dexterity Vest, -3, 4 -Aged Brie, -11, 24 -Elixir of the Mongoose, -8, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 2, 44 -Backstage passes to a TAFKAL80ETC concert, -3, 0 -Backstage passes to a TAFKAL80ETC concert, -8, 0 -Conjured Mana Cake, -10, 0 - --------- day 14 -------- -name, sellIn, quality -+5 Dexterity Vest, -4, 2 -Aged Brie, -12, 26 -Elixir of the Mongoose, -9, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 1, 47 -Backstage passes to a TAFKAL80ETC concert, -4, 0 -Backstage passes to a TAFKAL80ETC concert, -9, 0 -Conjured Mana Cake, -11, 0 - --------- day 15 -------- -name, sellIn, quality -+5 Dexterity Vest, -5, 0 -Aged Brie, -13, 28 -Elixir of the Mongoose, -10, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 0, 50 -Backstage passes to a TAFKAL80ETC concert, -5, 0 -Backstage passes to a TAFKAL80ETC concert, -10, 0 -Conjured Mana Cake, -12, 0 - --------- day 16 -------- -name, sellIn, quality -+5 Dexterity Vest, -6, 0 -Aged Brie, -14, 30 -Elixir of the Mongoose, -11, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -1, 0 -Backstage passes to a TAFKAL80ETC concert, -6, 0 -Backstage passes to a TAFKAL80ETC concert, -11, 0 -Conjured Mana Cake, -13, 0 - --------- day 17 -------- -name, sellIn, quality -+5 Dexterity Vest, -7, 0 -Aged Brie, -15, 32 -Elixir of the Mongoose, -12, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -2, 0 -Backstage passes to a TAFKAL80ETC concert, -7, 0 -Backstage passes to a TAFKAL80ETC concert, -12, 0 -Conjured Mana Cake, -14, 0 - --------- day 18 -------- -name, sellIn, quality -+5 Dexterity Vest, -8, 0 -Aged Brie, -16, 34 -Elixir of the Mongoose, -13, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -3, 0 -Backstage passes to a TAFKAL80ETC concert, -8, 0 -Backstage passes to a TAFKAL80ETC concert, -13, 0 -Conjured Mana Cake, -15, 0 - --------- day 19 -------- -name, sellIn, quality -+5 Dexterity Vest, -9, 0 -Aged Brie, -17, 36 -Elixir of the Mongoose, -14, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -4, 0 -Backstage passes to a TAFKAL80ETC concert, -9, 0 -Backstage passes to a TAFKAL80ETC concert, -14, 0 -Conjured Mana Cake, -16, 0 - --------- day 20 -------- -name, sellIn, quality -+5 Dexterity Vest, -10, 0 -Aged Brie, -18, 38 -Elixir of the Mongoose, -15, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -5, 0 -Backstage passes to a TAFKAL80ETC concert, -10, 0 -Backstage passes to a TAFKAL80ETC concert, -15, 0 -Conjured Mana Cake, -17, 0 - --------- day 21 -------- -name, sellIn, quality -+5 Dexterity Vest, -11, 0 -Aged Brie, -19, 40 -Elixir of the Mongoose, -16, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -6, 0 -Backstage passes to a TAFKAL80ETC concert, -11, 0 -Backstage passes to a TAFKAL80ETC concert, -16, 0 -Conjured Mana Cake, -18, 0 - --------- day 22 -------- -name, sellIn, quality -+5 Dexterity Vest, -12, 0 -Aged Brie, -20, 42 -Elixir of the Mongoose, -17, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -7, 0 -Backstage passes to a TAFKAL80ETC concert, -12, 0 -Backstage passes to a TAFKAL80ETC concert, -17, 0 -Conjured Mana Cake, -19, 0 - --------- day 23 -------- -name, sellIn, quality -+5 Dexterity Vest, -13, 0 -Aged Brie, -21, 44 -Elixir of the Mongoose, -18, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -8, 0 -Backstage passes to a TAFKAL80ETC concert, -13, 0 -Backstage passes to a TAFKAL80ETC concert, -18, 0 -Conjured Mana Cake, -20, 0 - --------- day 24 -------- -name, sellIn, quality -+5 Dexterity Vest, -14, 0 -Aged Brie, -22, 46 -Elixir of the Mongoose, -19, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -9, 0 -Backstage passes to a TAFKAL80ETC concert, -14, 0 -Backstage passes to a TAFKAL80ETC concert, -19, 0 -Conjured Mana Cake, -21, 0 - --------- day 25 -------- -name, sellIn, quality -+5 Dexterity Vest, -15, 0 -Aged Brie, -23, 48 -Elixir of the Mongoose, -20, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -10, 0 -Backstage passes to a TAFKAL80ETC concert, -15, 0 -Backstage passes to a TAFKAL80ETC concert, -20, 0 -Conjured Mana Cake, -22, 0 - --------- day 26 -------- -name, sellIn, quality -+5 Dexterity Vest, -16, 0 -Aged Brie, -24, 50 -Elixir of the Mongoose, -21, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -11, 0 -Backstage passes to a TAFKAL80ETC concert, -16, 0 -Backstage passes to a TAFKAL80ETC concert, -21, 0 -Conjured Mana Cake, -23, 0 - --------- day 27 -------- -name, sellIn, quality -+5 Dexterity Vest, -17, 0 -Aged Brie, -25, 50 -Elixir of the Mongoose, -22, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -12, 0 -Backstage passes to a TAFKAL80ETC concert, -17, 0 -Backstage passes to a TAFKAL80ETC concert, -22, 0 -Conjured Mana Cake, -24, 0 - --------- day 28 -------- -name, sellIn, quality -+5 Dexterity Vest, -18, 0 -Aged Brie, -26, 50 -Elixir of the Mongoose, -23, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -13, 0 -Backstage passes to a TAFKAL80ETC concert, -18, 0 -Backstage passes to a TAFKAL80ETC concert, -23, 0 -Conjured Mana Cake, -25, 0 - --------- day 29 -------- -name, sellIn, quality -+5 Dexterity Vest, -19, 0 -Aged Brie, -27, 50 -Elixir of the Mongoose, -24, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -14, 0 -Backstage passes to a TAFKAL80ETC concert, -19, 0 -Backstage passes to a TAFKAL80ETC concert, -24, 0 -Conjured Mana Cake, -26, 0 - --------- day 30 -------- -name, sellIn, quality -+5 Dexterity Vest, -20, 0 -Aged Brie, -28, 50 -Elixir of the Mongoose, -25, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -15, 0 -Backstage passes to a TAFKAL80ETC concert, -20, 0 -Backstage passes to a TAFKAL80ETC concert, -25, 0 -Conjured Mana Cake, -27, 0 - diff --git a/Ada/gilded_rose.adb b/Ada/gilded_rose.adb deleted file mode 100644 index fdcc5aa3..00000000 --- a/Ada/gilded_rose.adb +++ /dev/null @@ -1,62 +0,0 @@ -with Ada.Strings.Unbounded; -use Ada.Strings.Unbounded; - -package body Gilded_Rose is - procedure Update_Quality(Self : in out Gilded_Rose) is - Cursor : Item_Vecs.Cursor := Item_Vecs.First(Self.Items); - begin - while Item_Vecs.Has_Element(Cursor) loop - if Self.Items(Cursor).Name /= To_Unbounded_String("Aged Brie") - and Self.Items(Cursor).Name /= To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert") then - if Self.Items(Cursor).Quality > 0 then - if Self.Items(Cursor).Name /= To_Unbounded_String("Sulfuras, Hand of Ragnaros") then - Self.Items(Cursor).Quality := Self.Items(Cursor).Quality - 1; - end if; - end if; - else - if Self.Items(Cursor).Quality < 50 then - Self.Items(Cursor).Quality := Self.Items(Cursor).Quality + 1; - - if Self.Items(Cursor).Name = To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert") then - if Self.Items(Cursor).Sell_In < 11 then - if Self.Items(Cursor).Quality < 50 then - Self.Items(Cursor).Quality := Self.Items(Cursor).Quality + 1; - end if; - end if; - - if Self.Items(Cursor).Sell_In < 6 then - if Self.Items(Cursor).Quality < 50 then - Self.Items(Cursor).Quality := Self.Items(Cursor).Quality + 1; - end if; - end if; - end if; - end if; - end if; - - if Self.Items(Cursor).Name /= To_Unbounded_String("Sulfuras, Hand of Ragnaros") then - Self.Items(Cursor).Sell_In := Self.Items(Cursor).Sell_In - 1; - end if; - - if Self.Items(Cursor).Sell_In < 0 then - if Self.Items(Cursor).Name /= To_Unbounded_String("Aged Brie") then - if Self.Items(Cursor).Name /= To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert") then - if Self.Items(Cursor).Quality > 0 then - if Self.Items(Cursor).Name /= To_Unbounded_String("Sulfuras, Hand of Ragnaros") then - Self.Items(Cursor).Quality := Self.Items(Cursor).Quality - 1; - end if; - end if; - else - Self.Items(Cursor).Quality := Self.Items(Cursor).Quality - Self.Items(Cursor).Quality; - end if; - else - if Self.Items(Cursor).Quality < 50 then - Self.Items(Cursor).Quality := Self.Items(Cursor).Quality + 1; - end if; - end if; - end if; - - Item_Vecs.Next(Cursor); - end loop; - end; - -end Gilded_Rose; diff --git a/Ada/gilded_rose.ads b/Ada/gilded_rose.ads deleted file mode 100644 index 64fc0ad6..00000000 --- a/Ada/gilded_rose.ads +++ /dev/null @@ -1,15 +0,0 @@ -with Ada.Containers.Vectors; -with Items; -use Items; - -package Gilded_Rose is - package Item_Vecs is new Ada.Containers.Vectors ( - Element_Type => Item, - Index_Type => Positive - ); - - type Gilded_Rose is record - Items : Item_Vecs.Vector; - end record; - procedure Update_Quality(Self : in out Gilded_Rose); -end Gilded_Rose; diff --git a/Ada/gilded_rose_tester.adb b/Ada/gilded_rose_tester.adb deleted file mode 100644 index 938e16a2..00000000 --- a/Ada/gilded_rose_tester.adb +++ /dev/null @@ -1,10 +0,0 @@ -with Ahven.Text_Runner; -with Ahven.Framework; -with Gilded_Rose_Tests; - -procedure Gilded_Rose_Tester is - S : Ahven.Framework.Test_Suite := Ahven.Framework.Create_Suite("All"); -begin - Ahven.Framework.Add_Test(S, new Gilded_Rose_Tests.Test); - Ahven.Text_Runner.Run(S); -end Gilded_Rose_Tester; diff --git a/Ada/gilded_rose_tests.adb b/Ada/gilded_rose_tests.adb deleted file mode 100644 index 537f6cb8..00000000 --- a/Ada/gilded_rose_tests.adb +++ /dev/null @@ -1,38 +0,0 @@ -with Gilded_Rose; -use Gilded_Rose; - -with Items; -use Items; - -with Ahven; - -with Ada.Strings.Unbounded; - -package body Gilded_Rose_Tests is - procedure Initialize(T : in out Test) is - begin - Set_Name(T, "Gilded_Rose_Test"); - Ahven.Framework.Add_Test_Routine(T, Test_Gilded_Rose'Access, "Foo"); - end Initialize; - - procedure Test_Gilded_Rose is - Things : Item_Vecs.Vector; - begin - Things.Append(New_Item => - (Name => SU.To_Unbounded_String("Foo"), - Sell_In => 0, - Quality => 0)); - declare - App : Gilded_Rose.Gilded_Rose := (Items => Things); - - package SU renames Ada.Strings.Unbounded; - procedure Assert_Eq_Unbounded_String is - new Ahven.Assert_Equal(Data_Type => SU.Unbounded_String, Image => SU.To_String); - begin - Update_Quality(App); - Assert_Eq_Unbounded_String(Actual => App.Items(Item_Vecs.First(App.Items)).Name, - Expected => SU.To_Unbounded_String("fixme"), - Message => "fixme"); - end; - end; -end Gilded_Rose_Tests; diff --git a/Ada/gilded_rose_tests.ads b/Ada/gilded_rose_tests.ads deleted file mode 100644 index f6c1b40c..00000000 --- a/Ada/gilded_rose_tests.ads +++ /dev/null @@ -1,11 +0,0 @@ -with Ahven.Framework; - -package Gilded_Rose_Tests is - type Test is new Ahven.Framework.Test_Case with null record; - - procedure Initialize(T : in out Test); - - private - - procedure Test_Gilded_Rose; -end Gilded_Rose_Tests; diff --git a/Ada/items.adb b/Ada/items.adb deleted file mode 100644 index 5348d64d..00000000 --- a/Ada/items.adb +++ /dev/null @@ -1,31 +0,0 @@ -with Ada.Strings.Unbounded; -use Ada.Strings.Unbounded; - -package body Items is - function Integer_Image(Self : in Integer) return String is - Img : constant String := Integer'Image(Self); - begin - if Self < 0 then - return Img; - else - return Img(2 .. Img'Length); - end if; - end; - - function To_String(Self : in Item) return String is - Name : constant Unbounded_String := Self.Name; - Sell_In : constant Unbounded_String := To_Unbounded_String(Integer_Image(Self.Sell_In)); - Quality : constant Unbounded_String := To_Unbounded_String(Integer_Image(Self.Quality)); - - Ret : Unbounded_String; - begin - Append(Ret, Name); - Append(Ret, ", "); - Append(Ret, Sell_In); - Append(Ret, ", "); - Append(Ret, Quality); - - return To_String(Ret); - end; - -end Items; diff --git a/Ada/items.ads b/Ada/items.ads deleted file mode 100644 index a2a588d4..00000000 --- a/Ada/items.ads +++ /dev/null @@ -1,14 +0,0 @@ -with Ada.Strings.Unbounded; - -package Items is - package SU renames Ada.Strings.Unbounded; - - type Item is record - Name : SU.Unbounded_String; - Sell_In : Integer; - Quality : Integer; - end record; - - function To_String(Self : in Item) return String; - -end Items; diff --git a/Ada/program.adb b/Ada/program.adb deleted file mode 100644 index 336f952a..00000000 --- a/Ada/program.adb +++ /dev/null @@ -1,72 +0,0 @@ -with Ada.Text_IO; -use Ada.Text_IO; - -with Items; -use Items; - -with Ada.Strings.Unbounded; -use Ada.Strings.Unbounded; - -with Gilded_Rose; -use Gilded_Rose; - -procedure Program is - Things : Item_Vecs.Vector; -begin - Things.Append(New_Item => - (Name => To_Unbounded_String("+5 Dexterity Vest"), - Sell_In => 10, - Quality => 20)); - Things.Append(New_Item => - (Name => To_Unbounded_String("Aged Brie"), - Sell_In => 2, - Quality => 0)); - Things.Append(New_Item => - (Name => To_Unbounded_String("Elixir of the Mongoose"), - Sell_In => 5, - Quality => 7)); - Things.Append(New_Item => - (Name => To_Unbounded_String("Sulfuras, Hand of Ragnaros"), - Sell_In => 0, - Quality => 80)); - Things.Append(New_Item => - (Name => To_Unbounded_String("Sulfuras, Hand of Ragnaros"), - Sell_In => -1, - Quality => 80)); - Things.Append(New_Item => - (Name => To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert"), - Sell_In => 15, - Quality => 20)); - Things.Append(New_Item => - (Name => To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert"), - Sell_In => 10, - Quality => 49)); - Things.Append(New_Item => - (Name => To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert"), - Sell_In => 5, - Quality => 49)); - -- this conjured item does not work properly yet - Things.Append(New_Item => - (Name => To_Unbounded_String("Conjured Mana Cake"), - Sell_In => 3, - Quality => 6)); - - - declare - App : Gilded_Rose.Gilded_Rose := (Items => Things); - begin - Put_Line("OMGHAI!"); - - for I in 0 .. 30 loop - Put_Line("-------- day" & Integer'Image(I) & " --------"); - Put_Line("name, sellIn, quality"); - - for Each of App.Items loop - Put_Line(To_String(Each)); - end loop; - Put_Line(""); - - Update_Quality(App); - end loop; - end; -end; diff --git a/C/GildedRose.c b/C/GildedRose.c deleted file mode 100644 index afb97bbe..00000000 --- a/C/GildedRose.c +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include "GildedRose.h" - -Item* -init_item(Item* item, const char *name, int sellIn, int quality) -{ - item->sellIn = sellIn; - item->quality = quality; - item->name = strdup(name); - - return item; -} - -void update_quality(Item items[], int size) -{ - int i; - - for (i = 0; i < size; i++) - { - if (strcmp(items[i].name, "Aged Brie") && strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) - { - if (items[i].quality > 0) - { - if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) - { - items[i].quality = items[i].quality - 1; - } - } - } - else - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - - if (!strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) - { - if (items[i].sellIn < 11) - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - - if (items[i].sellIn < 6) - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - } - } - } - - if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) - { - items[i].sellIn = items[i].sellIn - 1; - } - - if (items[i].sellIn < 0) - { - if (strcmp(items[i].name, "Aged Brie")) - { - if (strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) - { - if (items[i].quality > 0) - { - if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) - { - items[i].quality = items[i].quality - 1; - } - } - } - else - { - items[i].quality = items[i].quality - items[i].quality; - } - } - else - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - } - } -} diff --git a/C/GildedRose.h b/C/GildedRose.h deleted file mode 100644 index 78d54a08..00000000 --- a/C/GildedRose.h +++ /dev/null @@ -1,9 +0,0 @@ -typedef struct -{ - char *name; - int sellIn; - int quality; -} Item; - -extern Item* init_item(Item* item, const char *name, int sellIn, int quality); -extern void update_quality(Item items[], int size); diff --git a/C/GildedRoseTextTests.c b/C/GildedRoseTextTests.c deleted file mode 100644 index d200ca0c..00000000 --- a/C/GildedRoseTextTests.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include "GildedRose.h" - -int -print_item(Item *item) -{ - return printf("%s, %d, %d\n", item->name, item->sellIn, item->quality); -} - -int main() -{ - Item items[9]; - int last = 0; - int day; - int index; - - init_item(items + last++, "+5 Dexterity Vest", 10, 20); - init_item(items + last++, "Aged Brie", 2, 0); - init_item(items + last++, "Elixir of the Mongoose", 5, 7); - init_item(items + last++, "Sulfuras, Hand of Ragnaros", 0, 80); - init_item(items + last++, "Sulfuras, Hand of Ragnaros", -1, 80); - init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 15, 20); - init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 10, 49); - init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 5, 49); - // this Conjured item doesn't yet work properly - init_item(items + last++, "Conjured Mana Cake", 3, 6); - - puts("OMGHAI!"); - - for (day = 0; day <= 30; day++) - { - printf("-------- day %d --------\n", day); - printf("name, sellIn, quality\n"); - for(index = 0; index < last; index++) { - print_item(items + index); - } - - printf("\n"); - - update_quality(items, last); - } - return 0; -} diff --git a/C/GildedRoseUnitTests.cc b/C/GildedRoseUnitTests.cc deleted file mode 100644 index 6d06fdb7..00000000 --- a/C/GildedRoseUnitTests.cc +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -extern "C" { -#include "GildedRose.h" -} - -TEST_GROUP(TestGildedRoseGroup) -{ - void setup() { - } - void teardown() { - } -}; - -TEST(TestGildedRoseGroup, FirstTest) -{ - Item items[2]; - init_item(items, "Foo", 0, 0); - update_quality(items, 1); - STRCMP_EQUAL("fixme", items[0].name); -} - -void example() -{ - Item items[6]; - int last = 0; - - init_item(items + last++, "+5 Dexterity Vest", 10, 20); - init_item(items + last++, "Aged Brie", 2, 0); - init_item(items + last++, "Elixir of the Mongoose", 5, 7); - init_item(items + last++, "Sulfuras, Hand of Ragnaros", 0, 80); - init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 15, 20); - init_item(items + last++, "Conjured Mana Cake", 3, 6); - update_quality(items, last); -} - -int -main(int ac, char** av) -{ - return CommandLineTestRunner::RunAllTests(ac, av); -} diff --git a/C/Makefile b/C/Makefile deleted file mode 100644 index 3a695892..00000000 --- a/C/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# Makefile for building the kata file with the Google Testing Framework -# -# SYNOPSIS: -# -# make [all] - makes everything. -# make TARGET - makes the given target. -# make clean - removes all files generated by make. - -# Please tweak the following variable definitions as needed by your -# project. - -# Points to the root of CppUTest, relative to where this file is. -# Remember to tweak this if you move this file. -CPPUTEST_HOME = CppUTest - -# Where to find user code. -USER_DIR = . - -# Flags passed to the preprocessor. -CPPFLAGS += -I$(CPPUTEST_HOME)/include - -# Flags passed to the C++ compiler. -CFLAGS += -g -Wall -Wextra - -LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest - -# All tests produced by this Makefile. Remember to add new tests you -# created to the list. -TESTS = GildedRoseUnitTests - -TEXTTESTS = GildedRoseTextTests - -# House-keeping build targets. - -all : $(TESTS) $(TEXTTESTS) - -GildedRose.o : $(USER_DIR)/GildedRose.c - -GildedRoseUnitTests : $(USER_DIR)/GildedRoseUnitTests.cc GildedRose.o - $(CXX) $(CPPFLAGS) $(CFLAGS) -o $@ $(USER_DIR)/GildedRoseUnitTests.cc GildedRose.o $(LD_LIBRARIES) - -GildedRoseTextTests.o : $(USER_DIR)/GildedRoseTextTests.c - -GildedRoseTextTests : GildedRoseTextTests.o GildedRose.o - $(CC) $^ -o $@ - -clean : - rm -f $(TESTS) $(TEXTTESTS) *.o *~ - -check-syntax: - gcc $(CPPFLAGS) -o /dev/null -S ${CHK_SOURCES} diff --git a/C/README.txt b/C/README.txt deleted file mode 100644 index 2bc1f69b..00000000 --- a/C/README.txt +++ /dev/null @@ -1,5 +0,0 @@ -run-once.sh runs your tests once - -Assumptions: - - make and a C++ compiler (like gcc) is installed on your system and is in the PATH - - The CppUTest framework is in the directory CppUTest diff --git a/C/run-once.sh b/C/run-once.sh deleted file mode 100755 index 4f6b2303..00000000 --- a/C/run-once.sh +++ /dev/null @@ -1,2 +0,0 @@ -make -./GildedRoseTextTests diff --git a/COBOL/mf/src/.cobolProj b/COBOL/mf/src/.cobolProj deleted file mode 100644 index b47b56d0..00000000 --- a/COBOL/mf/src/.cobolProj +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/COBOL/mf/src/.gitignore b/COBOL/mf/src/.gitignore deleted file mode 100644 index eea4e81d..00000000 --- a/COBOL/mf/src/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.cobolBuild -/Gilded_Rose.bin/ diff --git a/COBOL/mf/src/.project b/COBOL/mf/src/.project deleted file mode 100644 index a702b492..00000000 --- a/COBOL/mf/src/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Gilded Rose - - - - - - com.microfocus.eclipse.project.cobolBuilder - - - - - - com.microfocus.eclipse.project.cobolNature - - diff --git a/COBOL/mf/src/GildedRose.cbl b/COBOL/mf/src/GildedRose.cbl deleted file mode 100644 index 28ff10a2..00000000 --- a/COBOL/mf/src/GildedRose.cbl +++ /dev/null @@ -1,72 +0,0 @@ -program-id. GildedRose as "GildedRose". - -file-control. - select in-items assign 'in-items'. - select items assign 'items'. - -data division. -file section. - fd in-items. - 01 in-item pic x(58). - fd items. - 01 item. - 02 sell-in pic 9(4). - 02 quality pic 9(4). - 02 name pic x(50). - -working-storage section. -procedure division. - open input in-items output items. -start-lable. - read in-items end go to end-lable. - move in-item to item. - if name not equal "Aged Brie" and name not equal "Backstage passes to a TAFKAL80ETC concert" - if quality greater then 0 - if name not equal to "Sulfuras, Hand of Ragnaros" - compute quality = quality - 1 - end-if - end-if - else - if quality is less then 50 - compute quality = quality + 1 - if name equals "Backstage passes to a TAFKAL80ETC concert" - if sell-in less then 11 - if quality less then 50 - compute quality = quality + 1 - end-if - end-if - if sell-in less then 6 - if quality less then 50 - compute quality = quality + 1 - end-if - end-if - end-if - end-if - end-if - if name not equal "Sulfuras, Hand of Ragnaros" - compute sell-in = sell-in - 1 - end-if - if sell-in is less then 0 - if name is not equal to "Aged Brie" - if name is not equal to "Backstage passes to a TAFKAL80ETC concert" - if quality is greater then 0 - if name is equal to "Sulfuras, Hand of Ragnaros" - compute quality = quality - 1 - end-if - end-if - else - compute quality = quality - quality - end-if - else - if quality is less then 50 - compute quality = quality + 1 - end-if - end-if - end-if - write item. - go to start-lable. -end-lable. - close items. -goback. - -end program GildedRose. diff --git a/COBOL/mf/test/.cobolProj b/COBOL/mf/test/.cobolProj deleted file mode 100644 index 53304fe0..00000000 --- a/COBOL/mf/test/.cobolProj +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/COBOL/mf/test/.gitignore b/COBOL/mf/test/.gitignore deleted file mode 100644 index 21774bfb..00000000 --- a/COBOL/mf/test/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/.cobolBuild -/Coverage/ -/Tests.bin/ diff --git a/COBOL/mf/test/.project b/COBOL/mf/test/.project deleted file mode 100644 index 2615ee47..00000000 --- a/COBOL/mf/test/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - Tests - - - - - - com.microfocus.eclipse.project.cobolBuilder - - - - - com.microfocus.eclipse.mfunit.core.mfUnitBuilder - - - - - - com.microfocus.eclipse.project.cobolNature - com.microfocus.eclipse.mfunit.core.mfUnitNature - - diff --git a/COBOL/mf/test/TestGildedRose.cbl b/COBOL/mf/test/TestGildedRose.cbl deleted file mode 100644 index d9802330..00000000 --- a/COBOL/mf/test/TestGildedRose.cbl +++ /dev/null @@ -1,67 +0,0 @@ - *> Test Fixture for GildedRose, GildedRose - - copy "mfunit_prototypes.cpy". - - program-id. TestGildedRose. - - file-control. - select in-items assign 'in-items'. - select items assign 'items'. - - file section. - fd in-items. - 01 in-item. - 02 sell-in pic 9(4). - 02 quality pic 9(4). - 02 name pic x(50). - fd items. - 01 item. - 02 sell-in pic 9(4). - 02 quality pic 9(4). - 02 name pic x(50). - - working-storage section. - copy "mfunit.cpy". - 78 TEST-TESTGILDEDROSE value "TestGildedRose". - 01 pp procedure-pointer. - - *> Program linkage data - - procedure division. - goback returning 0 - . - - entry MFU-TC-PREFIX & TEST-TESTGILDEDROSE. - open output in-items - move "foo" to name in in-item - move 0 to quality in in-item - move 0 to sell-in in in-item - write in-item - close in-items - call "GildedRose" - open input items - read items - if name in item not equal to "fixme" then - call MFU-ASSERT-FAIL-Z using z"item name was not fixme" - close items - goback - . - - $region TestCase Configuration - - entry MFU-TC-SETUP-PREFIX & TEST-TESTGILDEDROSE. - perform InitializeLinkageData - *> Add any other test setup code here - goback returning 0 - . - - InitializeLinkageData section. - *> Load the library that is being tested - set pp to entry "GildedRose" - - exit section - . - - $end-region - - end program. diff --git a/Delphi/.gitattributes b/Delphi/.gitattributes deleted file mode 100644 index f4e939ab..00000000 --- a/Delphi/.gitattributes +++ /dev/null @@ -1,17 +0,0 @@ -# Set the default behavior, in case people don't have core.autocrlf set. -* text=auto - -# Explicitly declare text files you want to always be normalized and converted -# to native line endings on checkout. -*.groupproj text -*.dpr text -*.dproj text -*.pas text -*.dfm text -*.fmx text - -# Declare files that will always have CRLF line endings on checkout. - -# Denote all files that are truly binary and should not be modified. -*.exe binary -*.res binary diff --git a/Delphi/.gitignore b/Delphi/.gitignore deleted file mode 100644 index 1098ab8a..00000000 --- a/Delphi/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# Uncomment these types if you want even more clean repository. But be careful. -# It can make harm to an existing project source. Read explanations below. -# -# Resource files are binaries containing manifest, project icon and version info. -# They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files. -*.res -# -# Type library file (binary). In old Delphi versions it should be stored. -# Since Delphi 2009 it is produced from .ridl file and can safely be ignored. -#*.tlb -# -# Diagram Portfolio file. Used by the diagram editor up to Delphi 7. -# Uncomment this if you are not using diagrams or use newer Delphi version. -#*.ddp -# -# Visual LiveBindings file. Added in Delphi XE2. -# Uncomment this if you are not using LiveBindings Designer. -#*.vlb -# -# Deployment Manager configuration file for your project. Added in Delphi XE2. -# Uncomment this if it is not mobile development and you do not use remote debug feature. -#*.deployproj -# -# C++ object files produced when C/C++ Output file generation is configured. -# Uncomment this if you are not using external objects (zlib library for example). -#*.obj -# - -# Delphi compiler-generated binaries (safe to delete) -*.exe -*.dll -*.bpl -*.bpi -*.dcp -*.so -*.apk -*.drc -*.map -*.dres -*.rsm -*.tds -*.dcu -*.lib -*.a -*.o -*.ocx - -# Delphi autogenerated files (duplicated info) -*.cfg -*.hpp -*Resource.rc - -# Delphi local files (user-specific info) -*.local -*.identcache -*.projdata -*.tvsconfig -*.dsk - -# Delphi history and backups -__history/ -__recovery/ -*.~* - -# Castalia statistics file (since XE7 Castalia is distributed with Delphi) -*.stat - -# Ignore Build outputs -Build -Win32 -Win64 diff --git a/Delphi/GildedRose.groupproj b/Delphi/GildedRose.groupproj deleted file mode 100644 index d2a77d91..00000000 --- a/Delphi/GildedRose.groupproj +++ /dev/null @@ -1,48 +0,0 @@ - - - {3E0B3749-4258-486E-A44B-05088E7E42D6} - - - - - - - - - - - Default.Personality.12 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Delphi/GildedRose.pas b/Delphi/GildedRose.pas deleted file mode 100644 index dacd209f..00000000 --- a/Delphi/GildedRose.pas +++ /dev/null @@ -1,106 +0,0 @@ -unit GildedRose; - -interface - -uses - Item, - System.Generics.Collections; - -type - TGildedRose = class(TObject) - private - FItems: TObjectList; - public - constructor Create(const AItems: TObjectList); - procedure UpdateQuality; - property Items: TObjectList read FItems; - end; - -implementation - -{ TGildedRose } - -constructor TGildedRose.Create(const AItems: TObjectList); -begin - inherited Create; - FItems := AItems; -end; - -procedure TGildedRose.UpdateQuality; -var - I: Integer; -begin - for I := 0 to Items.Count - 1 do - begin - if (Items[I].Name <> 'Aged Brie') and (Items[I].Name <> 'Backstage passes to a TAFKAL80ETC concert') then - begin - if Items[I].Quality > 0 then - begin - if Items[I].Name <> 'Sulfuras, Hand of Ragnaros' then - begin - Items[I].Quality := Items[I].Quality - 1; - end; - end; - end - else - begin - if Items[I].Quality < 50 then - begin - Items[I].Quality := Items[I].Quality + 1; - if Items[I].Name = 'Backstage passes to a TAFKAL80ETC concert' then - begin - if Items[I].SellIn < 11 then - begin - if Items[I].Quality < 50 then - begin - Items[I].Quality := Items[I].Quality + 1; - end; - end; - - if Items[I].SellIn < 6 then - begin - if Items[I].Quality < 50 then - begin - Items[I].Quality := Items[I].Quality + 1; - end; - end; - end; - end; - end; - - if Items[I].Name <> 'Sulfuras, Hand of Ragnaros' then - begin - Items[I].SellIn := Items[I].SellIn - 1; - end; - - if Items[I].SellIn < 0 then - begin - if Items[I].Name <> 'Aged Brie' then - begin - if Items[I].Name <> 'Backstage passes to a TAFKAL80ETC concert' then - begin - if Items[I].Quality > 0 then - begin - if Items[I].Name <> 'Sulfuras, Hand of Ragnaros' then - begin - Items[I].Quality := Items[I].Quality - 1; - end; - end; - end - else - begin - Items[I].Quality := Items[I].Quality - Items[I].Quality; - end; - end - else - begin - if Items[I].Quality < 50 then - begin - Items[I].Quality := Items[I].Quality + 1; - end; - end; - end; - end; -end; - -end. diff --git a/Delphi/GildedRoseTests.pas b/Delphi/GildedRoseTests.pas deleted file mode 100644 index 2e15adde..00000000 --- a/Delphi/GildedRoseTests.pas +++ /dev/null @@ -1,36 +0,0 @@ -unit GildedRoseTests; - -interface -uses - DUnitX.TestFramework, - GildedRose, - Item, - System.Generics.Collections; - -type - [TestFixture] - TGildedRoseTests = class(TObject) - public - [Test] - procedure UpdateQuality_Never_ChangesTheItemName; - end; - -implementation - -procedure TGildedRoseTests.UpdateQuality_Never_ChangesTheItemName; -var - LItems: TObjectList; - LGildedRose: TGildedRose; -begin - LItems := TObjectList.Create; - LItems.Add(TItem.Create('foo', 0, 0)); - LGildedRose := TGildedRose.Create(LItems); - - LGildedRose.UpdateQuality; - - Assert.AreEqual('fixme', LGildedRose.Items[0].Name); -end; - -initialization - TDUnitX.RegisterTestFixture(TGildedRoseTests); -end. diff --git a/Delphi/Item.pas b/Delphi/Item.pas deleted file mode 100644 index c74f1650..00000000 --- a/Delphi/Item.pas +++ /dev/null @@ -1,39 +0,0 @@ -unit Item; - -interface - -type - TItem = class(TObject) - private - FName: string; - FSellIn: Integer; - FQuality: Integer; - public - constructor Create(const AName: string; const ASellIn, AQuality: Integer); - function ToString: string; override; - property Name: string read FName write FName; - property SellIn: Integer read FSellIn write FSellIn; - property Quality: Integer read FQuality write FQuality; - end; - -implementation - -uses - System.SysUtils; - -{ TItem } - -constructor TItem.Create(const AName: string; const ASellIn, AQuality: Integer); -begin - inherited Create; - FName := AName; - FSellIn := ASellIn; - FQuality := AQuality; -end; - -function TItem.ToString: string; -begin - Result := Format('%s, %d, %d', [Name, SellIn, Quality]); -end; - -end. diff --git a/Delphi/README.md b/Delphi/README.md deleted file mode 100644 index 7023295c..00000000 --- a/Delphi/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Delphi port of the Gilded-Rose Kata -This is a Delphi port of the *Gilded-Rose-Kata*. - -## Version Compatibility -The project files are written in Delphi 10.3.3 therefore require 10.3 or later. -That said, the actual code should be compatible back to Delphi 2010 as the unit -tests are written in [DUnitX](https://github.com/VSoftTechnologies/DUnitX) which -requires Delphi 2010 or later. - -## Building and Running -* Open the project group `GildedRose.groupproj`. -* Build and run the `TextTestFixture.exe` for the text output tests. -* Build and run the `UnitTests.exe` project to execute the unit tests. diff --git a/Delphi/TextTestFixture.dpr b/Delphi/TextTestFixture.dpr deleted file mode 100644 index dd325d39..00000000 --- a/Delphi/TextTestFixture.dpr +++ /dev/null @@ -1,57 +0,0 @@ -program TextTestFixture; - -{$APPTYPE CONSOLE} - -{$R *.res} - -uses - System.SysUtils, - System.Generics.Collections, - GildedRose in 'GildedRose.pas', - Item in 'Item.pas'; - -var - Days, ErrorCode, I, J: Integer; - Items: TObjectList; - App: TGildedRose; - -begin - try - Writeln('OMGHAI!'); - - Items := TObjectList.Create; - Items.Add(TItem.Create('+5 Dexterity Vest', 10, 20)); - Items.Add(TItem.Create('Aged Brie', 2, 0)); - Items.Add(TItem.Create('Elixir of the Mongoose', 5, 7)); - Items.Add(TItem.Create('Sulfuras, Hand of Ragnaros', 0, 80)); - Items.Add(TItem.Create('Sulfuras, Hand of Ragnaros', -1, 80)); - Items.Add(TItem.Create('Backstage passes to a TAFKAL80ETC concert', 15, 20)); - Items.Add(TItem.Create('Backstage passes to a TAFKAL80ETC concert', 10, 49)); - Items.Add(TItem.Create('Backstage passes to a TAFKAL80ETC concert', 5, 49)); - // this conjured item does not work properly yet - Items.Add(TItem.Create('Conjured Mana Cake', 3, 6)); - - App := TGildedRose.Create(Items); - - Days := 2; - if ParamCount > 0 then - begin - Val(ParamStr(1), Days, ErrorCode); - Inc(Days); - end; - - for I := 0 to Days - 1 do - begin - Writeln(Format('-------- day %d --------', [I])); - Writeln('name, sellIn, quality'); - for J := 0 to Items.Count - 1 do - Writeln(Items[J].ToString); - Writeln; - - App.UpdateQuality; - end; - except - on E: Exception do - Writeln(E.ClassName, ': ', E.Message); - end; -end. diff --git a/Delphi/TextTestFixture.dproj b/Delphi/TextTestFixture.dproj deleted file mode 100644 index 2651f9ee..00000000 --- a/Delphi/TextTestFixture.dproj +++ /dev/null @@ -1,1019 +0,0 @@ - - - {3166A4F2-2D40-49FF-9A28-E46E603C9C6A} - 18.8 - None - TextTestFixture.dpr - True - Debug - Win32 - 1 - Console - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_1 - true - true - - - true - Base - true - - - .\$(Platform)\$(Config) - .\$(Platform)\$(Config) - false - false - false - false - false - System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) - TextTestFixture - - - DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;bindcompfmx;FmxTeeUI;fmx;FireDACIBDriver;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FMXTee;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage) - - - DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;bindcompfmx;FmxTeeUI;fmx;FireDACIBDriver;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FMXTee;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage) - - - DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;bindcompfmx;FmxTeeUI;fmx;FireDACIBDriver;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FMXTee;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage) - - - DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;FireDACMSSQLDriver;bindcompfmx;DBXOracleDriver;inetdb;FmxTeeUI;fmx;FireDACIBDriver;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;FireDACDSDriver;rtl;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;bindcomp;DBXInformixDriver;IndyIPClient;dbxcds;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) - true - - - DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;FireDACMSSQLDriver;bindcompfmx;DBXOracleDriver;inetdb;FmxTeeUI;fmx;FireDACIBDriver;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;FireDACDSDriver;rtl;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;bindcomp;DBXInformixDriver;IndyIPClient;dbxcds;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) - true - - - DBXSqliteDriver;RESTComponents;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;tethering;svnui;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;fmx;FireDACIBDriver;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;emsserverresource;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) - Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - Debug - CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= - 1033 - true - $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png - $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png - - - DBXSqliteDriver;RESTComponents;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;tethering;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;fmx;FireDACIBDriver;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;emsserverresource;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) - true - $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png - $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png - - - DEBUG;$(DCC_Define) - true - false - true - true - true - - - false - - - false - RELEASE;$(DCC_Define) - 0 - 0 - - - - MainSource - - - - - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - - - - Delphi.Personality.12 - Application - - - - TextTestFixture.dpr - - - - - - true - - - - - true - - - - - true - - - - - TextTestFixture.exe - true - - - - - 1 - - - Contents\MacOS - 1 - - - 0 - - - - - classes - 1 - - - classes - 1 - - - - - res\xml - 1 - - - res\xml - 1 - - - - - library\lib\armeabi-v7a - 1 - - - - - library\lib\armeabi - 1 - - - library\lib\armeabi - 1 - - - - - library\lib\armeabi-v7a - 1 - - - - - library\lib\mips - 1 - - - library\lib\mips - 1 - - - - - library\lib\armeabi-v7a - 1 - - - library\lib\arm64-v8a - 1 - - - - - library\lib\armeabi-v7a - 1 - - - - - res\drawable - 1 - - - res\drawable - 1 - - - - - res\values - 1 - - - res\values - 1 - - - - - res\values-v21 - 1 - - - res\values-v21 - 1 - - - - - res\values - 1 - - - res\values - 1 - - - - - res\drawable - 1 - - - res\drawable - 1 - - - - - res\drawable-xxhdpi - 1 - - - res\drawable-xxhdpi - 1 - - - - - res\drawable-ldpi - 1 - - - res\drawable-ldpi - 1 - - - - - res\drawable-mdpi - 1 - - - res\drawable-mdpi - 1 - - - - - res\drawable-hdpi - 1 - - - res\drawable-hdpi - 1 - - - - - res\drawable-xhdpi - 1 - - - res\drawable-xhdpi - 1 - - - - - res\drawable-mdpi - 1 - - - res\drawable-mdpi - 1 - - - - - res\drawable-hdpi - 1 - - - res\drawable-hdpi - 1 - - - - - res\drawable-xhdpi - 1 - - - res\drawable-xhdpi - 1 - - - - - res\drawable-xxhdpi - 1 - - - res\drawable-xxhdpi - 1 - - - - - res\drawable-xxxhdpi - 1 - - - res\drawable-xxxhdpi - 1 - - - - - res\drawable-small - 1 - - - res\drawable-small - 1 - - - - - res\drawable-normal - 1 - - - res\drawable-normal - 1 - - - - - res\drawable-large - 1 - - - res\drawable-large - 1 - - - - - res\drawable-xlarge - 1 - - - res\drawable-xlarge - 1 - - - - - res\values - 1 - - - res\values - 1 - - - - - 1 - - - Contents\MacOS - 1 - - - 0 - - - - - Contents\MacOS - 1 - .framework - - - Contents\MacOS - 1 - .framework - - - 0 - - - - - 1 - .dylib - - - 1 - .dylib - - - 1 - .dylib - - - Contents\MacOS - 1 - .dylib - - - Contents\MacOS - 1 - .dylib - - - 0 - .dll;.bpl - - - - - 1 - .dylib - - - 1 - .dylib - - - 1 - .dylib - - - Contents\MacOS - 1 - .dylib - - - Contents\MacOS - 1 - .dylib - - - 0 - .bpl - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - Contents\Resources\StartUp\ - 0 - - - Contents\Resources\StartUp\ - 0 - - - 0 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - - - - - 1 - - - 1 - - - - - ..\ - 1 - - - ..\ - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - - - - - ..\ - 1 - - - ..\ - 1 - - - - - Contents - 1 - - - Contents - 1 - - - - - Contents\Resources - 1 - - - Contents\Resources - 1 - - - - - library\lib\armeabi-v7a - 1 - - - library\lib\arm64-v8a - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - Contents\MacOS - 1 - - - Contents\MacOS - 1 - - - 0 - - - - - library\lib\armeabi-v7a - 1 - - - - - 1 - - - 1 - - - - - Assets - 1 - - - Assets - 1 - - - - - Assets - 1 - - - Assets - 1 - - - - - - - - - - - - - - - False - False - False - False - False - True - False - - - 12 - - - - - diff --git a/Delphi/UnitTests.dpr b/Delphi/UnitTests.dpr deleted file mode 100644 index 1986cbb8..00000000 --- a/Delphi/UnitTests.dpr +++ /dev/null @@ -1,59 +0,0 @@ -program UnitTests; - -{$IFNDEF TESTINSIGHT} -{$APPTYPE CONSOLE} -{$ENDIF}{$STRONGLINKTYPES ON} -uses - System.SysUtils, - {$IFDEF TESTINSIGHT} - TestInsight.DUnitX, - {$ENDIF } - DUnitX.Loggers.Console, - DUnitX.Loggers.Xml.NUnit, - DUnitX.TestFramework, - GildedRoseTests in 'GildedRoseTests.pas'; - -var - runner : ITestRunner; - results : IRunResults; - logger : ITestLogger; - nunitLogger : ITestLogger; -begin -{$IFDEF TESTINSIGHT} - TestInsight.DUnitX.RunRegisteredTests; - exit; -{$ENDIF} - try - //Check command line options, will exit if invalid - TDUnitX.CheckCommandLine; - //Create the test runner - runner := TDUnitX.CreateRunner; - //Tell the runner to use RTTI to find Fixtures - runner.UseRTTI := True; - //tell the runner how we will log things - //Log to the console window - logger := TDUnitXConsoleLogger.Create(true); - runner.AddLogger(logger); - //Generate an NUnit compatible XML File - nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile); - runner.AddLogger(nunitLogger); - runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests; - - //Run tests - results := runner.Execute; - if not results.AllPassed then - System.ExitCode := EXIT_ERRORS; - - {$IFNDEF CI} - //We don't want this happening when running under CI. - if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then - begin - System.Write('Done.. press key to quit.'); - System.Readln; - end; - {$ENDIF} - except - on E: Exception do - System.Writeln(E.ClassName, ': ', E.Message); - end; -end. diff --git a/Delphi/UnitTests.dproj b/Delphi/UnitTests.dproj deleted file mode 100644 index 1cd2fa7e..00000000 --- a/Delphi/UnitTests.dproj +++ /dev/null @@ -1,937 +0,0 @@ - - - {9379A28B-85A1-455B-BE8B-BDE5DD446BDF} - 18.8 - None - UnitTests.dpr - True - Debug - Win32 - 1 - Console - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_1 - true - true - - - true - Base - true - - - .\$(Platform)\$(Config) - .\$(Platform)\$(Config) - false - false - false - false - false - System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) - $(BDS)\bin\delphi_PROJECTICON.ico - $(BDS)\bin\delphi_PROJECTICNS.icns - $(DUnitX);$(DCC_UnitSearchPath) - UnitTests - - - DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;bindcompfmx;FmxTeeUI;fmx;FireDACIBDriver;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FMXTee;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage) - - - DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;bindcompfmx;FmxTeeUI;fmx;FireDACIBDriver;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FMXTee;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage) - - - DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;bindcompfmx;FmxTeeUI;fmx;FireDACIBDriver;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FMXTee;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage) - - - DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;FireDACMSSQLDriver;bindcompfmx;DBXOracleDriver;inetdb;FmxTeeUI;fmx;FireDACIBDriver;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;FireDACDSDriver;rtl;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;bindcomp;DBXInformixDriver;IndyIPClient;dbxcds;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) - - - DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;FireDACMSSQLDriver;bindcompfmx;DBXOracleDriver;inetdb;FmxTeeUI;fmx;FireDACIBDriver;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;FireDACDSDriver;rtl;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;bindcomp;DBXInformixDriver;IndyIPClient;dbxcds;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) - - - DBXSqliteDriver;RESTComponents;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;tethering;svnui;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;fmx;FireDACIBDriver;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;emsserverresource;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) - Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - Debug - CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= - 1033 - - - DBXSqliteDriver;RESTComponents;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;tethering;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;fmx;FireDACIBDriver;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;emsserverresource;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) - - - DEBUG;$(DCC_Define) - true - false - true - true - true - - - false - - - false - RELEASE;$(DCC_Define) - 0 - 0 - - - - MainSource - - - - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - - - - Delphi.Personality.12 - Console - - - - UnitTests.dpr - - - - - - true - - - - - true - - - - - true - - - - - UnitTests.exe - true - - - - - 1 - - - 0 - - - - - classes - 1 - - - classes - 1 - - - - - res\xml - 1 - - - res\xml - 1 - - - - - library\lib\armeabi-v7a - 1 - - - - - library\lib\armeabi - 1 - - - library\lib\armeabi - 1 - - - - - library\lib\armeabi-v7a - 1 - - - - - library\lib\mips - 1 - - - library\lib\mips - 1 - - - - - library\lib\armeabi-v7a - 1 - - - library\lib\arm64-v8a - 1 - - - - - library\lib\armeabi-v7a - 1 - - - - - res\drawable - 1 - - - res\drawable - 1 - - - - - res\values - 1 - - - res\values - 1 - - - - - res\values-v21 - 1 - - - res\values-v21 - 1 - - - - - res\values - 1 - - - res\values - 1 - - - - - res\drawable - 1 - - - res\drawable - 1 - - - - - res\drawable-xxhdpi - 1 - - - res\drawable-xxhdpi - 1 - - - - - res\drawable-ldpi - 1 - - - res\drawable-ldpi - 1 - - - - - res\drawable-mdpi - 1 - - - res\drawable-mdpi - 1 - - - - - res\drawable-hdpi - 1 - - - res\drawable-hdpi - 1 - - - - - res\drawable-xhdpi - 1 - - - res\drawable-xhdpi - 1 - - - - - res\drawable-mdpi - 1 - - - res\drawable-mdpi - 1 - - - - - res\drawable-hdpi - 1 - - - res\drawable-hdpi - 1 - - - - - res\drawable-xhdpi - 1 - - - res\drawable-xhdpi - 1 - - - - - res\drawable-xxhdpi - 1 - - - res\drawable-xxhdpi - 1 - - - - - res\drawable-xxxhdpi - 1 - - - res\drawable-xxxhdpi - 1 - - - - - res\drawable-small - 1 - - - res\drawable-small - 1 - - - - - res\drawable-normal - 1 - - - res\drawable-normal - 1 - - - - - res\drawable-large - 1 - - - res\drawable-large - 1 - - - - - res\drawable-xlarge - 1 - - - res\drawable-xlarge - 1 - - - - - res\values - 1 - - - res\values - 1 - - - - - 1 - - - 1 - - - 0 - - - - - 1 - .framework - - - 1 - .framework - - - 0 - - - - - 1 - .dylib - - - 1 - .dylib - - - 0 - .dll;.bpl - - - - - 1 - .dylib - - - 1 - .dylib - - - 1 - .dylib - - - 1 - .dylib - - - 1 - .dylib - - - 0 - .bpl - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - Contents\Resources - 1 - - - Contents\Resources - 1 - - - - - library\lib\armeabi-v7a - 1 - - - library\lib\arm64-v8a - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 0 - - - - - library\lib\armeabi-v7a - 1 - - - - - 1 - - - 1 - - - - - Assets - 1 - - - Assets - 1 - - - - - Assets - 1 - - - Assets - 1 - - - - - - - - - - - - - - - False - False - False - False - False - True - False - - - 12 - - - - - diff --git a/Groovy/.gitignore b/Groovy/.gitignore deleted file mode 100644 index 8f0aaba4..00000000 --- a/Groovy/.gitignore +++ /dev/null @@ -1,124 +0,0 @@ - -# Created by https://www.gitignore.io/api/groovy,intellij,eclipse,vim - -#!! ERROR: groovy is undefined. Use list command to see defined gitignore types !!# - -### Intellij ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: -.idea/workspace.xml -.idea/tasks.xml -.idea/dictionaries -.idea/vcs.xml -.idea/jsLibraryMappings.xml - -# Sensitive or high-churn files: -.idea/dataSources.ids -.idea/dataSources.xml -.idea/dataSources.local.xml -.idea/sqlDataSources.xml -.idea/dynamic.xml -.idea/uiDesigner.xml - -# Gradle: -.idea/gradle.xml -.idea/libraries - -# Mongo Explorer plugin: -.idea/mongoSettings.xml - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -/out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -### Intellij Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml - - -### Eclipse ### - -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath -.recommenders - -# Eclipse Core -.project - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# PyDev specific (Python IDE for Eclipse) -*.pydevproject - -# CDT-specific (C/C++ Development Tooling) -.cproject - -# JDT-specific (Eclipse Java Development Tools) -.classpath - -# Java annotation processor (APT) -.factorypath - -# PDT-specific (PHP Development Tools) -.buildpath - -# sbteclipse plugin -.target - -# Tern plugin -.tern-project - -# TeXlipse plugin -.texlipse - -# STS (Spring Tool Suite) -.springBeans - -# Code Recommenders -.recommenders/ - - -### Vim ### -# swap -[._]*.s[a-w][a-z] -[._]s[a-w][a-z] -# session -Session.vim -# temporary -.netrwhist -*~ -# auto-generated tag files -tags - diff --git a/Groovy/.idea/compiler.xml b/Groovy/.idea/compiler.xml deleted file mode 100644 index 96cc43ef..00000000 --- a/Groovy/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Groovy/.idea/copyright/profiles_settings.xml b/Groovy/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf33..00000000 --- a/Groovy/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Groovy/.idea/misc.xml b/Groovy/.idea/misc.xml deleted file mode 100644 index c6d8fb73..00000000 --- a/Groovy/.idea/misc.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Groovy/.idea/modules.xml b/Groovy/.idea/modules.xml deleted file mode 100644 index c1a39855..00000000 --- a/Groovy/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Groovy/Groovy.iml b/Groovy/Groovy.iml deleted file mode 100644 index 85bea791..00000000 --- a/Groovy/Groovy.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Groovy/README.txt b/Groovy/README.txt deleted file mode 100644 index 664827d7..00000000 --- a/Groovy/README.txt +++ /dev/null @@ -1,17 +0,0 @@ -Welcome to the Groovy Gilded Rose -================================= - -to run the test, you can either: -- run them from your favorite IDE - - make sure you have installed language support for Groovy - - IntelliJ: - - open project - - choose this folder (Groovy) - - Eclipse: - - new Groovy Project - - choose this folder (Groovy) as the project folder - - add JUnit to build path -- run the test from the src/ folder in your shell: - - $ cd src/ - - $ groovy com/gildedrose/GildedRoseTest.groovy - diff --git a/Groovy/src/com/gildedrose/GildedRose.groovy b/Groovy/src/com/gildedrose/GildedRose.groovy deleted file mode 100644 index ba054cb6..00000000 --- a/Groovy/src/com/gildedrose/GildedRose.groovy +++ /dev/null @@ -1,62 +0,0 @@ -package com.gildedrose - -class GildedRose { - Item[] items - - GildedRose(Item[] items) { - this.items = items - } - - void updateQuality() { - for (int i = 0; i < items.length; i++) { - if (!items[i].name.equals("Aged Brie") - && !items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) { - if (items[i].quality > 0) { - if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) { - items[i].quality = items[i].quality - 1 - } - } - } else { - if (items[i].quality < 50) { - items[i].quality = items[i].quality + 1 - - if (items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) { - if (items[i].sellIn < 11) { - if (items[i].quality < 50) { - items[i].quality = items[i].quality + 1 - } - } - - if (items[i].sellIn < 6) { - if (items[i].quality < 50) { - items[i].quality = items[i].quality + 1 - } - } - } - } - } - - if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) { - items[i].sellIn = items[i].sellIn - 1 - } - - if (items[i].sellIn < 0) { - if (!items[i].name.equals("Aged Brie")) { - if (!items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) { - if (items[i].quality > 0) { - if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) { - items[i].quality = items[i].quality - 1 - } - } - } else { - items[i].quality = items[i].quality - items[i].quality - } - } else { - if (items[i].quality < 50) { - items[i].quality = items[i].quality + 1 - } - } - } - } - } -} diff --git a/Groovy/src/com/gildedrose/GildedRoseTest.groovy b/Groovy/src/com/gildedrose/GildedRoseTest.groovy deleted file mode 100644 index d96202c0..00000000 --- a/Groovy/src/com/gildedrose/GildedRoseTest.groovy +++ /dev/null @@ -1,15 +0,0 @@ -package com.gildedrose - -import org.junit.Test - -class GildedRoseTest { - - @Test - void "foo"() { - def items = [ new Item("foo", 0, 0) ] as Item[] - def app = new GildedRose(items) - app.updateQuality() - assert "fixme" == app.items[0].name - } - -} diff --git a/Groovy/src/com/gildedrose/Item.groovy b/Groovy/src/com/gildedrose/Item.groovy deleted file mode 100644 index c42d6cea..00000000 --- a/Groovy/src/com/gildedrose/Item.groovy +++ /dev/null @@ -1,21 +0,0 @@ -package com.gildedrose - -class Item { - - String name - - int sellIn - - int quality - - Item(String name, int sellIn, int quality) { - this.name = name - this.sellIn = sellIn - this.quality = quality - } - - @Override - String toString() { - return this.name + ", " + this.sellIn + ", " + this.quality - } -} diff --git a/Groovy/src/com/gildedrose/TexttestFixture.groovy b/Groovy/src/com/gildedrose/TexttestFixture.groovy deleted file mode 100644 index 3c8b46e3..00000000 --- a/Groovy/src/com/gildedrose/TexttestFixture.groovy +++ /dev/null @@ -1,32 +0,0 @@ -package com.gildedrose - -println("OMGHAI!") - -Item[] items = [ - new Item("+5 Dexterity Vest", 10, 20), - new Item("Aged Brie", 2, 0), - new Item("Elixir of the Mongoose", 5, 7), - new Item("Sulfuras, Hand of Ragnaros", 0, 80), - new Item("Sulfuras, Hand of Ragnaros", -1, 80), - new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), - new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), - new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), - // this conjured item does not work properly yet - new Item("Conjured Mana Cake", 3, 6)] as Item[] - -GildedRose app = new GildedRose(items) - -int days = 2 -if (args.length > 0) { - days = Integer.parseInt(args[0]) + 1 -} - -for (int i = 0; i < days; i++) { - println("-------- day " + i + " --------") - println("name, sellIn, quality") - for (Item item in items) { - println(item) - } - println "" - app.updateQuality() -} diff --git a/Java-Spock/.gitignore b/Java-Spock/.gitignore deleted file mode 100644 index cd3d2f4b..00000000 --- a/Java-Spock/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.idea/ -.gradle/ -build/ \ No newline at end of file diff --git a/Java-Spock/build.gradle b/Java-Spock/build.gradle deleted file mode 100644 index f3e0c1c1..00000000 --- a/Java-Spock/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -apply plugin: 'groovy' - -repositories { - mavenCentral() -} - -dependencies { - testCompile 'org.spockframework:spock-core:1.0-groovy-2.4' -} diff --git a/Java-Spock/gradle/wrapper/gradle-wrapper.jar b/Java-Spock/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 94114481..00000000 Binary files a/Java-Spock/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Java-Spock/gradle/wrapper/gradle-wrapper.properties b/Java-Spock/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 29dd2bcf..00000000 --- a/Java-Spock/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Tue Jul 05 09:24:35 CEST 2016 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip diff --git a/Java-Spock/gradlew b/Java-Spock/gradlew deleted file mode 100644 index 9d82f789..00000000 --- a/Java-Spock/gradlew +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/Java-Spock/gradlew.bat b/Java-Spock/gradlew.bat deleted file mode 100644 index 8a0b282a..00000000 --- a/Java-Spock/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Java-Spock/src/main/java/com/gildedrose/GildedRose.java b/Java-Spock/src/main/java/com/gildedrose/GildedRose.java deleted file mode 100644 index 87a3b926..00000000 --- a/Java-Spock/src/main/java/com/gildedrose/GildedRose.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.gildedrose; - -class GildedRose { - Item[] items; - - public GildedRose(Item[] items) { - this.items = items; - } - - public void updateQuality() { - for (int i = 0; i < items.length; i++) { - if (!items[i].name.equals("Aged Brie") - && !items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) { - if (items[i].quality > 0) { - if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) { - items[i].quality = items[i].quality - 1; - } - } - } else { - if (items[i].quality < 50) { - items[i].quality = items[i].quality + 1; - - if (items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) { - if (items[i].sellIn < 11) { - if (items[i].quality < 50) { - items[i].quality = items[i].quality + 1; - } - } - - if (items[i].sellIn < 6) { - if (items[i].quality < 50) { - items[i].quality = items[i].quality + 1; - } - } - } - } - } - - if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) { - items[i].sellIn = items[i].sellIn - 1; - } - - if (items[i].sellIn < 0) { - if (!items[i].name.equals("Aged Brie")) { - if (!items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) { - if (items[i].quality > 0) { - if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) { - items[i].quality = items[i].quality - 1; - } - } - } else { - items[i].quality = items[i].quality - items[i].quality; - } - } else { - if (items[i].quality < 50) { - items[i].quality = items[i].quality + 1; - } - } - } - } - } -} diff --git a/Java-Spock/src/main/java/com/gildedrose/Item.java b/Java-Spock/src/main/java/com/gildedrose/Item.java deleted file mode 100644 index 465729ec..00000000 --- a/Java-Spock/src/main/java/com/gildedrose/Item.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.gildedrose; - -public class Item { - - public String name; - - public int sellIn; - - public int quality; - - public Item(String name, int sellIn, int quality) { - this.name = name; - this.sellIn = sellIn; - this.quality = quality; - } - - @Override - public String toString() { - return this.name + ", " + this.sellIn + ", " + this.quality; - } -} diff --git a/Java-Spock/src/main/java/com/gildedrose/TexttestFixture.java b/Java-Spock/src/main/java/com/gildedrose/TexttestFixture.java deleted file mode 100644 index d059c88f..00000000 --- a/Java-Spock/src/main/java/com/gildedrose/TexttestFixture.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.gildedrose; - -public class TexttestFixture { - public static void main(String[] args) { - System.out.println("OMGHAI!"); - - Item[] items = new Item[] { - new Item("+5 Dexterity Vest", 10, 20), // - new Item("Aged Brie", 2, 0), // - new Item("Elixir of the Mongoose", 5, 7), // - new Item("Sulfuras, Hand of Ragnaros", 0, 80), // - new Item("Sulfuras, Hand of Ragnaros", -1, 80), - new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), - new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), - new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), - // this conjured item does not work properly yet - new Item("Conjured Mana Cake", 3, 6) }; - - GildedRose app = new GildedRose(items); - - int days = 2; - if (args.length > 0) { - days = Integer.parseInt(args[0]) + 1; - } - - for (int i = 0; i < days; i++) { - System.out.println("-------- day " + i + " --------"); - System.out.println("name, sellIn, quality"); - for (Item item : items) { - System.out.println(item); - } - System.out.println(); - app.updateQuality(); - } - } - -} diff --git a/Java-Spock/src/test/groovy/com/gildedrose/GildedRoseSpec.groovy b/Java-Spock/src/test/groovy/com/gildedrose/GildedRoseSpec.groovy deleted file mode 100644 index 04276c03..00000000 --- a/Java-Spock/src/test/groovy/com/gildedrose/GildedRoseSpec.groovy +++ /dev/null @@ -1,25 +0,0 @@ -package com.gildedrose - -import spock.lang.Specification - -/** - * Spock unit tests. - */ -class GildedRoseSpec extends Specification { - - def "should update quality correctly"() { - - given: "some items" - Item[] items = [new Item("foo", 0, 0)]; - - and: "the application with these items" - GildedRose app = new GildedRose(items); - - when: "updating quality" - app.updateQuality(); - - then: "the quality is correct" - app.items[0].name == "fixme" - } - -} diff --git a/R/.project b/R/.project deleted file mode 100644 index 62d08220..00000000 --- a/R/.project +++ /dev/null @@ -1,18 +0,0 @@ - - - GildedRose.R - - - - - - de.walware.statet.r.builders.RSupport - - - - - - de.walware.statet.base.StatetNature - de.walware.statet.r.RNature - - diff --git a/R/gilded_rose.R b/R/gilded_rose.R deleted file mode 100644 index 3d639dda..00000000 --- a/R/gilded_rose.R +++ /dev/null @@ -1,56 +0,0 @@ -source('item.R') - -update_quality <- function(items) { - lapply(items, - function(item) { - - if (item$name != "Aged Brie" && item$name != "Backstage passes to a TAFKAL80ETC concert") { - if (item$quality > 0) { - if (item$name != "Sulfuras, Hand of Ragnaros") { - item$quality <- item$quality - 1 - } - } - } else { - if (item$quality < 50) { - item$quality <- item$quality + 1 - if (item$name == "Backstage passes to a TAFKAL80ETC concert") { - if (item$sell_in < 11) { - if (item$quality < 50) { - item$quality = item$quality + 1 - } - } - if (item$sell_in < 6) { - if (item$quality < 50) { - item$quality = item$quality + 1 - } - } - } - } - } - - if (item$name != "Sulfuras, Hand of Ragnaros") { - item$sell_in <- item$sell_in - 1 - } - - if (item$sell_in < 0) { - if (item$name != "Aged Brie") { - if (item$name != "Backstage passes to a TAFKAL80ETC concert") { - if (item$quality > 0) { - if (item$name != "Sulfuras, Hand of Ragnaros") { - item$quality <- item$quality - 1 - } - } - } else { - item$quality <- item$quality - item$quality - } - } else { - if (item$quality < 50) { - item$quality <- item$quality + 1 - } - } - } - - item - } - ) -} diff --git a/R/item.R b/R/item.R deleted file mode 100644 index 51cc90dc..00000000 --- a/R/item.R +++ /dev/null @@ -1,13 +0,0 @@ -item <- function(name, sell_in, quality) { - newItem <- list(name=name, sell_in=sell_in, quality=quality) - class(newItem) <- 'item' - newItem -} - -as.character.item <- function(item) { - paste(item$name, ", ", item$sell_in, ", ", item$quality, sep='') -} - -print.item <- function(item) { - print.default(as.character(item)) -} diff --git a/R/runit_gilded_rose.R b/R/runit_gilded_rose.R deleted file mode 100644 index a0004b7c..00000000 --- a/R/runit_gilded_rose.R +++ /dev/null @@ -1,7 +0,0 @@ -source('gilded_rose.R') - -test.foo <- function() { - items <- list( item('foo', 0, 0) ) - items <- update_quality(items) - checkEquals('fixme', items[[1]]$name); -} diff --git a/R/test_setup.R b/R/test_setup.R deleted file mode 100644 index fc62610e..00000000 --- a/R/test_setup.R +++ /dev/null @@ -1,7 +0,0 @@ -# A little helper script to get the testing infrastructure started - -# install.packages("RUnit") -require(RUnit) - -# execute single test file -runTestFile("runit_gilded_rose.R") diff --git a/R/texttest_fixture.R b/R/texttest_fixture.R deleted file mode 100644 index ec635e6e..00000000 --- a/R/texttest_fixture.R +++ /dev/null @@ -1,33 +0,0 @@ -rm(list=ls()) - -source('gilded_rose.R') - -writeLines('OMGHAI!') - -items <- list( - item('+5 Dexterity Vest', 10, 20), - item('Aged Brie', 2, 0), - item('Elixir of the Mongoose', 5, 7), - item('Sulfuras, Hand of Ragnaros', 0, 80), - item('Sulfuras, Hand of Ragnaros', -1, 80), - item('Backstage passes to a TAFKAL80ETC concert', 15, 20), - item('Backstage passes to a TAFKAL80ETC concert', 10, 49), - item('Backstage passes to a TAFKAL80ETC concert', 5, 49), - # This Conjured item does not work properly yet - item('Conjured Mana Cake', 3, 6) -) - -days <- 2 -for (day in 0:days) { - writeLines(paste('-------- day ', day, ' --------', sep='')) - writeLines('name, sellIn, quality') - lapply(items, - function(item) { - writeLines(as.character(item)) - } - ) - writeLines('') - items <- update_quality(items) -} - -rm('day', 'days', 'items') diff --git a/Smalltalk/GildedRose.st b/Smalltalk/GildedRose.st deleted file mode 100644 index 863e99e2..00000000 --- a/Smalltalk/GildedRose.st +++ /dev/null @@ -1,160 +0,0 @@ -Object subclass: #GildedRose - instanceVariableNames: '' - classVariableNames: '' - poolDictionaries: '' - category: 'GildedRose'! -!GildedRose commentStamp: 'AndreasLeidig 4/21/2012 15:38' prior: 0! -This Kata was originally created by Terry Hughes (http://twitter.com/#!!/TerryHughes). It is already on GitHub as "GildedRose", a sample project for C#. I could have forked it again, but I thought other language users might not want to download a whole C# project environment. In this repository are starting code samples for Java, Python, Ruby, C# and C++. - -See also http://iamnotmyself.com/2011/02/13/refactor-this-the-gilded-rose-kata/ - -==================== -How to use this Kata -==================== - -The simplest way is to just clone the code and start hacking away improving the design. You'll want to look at the "Gilded Rose Background Reading" (below) which explains what the code is for. I strongly advise you that you'll also need some tests if you want to make sure you don't break the code while you refactor. - -You could write some unit tests yourself, using the Kata Background Reading (below) to identify suitable test cases. I've provided a failing unit test in a popular test framework as a starting point for most languages. - -Alternatively, use the "Text-Based" tests provided in this repository. (Read more about that in the next section) - -Whichever testing approach you choose, the idea of the exercise is to do some deliberate practice, and improve your Refactoring skills. The idea is not to re-write the code from scratch, but rather to practice taking small steps, running the tests often, and incrementally improving the design. - -================== -Text-Based Testing -================== - -This is a testing approach which is very useful when refactoring legacy code. The basic idea is to create tests that use the text which the code produces. Before you change the code, you run it, and save the output as a "Golden Copy". Then after you change the code, you run it again, and compare the output against the Golden Copy. Any differences, and the test fails. - -It's basically the same idea as "assertEquals(expected, actual)" in a unit test, except the text you are comparing is typically much longer, and the "expected" value is saved from actual output, rather than being defined in advance. - -Typically a piece of legacy code may not produce suitable textual output from the start, so you may need to modify it before you can write your first text-based test. That could involve inserting log statements into the code, or just writing a "main" method that executes the code and prints out what the result is afterwards. It's this latter approach we are using here to test GildedRose. - -The Text-Based tests in this repository are designed to be used with the tool "TextTest" (http://texttest.org). This tool helps you to organize and run text-based tests. There is more information in the README file in the "texttests" subdirectory. - -=================================== -Gilded Rose Kata Background Reading -=================================== - -Hi and welcome to team Gilded Rose. As you know, we are a small inn with a prime location in a prominent city ran by a friendly innkeeper named Allison. We also buy and sell only the finest goods. Unfortunately, our goods are constantly degrading in quality as they approach their sell by date. We have a system in place that updates our inventory for us. It was developed by a no-nonsense type named Leeroy, who has moved on to new adventures. Your task is to add the new feature to our system so that we can begin selling a new category of items. First an introduction to our system: - - - All items have a SellIn value which denotes the number of days we have to sell the item - - All items have a Quality value which denotes how valuable the item is - - At the end of each day our system lowers both values for every item - -Pretty simple, right? Well this is where it gets interesting: - - - Once the sell by date has passed, Quality degrades twice as fast - - The Quality of an item is never negative - - "Aged Brie" actually increases in Quality the older it gets - - The Quality of an item is never more than 50 - - "Sulfuras", being a legendary item, never has to be sold or decreases in Quality - - "Backstage passes", like aged brie, increases in Quality as it's SellIn value approaches; Quality increases by 2 when there are 10 days or less and by 3 when there are 5 days or less but Quality drops to 0 after the concert - -We have recently signed a supplier of conjured items. This requires an update to our system: - - - "Conjured" items degrade in Quality twice as fast as normal items - -Feel free to make any changes to the UpdateQuality method and add any new code as long as everything still works correctly. However, do not alter the Item class or Items property as those belong to the goblin in the corner who will insta-rage and one-shot you as he doesn't believe in shared code ownership (you can make the UpdateQuality method and Items property static if you like, we'll cover for you). - -Just for clarification, an item can never have its Quality increase above 50, however "Sulfuras" is a legendary item and as such its Quality is 80 and it never alters.! - - -!GildedRose methodsFor: 'API' stamp: 'AndreasLeidig 4/21/2012 17:02'! -updateQualityFor: items - items - do: [:item | - (item name ~= 'Aged Brie' - and: [item name ~= 'Backstage passes to a TAFKAL80ETC concert']) - ifTrue: [item quality > 0 - ifTrue: [item name ~= 'Sulfuras, Hand of Ragnaros' - ifTrue: [item quality: item quality - 1]]] - ifFalse: [item quality < 50 - ifTrue: [item quality: item quality + 1. - item name = 'Backstage passes to a TAFKAL80ETC concert' - ifTrue: [item sellIn < 11 - ifTrue: [item quality < 50 - ifTrue: [item quality: item quality + 1]]. - item sellIn < 6 - ifTrue: [item quality < 50 - ifTrue: [item quality: item quality + 1]]]]]. - item name ~= 'Sulfuras, Hand of Ragnaros' - ifTrue: [item sellIn: item sellIn - 1]. - item sellIn < 0 - ifTrue: [item name ~= 'Aged Brie' - ifTrue: [item name ~= 'Backstage passes to a TAFKAL80ETC concert' - ifTrue: [item quality > 0 - ifTrue: [item name ~= 'Sulfuras, Hand of Ragnaros' - ifTrue: [item quality: item quality - 1]]] - ifFalse: [item quality: item quality - item quality]] - ifFalse: [item quality < 50 - ifTrue: [item quality: item quality + 1]]]]! ! - -"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! - -GildedRose class - instanceVariableNames: ''! - -!GildedRose class methodsFor: 'run Example' stamp: 'AndreasLeidig 4/21/2012 20:26'! -runExamples - "GildedRose runExamples" - | items gildedRose | - items := OrderedCollection new - add: (Item new name: '+5 Dexterity Vest'; sellIn: 10; quality: 20; yourself); - add: (Item new name: 'Aged Brie'; sellIn: 2; quality: 0; yourself); - add: (Item new name: 'Elixir of the Mongoose'; sellIn: 5; quality: 7; yourself); - add: (Item new name: 'Sulfuras, Hand of Ragnaros'; sellIn: 0; quality: 80; yourself); - add: (Item new name: 'Sulfuras, Hand of Ragnaros'; sellIn: -1; quality: 80; yourself); - add: (Item new name: 'Backstage passes to a TAFKAL80ETC concert'; sellIn: 15; quality: 20; yourself); - add: (Item new name: 'Backstage passes to a TAFKAL80ETC concert'; sellIn: 10; quality: 49; yourself); - add: (Item new name: 'Backstage passes to a TAFKAL80ETC concert'; sellIn: 5; quality: 49; yourself); - add: (Item new name: 'Conjured Mana Cake'; sellIn: 3; quality: 6; yourself); "this conjured item does not work properly yet" - yourself. - - gildedRose := GildedRose new. - Transcript show: 'OMGHAI!!'; - cr. - 0 to: 30 do: [:idx | - Transcript show: '-------- day ' , idx printString , ' --------'; - cr; - show: 'name, sellIn, quality'; - cr. - items - do: [:item | - Transcript show: item name , ', ' , item sellIn printString , ', ' , item quality printString; - cr]. - Transcript cr. - gildedRose updateQualityFor: items]. - Transcript cr! ! - - -Object subclass: #Item - instanceVariableNames: 'name sellIn quality' - classVariableNames: '' - poolDictionaries: '' - category: 'GildedRose'! - -!Item methodsFor: 'accessing' stamp: 'AndreasLeidig 4/21/2012 15:40'! -name - ^name! ! - -!Item methodsFor: 'accessing' stamp: 'AndreasLeidig 4/21/2012 15:41'! -name: aString - name := aString! ! - -!Item methodsFor: 'accessing' stamp: 'AndreasLeidig 4/21/2012 15:41'! -quality - ^quality! ! - -!Item methodsFor: 'accessing' stamp: 'AndreasLeidig 4/21/2012 15:42'! -quality: aNumber - quality := aNumber! ! - -!Item methodsFor: 'accessing' stamp: 'AndreasLeidig 4/21/2012 15:41'! -sellIn - ^sellIn! ! - -!Item methodsFor: 'accessing' stamp: 'AndreasLeidig 4/21/2012 15:42'! -sellIn: aNumber - sellIn := aNumber - ! ! diff --git a/TypeScript/.gitignore b/TypeScript/.gitignore deleted file mode 100644 index 7d7d75b0..00000000 --- a/TypeScript/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.DS_Store -.idea -node_modules -typings -app/**/*.js -app/**/*.js.map -test/**/*.js -test/**/*.js.map -coverage -.nyc_output diff --git a/TypeScript/.mocharc.js b/TypeScript/.mocharc.js deleted file mode 100644 index 662e3c27..00000000 --- a/TypeScript/.mocharc.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; - -module.exports = { - require: [ - "ts-node/register", - "source-map-support/register" - ], - recursive: true, - spec: "test/*.spec.ts" -} \ No newline at end of file diff --git a/TypeScript/app/gilded-rose.ts b/TypeScript/app/gilded-rose.ts deleted file mode 100644 index 928aa579..00000000 --- a/TypeScript/app/gilded-rose.ts +++ /dev/null @@ -1,69 +0,0 @@ -export class Item { - name: string; - sellIn: number; - quality: number; - - constructor(name, sellIn, quality) { - this.name = name; - this.sellIn = sellIn; - this.quality = quality; - } -} - -export class GildedRose { - items: Array; - - constructor(items = [] as Array) { - this.items = items; - } - - updateQuality() { - for (let i = 0; i < this.items.length; i++) { - if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') { - if (this.items[i].quality > 0) { - if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { - this.items[i].quality = this.items[i].quality - 1 - } - } - } else { - if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 - if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') { - if (this.items[i].sellIn < 11) { - if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 - } - } - if (this.items[i].sellIn < 6) { - if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 - } - } - } - } - } - if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { - this.items[i].sellIn = this.items[i].sellIn - 1; - } - if (this.items[i].sellIn < 0) { - if (this.items[i].name != 'Aged Brie') { - if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') { - if (this.items[i].quality > 0) { - if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { - this.items[i].quality = this.items[i].quality - 1 - } - } - } else { - this.items[i].quality = this.items[i].quality - this.items[i].quality - } - } else { - if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 - } - } - } - } - - return this.items; - } -} diff --git a/TypeScript/package.json b/TypeScript/package.json deleted file mode 100644 index 6bca69d9..00000000 --- a/TypeScript/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "gilded-rose-kata", - "version": "1.0.0", - "description": "Gilded Rose kata in TypeScript", - "scripts": { - "precompile": "rimraf app/**/*.js test/**/*.js", - "compile": "tsc", - "pretest": "rimraf app/**/*.js test/**/*.js", - "test": "nyc mocha" - }, - "license": "MIT", - "private": true, - "devDependencies": { - "@types/chai": "~3.5.2", - "@types/mocha": "~2.2.41", - "@types/node": "~7.0.18", - "chai": "~4.2.0", - "mocha": "~8.2.1", - "nyc": "~15.1.0", - "rimraf": "~3.0.2", - "source-map-support": "0.5.19", - "ts-node": "~9.1.1", - "typescript": "~4.1.3" - }, - "nyc": { - "extension": [ - ".ts" - ], - "exclude": [ - "**/*.d.ts", - "test/**" - ], - "require": [ - "ts-node/register" - ], - "reporter": [ - "html", - "text" - ] - } -} diff --git a/TypeScript/test/gilded-rose.spec.ts b/TypeScript/test/gilded-rose.spec.ts deleted file mode 100644 index 0c192caf..00000000 --- a/TypeScript/test/gilded-rose.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { expect } from 'chai'; -import { Item, GildedRose } from '../app/gilded-rose'; - -describe('Gilded Rose', function () { - - it('should foo', function() { - const gildedRose = new GildedRose([ new Item('foo', 0, 0) ]); - const items = gildedRose.updateQuality(); - expect(items[0].name).to.equal('fixme'); - }); - -}); diff --git a/TypeScript/test/golden-master-text-test.ts b/TypeScript/test/golden-master-text-test.ts deleted file mode 100644 index 96b60e41..00000000 --- a/TypeScript/test/golden-master-text-test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Item, GildedRose } from '../app/gilded-rose'; - -const items = [ - new Item("+5 Dexterity Vest", 10, 20), // - new Item("Aged Brie", 2, 0), // - new Item("Elixir of the Mongoose", 5, 7), // - new Item("Sulfuras, Hand of Ragnaros", 0, 80), // - new Item("Sulfuras, Hand of Ragnaros", -1, 80), - new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), - new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), - new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), - // this conjured item does not work properly yet - new Item("Conjured Mana Cake", 3, 6)]; - - -const gildedRose = new GildedRose(items); -var days: number = 2; -for (let i = 0; i < days; i++) { - console.log("-------- day " + i + " --------"); - console.log("name, sellIn, quality"); - items.forEach(element => { - console.log(element.name + ' ' + element.sellIn + ' ' + element.quality); - - }); - console.log(); - gildedRose.updateQuality(); -} \ No newline at end of file diff --git a/TypeScript/tsconfig.json b/TypeScript/tsconfig.json deleted file mode 100644 index 84381f86..00000000 --- a/TypeScript/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "strict": true, - "noImplicitAny": false, - "sourceMap": false - }, - "exclude": [ - "node_modules" - ] -} diff --git a/abap/README.md b/abap/README.md deleted file mode 100644 index ebd18544..00000000 --- a/abap/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Gilded Rose Refactoring Kata in [ABAP](http://scn.sap.com/community/abap/) - -## Prerequisite - -Access to SAP NetWeaver server with at least ABAP 7.40 - -## Installation - -Assuming you have a proper developer key set up, run SE38 -* create a new Module Pool (type M) program as a Local Object -* paste the raw code from [YY_PAO_GILDED_ROSE.abap](https://raw.githubusercontent.com/brehberg/GildedRose-Refactoring-Kata/master/abap/YY_PAO_GILDED_ROSE.abap) -* save (Ctrl-S) and activate (Ctrl-F3) the program - -## Running Tests - -From the menus choose Program -> Execute -> Unit Tests (Ctrl+Shift+F10) diff --git a/abap/YY_PAO_GILDED_ROSE.abap b/abap/YY_PAO_GILDED_ROSE.abap deleted file mode 100644 index 40e8f985..00000000 --- a/abap/YY_PAO_GILDED_ROSE.abap +++ /dev/null @@ -1,242 +0,0 @@ -*&---------------------------------------------------------------------* -*& Gilded Rose Requirements Specification -*&---------------------------------------------------------------------* -*& -*& Hi and welcome to team Gilded Rose. As you know, we are a small inn with -*& a prime location in a prominent city ran by a friendly innkeeper named -*& Allison. We also buy and sell only the finest goods. Unfortunately, our -*& goods are constantly degrading in quality as they approach their sell by -*& date. We have a system in place that updates our inventory for us. It -*& was developed by a no-nonsense type named Leeroy, who has moved on to -*& new adventures. Your task is to add the new feature to our system so that -*& we can begin selling a new category of items. -*& -*& First an introduction to our system: -*& -*& - All items have a Sell In value which denotes the number of -*& days we have to sell the item -*& - All items have a Quality value which denotes how valuable the item is -*& - At the end of each day our system lowers both values for every item -*& -*& Seems pretty simple, right? Well this is where it gets interesting: -*& -*& - Once the sell by date has passed, Quality degrades twice as fast -*& - The Quality of an item is never negative -*& - "Aged Brie" actually increases in Quality the older it gets -*& - The Quality of an item is never more than 50 -*& - "Sulfuras", being a legendary item, never has to be sold or -*& decreases in Quality -*& - "Backstage passes", like aged brie, increases in Quality as its -*& Sell In value approaches; Quality increases by 2 when there -*& are 10 days or less and by 3 when there are 5 days or less -*& but Quality drops to 0 after the concert -*& -*& We have recently signed a supplier of conjured items. This requires an -*& update to our system: -*& -*& - "Conjured" items degrade in Quality twice as fast as normal items -*& -*& Feel free to make any changes to the Update Quality method and add any new -*& code as long as everything still works correctly. However, do not alter -*& the Item class directly or Items table attribute as those belong to the -*& goblin in the corner who will insta-rage and one-shot you as he doesn't -*& believe in shared code ownership (you can make the Update Quality method -*& and Items property static if you must, we'll cover for you). -*& -*& Just for clarification, an item can never have its Quality increase -*& above 50, however "Sulfuras" is a legendary item and as such its Quality -*& is 80 and it never alters. - -PROGRAM yy_pao_gilded_rose. - - -*& Production Code - Class Library -CLASS lcl_item DEFINITION DEFERRED. - -CLASS lcl_gilded_rose DEFINITION FINAL. - PUBLIC SECTION. - TYPES: - tt_items TYPE STANDARD TABLE OF REF TO lcl_item WITH EMPTY KEY. - METHODS: - constructor - IMPORTING it_items TYPE tt_items, - update_quality. - - PRIVATE SECTION. - DATA: - mt_items TYPE tt_items. -ENDCLASS. - -CLASS lcl_item DEFINITION FINAL. - PUBLIC SECTION. - METHODS: - constructor - IMPORTING iv_name TYPE string - iv_sell_in TYPE i - iv_quality TYPE i, - description - RETURNING VALUE(rv_string) TYPE string. - DATA: - mv_name TYPE string, - mv_sell_in TYPE i, - mv_quality TYPE i. -ENDCLASS. - -CLASS lcl_gilded_rose IMPLEMENTATION. - - METHOD constructor. - mt_items = it_items. - ENDMETHOD. - - METHOD update_quality. - - LOOP AT mt_items INTO DATA(lo_item). - IF lo_item->mv_name <> |Aged Brie| AND - lo_item->mv_name <> |Backstage passes to a TAFKAL80ETC concert|. - IF lo_item->mv_quality > 0. - IF lo_item->mv_name <> |Sulfuras, Hand of Ragnaros|. - lo_item->mv_quality = lo_item->mv_quality - 1. - ENDIF. - ENDIF. - ELSE. - IF lo_item->mv_quality < 50. - lo_item->mv_quality = lo_item->mv_quality + 1. - - IF lo_item->mv_name = |Backstage passes to a TAFKAL80ETC concert|. - IF lo_item->mv_sell_in < 11. - IF lo_item->mv_quality < 50. - lo_item->mv_quality = lo_item->mv_quality + 1. - ENDIF. - ENDIF. - - IF lo_item->mv_sell_in < 6. - IF lo_item->mv_quality < 50. - lo_item->mv_quality = lo_item->mv_quality + 1. - ENDIF. - ENDIF. - ENDIF. - ENDIF. - ENDIF. - - IF lo_item->mv_name <> |Sulfuras, Hand of Ragnaros|. - lo_item->mv_sell_in = lo_item->mv_sell_in - 1. - ENDIF. - - IF lo_item->mv_sell_in < 0. - IF lo_item->mv_name <> |Aged Brie|. - IF lo_item->mv_name <> |Backstage passes to a TAFKAL80ETC concert|. - IF lo_item->mv_quality > 0. - IF lo_item->mv_name <> |Sulfuras, Hand of Ragnaros|. - lo_item->mv_quality = lo_item->mv_quality - 1. - ENDIF. - ENDIF. - ELSE. - lo_item->mv_quality = lo_item->mv_quality - lo_item->mv_quality. - ENDIF. - ELSE. - IF lo_item->mv_quality < 50. - lo_item->mv_quality = lo_item->mv_quality + 1. - ENDIF. - ENDIF. - ENDIF. - ENDLOOP. - - ENDMETHOD. - -ENDCLASS. - -CLASS lcl_item IMPLEMENTATION. - - METHOD constructor. - mv_name = iv_name. - mv_sell_in = iv_sell_in. - mv_quality = iv_quality. - ENDMETHOD. - - METHOD description. - rv_string = |{ mv_name }, { mv_sell_in }, { mv_quality }|. - ENDMETHOD. - -ENDCLASS. - - -*& Test Code - Executable Text Test Fixture -CLASS lth_texttest_fixture DEFINITION FINAL. - PUBLIC SECTION. - CLASS-METHODS main. -ENDCLASS. - -CLASS lth_texttest_fixture IMPLEMENTATION. - METHOD main. - DATA(lo_out) = cl_demo_output=>new( )->write_text( |OMGHAI!| ). - - DATA(lt_items) = VALUE lcl_gilded_rose=>tt_items( - ( NEW #( iv_name = |+5 Dexterity Vest| - iv_sell_in = 10 - iv_quality = 20 ) ) - ( NEW #( iv_name = |Aged Brie| - iv_sell_in = 2 - iv_quality = 0 ) ) - ( NEW #( iv_name = |Elixir of the Mongoose| - iv_sell_in = 5 - iv_quality = 7 ) ) - ( NEW #( iv_name = |Sulfuras, Hand of Ragnaros| - iv_sell_in = 0 - iv_quality = 80 ) ) - ( NEW #( iv_name = |Backstage passes to a TAFKAL80ETC concert| - iv_sell_in = 15 - iv_quality = 20 ) ) - ( NEW #( iv_name = |Backstage passes to a TAFKAL80ETC concert| - iv_sell_in = 10 - iv_quality = 49 ) ) - ( NEW #( iv_name = |Backstage passes to a TAFKAL80ETC concert| - iv_sell_in = 5 - iv_quality = 49 ) ) - "This conjured item does not work properly yet - ( NEW #( iv_name = |Conjured Mana Cake| - iv_sell_in = 3 - iv_quality = 6 ) ) ). - - DATA(lo_app) = NEW lcl_gilded_rose( it_items = lt_items ). - - DATA(lv_days) = 2. - cl_demo_input=>request( EXPORTING text = |Number of Days?| - CHANGING field = lv_days ). - - DO lv_days TIMES. - lo_out->next_section( |-------- day { sy-index } --------| ). - lo_out->write_text( |Name, Sell_In, Quality| ). - LOOP AT lt_items INTO DATA(lo_item). - lo_out->write_text( lo_item->description( ) ). - ENDLOOP. - lo_app->update_quality( ). - ENDDO. - - lo_out->display( ). - ENDMETHOD. -ENDCLASS. - - -*& Test Code - Currently Broken -CLASS ltc_gilded_rose DEFINITION FINAL FOR TESTING RISK LEVEL HARMLESS. - PRIVATE SECTION. - METHODS: - foo FOR TESTING. -ENDCLASS. - -CLASS ltc_gilded_rose IMPLEMENTATION. - - METHOD foo. - DATA(lt_items) = VALUE lcl_gilded_rose=>tt_items( ( NEW #( iv_name = |foo| - iv_sell_in = 0 - iv_quality = 0 ) ) ). - - DATA(lo_app) = NEW lcl_gilded_rose( it_items = lt_items ). - lo_app->update_quality( ). - - cl_abap_unit_assert=>assert_equals( - act = CAST lcl_item( lt_items[ 1 ] )->mv_name - exp = |fixme| ). - ENDMETHOD. - -ENDCLASS. diff --git a/c99/CMakeLists.txt b/c99/CMakeLists.txt deleted file mode 100644 index cafa2ef7..00000000 --- a/c99/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 2.8.4) -project(GildedRose_c99) - -enable_testing() - -include(ExternalProject) -ExternalProject_Add(unity - GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git - GIT_TAG master - SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/unity-src" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/unity-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) -add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/unity-src/src/unity.c - DEPENDS unity - COMMAND "") - - -add_executable( GildedRose_Unity - GildedRose.c - ${CMAKE_CURRENT_BINARY_DIR}/unity-src/src/unity.c - test_unity_gildedrose.c -) -target_include_directories(GildedRose_Unity PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/unity-src/src/) -set_property(TARGET GildedRose_Unity PROPERTY C_STANDARD 99) -add_dependencies(GildedRose_Unity unity) - -add_test(NAME GildedRose_Unity COMMAND GildedRose_Unity) diff --git a/c99/GildedRose.c b/c99/GildedRose.c deleted file mode 100644 index afb97bbe..00000000 --- a/c99/GildedRose.c +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include "GildedRose.h" - -Item* -init_item(Item* item, const char *name, int sellIn, int quality) -{ - item->sellIn = sellIn; - item->quality = quality; - item->name = strdup(name); - - return item; -} - -void update_quality(Item items[], int size) -{ - int i; - - for (i = 0; i < size; i++) - { - if (strcmp(items[i].name, "Aged Brie") && strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) - { - if (items[i].quality > 0) - { - if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) - { - items[i].quality = items[i].quality - 1; - } - } - } - else - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - - if (!strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) - { - if (items[i].sellIn < 11) - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - - if (items[i].sellIn < 6) - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - } - } - } - - if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) - { - items[i].sellIn = items[i].sellIn - 1; - } - - if (items[i].sellIn < 0) - { - if (strcmp(items[i].name, "Aged Brie")) - { - if (strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) - { - if (items[i].quality > 0) - { - if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) - { - items[i].quality = items[i].quality - 1; - } - } - } - else - { - items[i].quality = items[i].quality - items[i].quality; - } - } - else - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - } - } -} diff --git a/c99/GildedRose.h b/c99/GildedRose.h deleted file mode 100644 index 78d54a08..00000000 --- a/c99/GildedRose.h +++ /dev/null @@ -1,9 +0,0 @@ -typedef struct -{ - char *name; - int sellIn; - int quality; -} Item; - -extern Item* init_item(Item* item, const char *name, int sellIn, int quality); -extern void update_quality(Item items[], int size); diff --git a/c99/GildedRoseTextTests.c b/c99/GildedRoseTextTests.c deleted file mode 100644 index d200ca0c..00000000 --- a/c99/GildedRoseTextTests.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include "GildedRose.h" - -int -print_item(Item *item) -{ - return printf("%s, %d, %d\n", item->name, item->sellIn, item->quality); -} - -int main() -{ - Item items[9]; - int last = 0; - int day; - int index; - - init_item(items + last++, "+5 Dexterity Vest", 10, 20); - init_item(items + last++, "Aged Brie", 2, 0); - init_item(items + last++, "Elixir of the Mongoose", 5, 7); - init_item(items + last++, "Sulfuras, Hand of Ragnaros", 0, 80); - init_item(items + last++, "Sulfuras, Hand of Ragnaros", -1, 80); - init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 15, 20); - init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 10, 49); - init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 5, 49); - // this Conjured item doesn't yet work properly - init_item(items + last++, "Conjured Mana Cake", 3, 6); - - puts("OMGHAI!"); - - for (day = 0; day <= 30; day++) - { - printf("-------- day %d --------\n", day); - printf("name, sellIn, quality\n"); - for(index = 0; index < last; index++) { - print_item(items + index); - } - - printf("\n"); - - update_quality(items, last); - } - return 0; -} diff --git a/c99/Makefile b/c99/Makefile deleted file mode 100644 index 113d1552..00000000 --- a/c99/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# Makefile for building the kata file with the Google Testing Framework -# -# SYNOPSIS: -# -# make [all] - makes everything, runs tests -# make TARGET - makes the given target. -# make clean - removes all files generated by make. -# make memtest - run memory leak analysis - -# The _POSIX_C_SOURCE definition prevents the compiler from throwing warnings -CFLAGS = `pkg-config --cflags check` -g --std=c99 -D_POSIX_C_SOURCE=200809L -LIBS = `pkg-config --libs check` - -# All files that should be part of your test should start with 'test_' -TEST_SRC = $(wildcard test_*.c) -TEST_BASE = $(basename ${TEST_SRC}) -TEST_OBJECTS = $(addsuffix .o, ${TEST_BASE}) - -# All files that should be part of your main program should start with 'gilded_' -PROG_SRC = $(wildcard gilded_*.c) -PROG_BASE = $(basename ${PROG_SRC}) -PROG_OBJECTS = $(addsuffix .o, ${PROG_BASE}) - -OBJECT_UNDER_TEST = GildedRose.o ${PROG_OBJECTS} - -# This is the test application. You can run this program to see your test output -TEST_APP = test_gildedrose - - -# This will generate output for several products over a course of several days. -# You can run this application to build golden rule tests -GOLDEN_APP = golden_rose - -all: ${TEST_APP} ${GOLDEN_APP} - ./${TEST_APP} - -${TEST_APP}: ${TEST_OBJECTS} ${OBJECT_UNDER_TEST} - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) - -${GOLDEN_APP}: GildedRoseTextTests.o ${OBJECT_UNDER_TEST} - $(CC) $(CFLAGS) -o $@ $^ - -# If you're not on a mac, you should run memtest (in fact, consider adding it to the 'all' target). -# If you're on a mac, complain to apple for breaking an important development tool. -memtest: ${TEST_APP} - valgrind --leak-check=full --error-exitcode=1 ./${TEST_APP} --nofork - -clean: - rm -f *.o - rm -f ${TEST_APP} - rm -f ${GOLDEN_APP} diff --git a/c99/README.md b/c99/README.md deleted file mode 100644 index ec2cd02e..00000000 --- a/c99/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Gilded Rose, C99 Edition - -The command "make" will build and run your tests, as well as build the program -golden_rose, which can serve as the basis for a golden-rule test. - - -## Assumptions - - gnu make and a C compiler (like gcc) is installed on your system and is in the PATH - - The check unit testing library is installed on your system (https://libcheck.github.io/check/) - - pkg-config is installed on your system - -## Usage - - Run `make` to build the program and run all tests - - Files which contain tests should be named `test_*.c` They will automatically - be included in your test suite. - - `GildedRose.h` should not be modified. The Goblin threat is real. - - New program logic may be included in files named `gilded_*.c` which will - automatically be included in both your tests and the final program. - -## Golden Rule tests - - The program `golden_rose` will generate text output. If you capture this - output after your first `make` you can use this as a reference for a golden - rule test. - - You can test your work against this reference by directing the output of your - current golden_rose to a file and using the `diff` utility to compare that - to the reference file you created above. - - To avoid the Goblin threat you can use `git diff GildedRose.h`, which should - have no output if you have left the precious Item structure unchanged. - -## Notes - - This project is tweaked to run on Linux systems, and will mostly work on Macs. - With some changes to the Makefile it can be made to run on BSD systems with - BSD make. An adventurous person could also get it to run on Windows. - - If you are working on a Macintosh computer you cannot run the memtest target, - because valgrind and OS X don't play nice any more. If you want to use the - memory checker OS X does run docker as a first class citizen. - - If you don't have pkg-config on your system, the only changes you'll need to - make are for the requirements of the check library. Mostly you need to - set the appropriate flags for threaded binaries, which may include some - special linker flags. The libcheck documentation will cover what you need - if you want to undertake this change. diff --git a/c99/run-once-cmake.sh b/c99/run-once-cmake.sh deleted file mode 100755 index 74e2c0e0..00000000 --- a/c99/run-once-cmake.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -if [[ ! -d build ]]; then - mkdir -p build -fi - -cd build -cmake .. -DCMAKE_BUILD_TYPE=DEBUG && cmake --build . && ctest --output-on-failure diff --git a/c99/test_main.c b/c99/test_main.c deleted file mode 100644 index 0d5a0de0..00000000 --- a/c99/test_main.c +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include - -Suite *suite_rose(void); - -int main(int argc, char **argv) -{ - Suite *s; - SRunner *runner; - int number_fails; - int forkme = 1; - - if (argc > 1 && strcmp(argv[1], "--nofork") == 0) { - forkme = 0; - } - - s = suite_rose(); - runner = srunner_create(s); - - if (0 == forkme) { - srunner_set_fork_status(runner, CK_NOFORK); - } - - srunner_run_all(runner, CK_NORMAL); - number_fails = srunner_ntests_failed(runner); - - srunner_free(runner); - - return number_fails; -} diff --git a/c99/test_rose.c b/c99/test_rose.c deleted file mode 100644 index 30cc7544..00000000 --- a/c99/test_rose.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include "GildedRose.h" - - - -START_TEST(roseFoo) -{ - Item items[1]; - init_item(items, "foo", 0, 0); - update_quality(items, 1); - - ck_assert_str_eq("fixme", items[0].name); -} -END_TEST - -TCase *tcase_rose(void) -{ - TCase *tc; - - tc = tcase_create("gilded-rose"); - tcase_add_test(tc, roseFoo); - - return tc; -} - -Suite *suite_rose(void) -{ - Suite *s; - - s = suite_create("characterization-tests"); - suite_add_tcase(s, tcase_rose()); - - return s; -} diff --git a/c99/test_unity_gildedrose.c b/c99/test_unity_gildedrose.c deleted file mode 100644 index 5e0d8b98..00000000 --- a/c99/test_unity_gildedrose.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "unity.h" -#include "GildedRose.h" - -void test_NameOfItem(void) -{ - Item items[1]; - init_item(items, "Foo", 0, 0); - update_quality(items, 1); - TEST_ASSERT_EQUAL_STRING( "fixme", items[0].name ); -} - -int main(void) -{ - UNITY_BEGIN(); - RUN_TEST(test_NameOfItem); - return UNITY_END(); -} - diff --git a/clisp/gilded-rose.lisp b/clisp/gilded-rose.lisp deleted file mode 100644 index 59143a42..00000000 --- a/clisp/gilded-rose.lisp +++ /dev/null @@ -1,140 +0,0 @@ -; Hi and welcome to team Gilded Rose. As you know, we are a small inn -; with a prime location in a prominent city ran by a friendly -; innkeeper named Allison. We also buy and sell only the finest goods. -; Unfortunately, our goods are constantly degrading in quality as they -; approach their sell by date. We have a system in place that updates -; our inventory for us. It was developed by a no-nonsense type named -; Leeroy, who has moved on to new adventures. Your task is to add the -; new feature to our system so that we can begin selling a new -; category of items. -; First an introduction to our system: -; All items have a SellIn value which denotes the number of days we have to sell the item -; All items have a Quality value which denotes how valuable the item is -; At the end of each day our system lowers both values for every item -; Pretty simple, right? Well this is where it gets interesting: -; Once the sell by date has passed, Quality degrades twice as fast -; The Quality of an item is never negative -; "Aged Brie" actually increases in Quality the older it gets -; The Quality of an item is never more than 50 -; "Sulfuras", being a legendary item, never has to be sold or decreases in Quality -; "Backstage passes", like aged brie, increases in Quality as it's -; SellIn value approaches; Quality increases by 2 when there are 10 -; days or less and by 3 when there are 5 days or less but Quality -; drops to 0 after the concert -; We have recently signed a supplier of conjured items. This requires an update to our system: -; "Conjured" items degrade in Quality twice as fast as normal items -; Feel free to make any changes to the UpdateQuality method and add -; any new code as long as everything still works correctly. However, -; do not alter the Item class or Items property as those belong to the -; goblin in the corner who will insta-rage and one-shot you as he -; doesn't believe in shared code ownership (you can make the -; UpdateQuality method and Items property static if you like, we'll -; cover for you). -; Just for clarification, an item can never have its Quality increase -; above 50, however "Sulfuras" is a legendary item and as such its -; Quality is 80 and it never alters. - -; https://github.com/emilybache/GildedRose-Refactoring-Kata - -; Common Lisp version: Rainer Joswig, joswig@lisp.de, 2016 - -; Example from the command line: -; sbcl --script gildedrose.lisp 10 - -;;; ================================================================ -;;; Code - -(defpackage "GILDED-ROSE" - (:use "CL")) - -(in-package "GILDED-ROSE") - - -;;; Class ITEM - -(defclass item () - ((name :initarg :name :type string) - (sell-in :initarg :sell-in :type integer) - (quality :initarg :quality :type integer))) - -(defmethod to-string ((i item)) - (with-slots (name quality sell-in) i - (format nil "~a, ~a, ~a" name sell-in quality))) - -;;; Class GILDED-ROSE - -(defclass gilded-rose () - ((items :initarg :items))) - -(defmethod update-quality ((gr gilded-rose)) - (with-slots (items) gr - (dotimes (i (length items)) - (with-slots (name quality sell-in) - (elt items i) - (if (and (not (equalp name "Aged Brie")) - (not (equalp name "Backstage passes to a TAFKAL80ETC concert"))) - (if (> quality 0) - (if (not (equalp name "Sulfuras, Hand of Ragnaros")) - (setf quality (- quality 1)))) - (when (< quality 50) - (setf quality (+ quality 1)) - (when (equalp name "Backstage passes to a TAFKAL80ETC concert") - (if (< sell-in 11) - (if (< quality 50) - (setf quality (+ quality 1)))) - (if (< sell-in 6) - (if (< quality 50) - (setf quality (+ quality 1))))))) - - (if (not (equalp name "Sulfuras, Hand of Ragnaros")) - (setf sell-in (- sell-in 1))) - - (if (< sell-in 0) - (if (not (equalp name "Aged Brie")) - (if (not (equalp name "Backstage passes to a TAFKAL80ETC concert")) - (if (> quality 0) - (if (not (equalp name "Sulfuras, Hand of Ragnaros")) - (setf quality (- quality 1)))) - (setf quality (- quality quality))) - (if (< quality 50) - (setf quality (+ quality 1))))))))) - -;;; Example - -(defun run-gilded-rose () - (write-line "OMGHAI!") - (let* ((descriptions '(("+5 Dexterity Vest" 10 20) - ("Aged Brie" 2 0) - ("Elixir of the Mongoose" 5 7) - ("Sulfuras, Hand of Ragnaros" 0 80) - ("Sulfuras, Hand of Ragnaros" -1 80) - ("Backstage passes to a TAFKAL80ETC concert" 15 20) - ("Backstage passes to a TAFKAL80ETC concert" 10 49) - ("Backstage passes to a TAFKAL80ETC concert" 5 49) - ;; this conjured item does not work properly yet - ("Conjured Mana Cake" 3 6))) - (items (loop for (name sell-in quality) in descriptions - collect (make-instance 'item - :name name - :sell-in sell-in - :quality quality))) - (app (make-instance 'gilded-rose :items items)) - (days 2)) - #+sbcl - (if (second sb-ext:*posix-argv*) - (setf days (parse-integer (second sb-ext:*posix-argv*)))) - #+lispworks - (if (fourth sys:*line-arguments-list*) - (setf days (parse-integer (fourth sys:*line-arguments-list*)))) - (dotimes (i days) - (format t "-------- day ~a --------~%" i) - (format t "name, sell-in, quality~%") - (dolist (item items) - (write-line (to-string item))) - (terpri) - (update-quality app)))) - -(run-gilded-rose) - -;;; ================================================================ -;;; EOF diff --git a/cpp-catch2/.gitignore b/cpp-catch2/.gitignore deleted file mode 100644 index 401f2947..00000000 --- a/cpp-catch2/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/build_meson/ -/subprojects/Catch2-*/ -/subprojects/packagecache/ -/cmake-build-*/ diff --git a/cpp-catch2/CMakeLists.txt b/cpp-catch2/CMakeLists.txt deleted file mode 100644 index 4d205699..00000000 --- a/cpp-catch2/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -cmake_minimum_required(VERSION 3.14..3.16) -set(CMAKE_VERBOSE_MAKEFILE ON) -project(GildedRoseKata VERSION 1.0 - DESCRIPTION "The GildedRose Refactoring kata for an approval testing approach" - LANGUAGES CXX) -include(FetchContent) - -FetchContent_Declare( - catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v2.12.2 -) -FetchContent_MakeAvailable(catch2) -LIST(APPEND CMAKE_MODULE_PATH - ${catch2_SOURCE_DIR}/contrib - ) - -FetchContent_Declare( - approvaltests_ho - URL https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.0.0/ApprovalTests.v.10.0.0.hpp - DOWNLOAD_NO_EXTRACT TRUE - DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/approvaltests - DOWNLOAD_NAME ApprovalTests.v.10.0.0.hpp -) -FetchContent_GetProperties(approvaltests_ho) -if (NOT approvaltests_ho_POPULATED) - FetchContent_Populate(approvaltests_ho) -endif () -add_library(approvaltests INTERFACE) -target_include_directories(approvaltests - INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/approvaltests - INTERFACE ${catch2_SOURCE_DIR}/single_include/catch2 - ) - -add_executable(gildedrose_catch2 - src/GildedRose.h - src/GildedRose.cc - test/gildedrose_catch.cpp - test/main.cpp) -set_target_properties(gildedrose_catch2 PROPERTIES CXX_STANDARD 11) -target_include_directories(gildedrose_catch2 - PUBLIC src) -target_link_libraries(gildedrose_catch2 Catch2::Catch2 approvaltests) - -include(CTest) -include(ParseAndAddCatchTests) -ParseAndAddCatchTests(gildedrose_catch2) \ No newline at end of file diff --git a/cpp-catch2/README.md b/cpp-catch2/README.md deleted file mode 100644 index 66b941cb..00000000 --- a/cpp-catch2/README.md +++ /dev/null @@ -1,20 +0,0 @@ -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 -the [top level readme](https://github.com/emilybache/GildedRose-Refactoring-Kata) - for a general description of the exercise. - - -CMake ------ - -CMake is included in CLion from JetBrains. Without CMake files -CLion has a hard time to handle c-projects. - -To install CMake (if you don't use CLion) on macOS using brew - - brew install cmake - -Tested on CMake 3.15.3 (included with CLion 2019.3) on macOS - diff --git a/cpp-catch2/src/GildedRose.cc b/cpp-catch2/src/GildedRose.cc deleted file mode 100644 index 8df23e47..00000000 --- a/cpp-catch2/src/GildedRose.cc +++ /dev/null @@ -1,80 +0,0 @@ -#include "GildedRose.h" - -GildedRose::GildedRose(vector & items) : items(items) -{} - -void GildedRose::updateQuality() -{ - for (int i = 0; i < items.size(); i++) - { - if (items[i].name != "Aged Brie" && items[i].name != "Backstage passes to a TAFKAL80ETC concert") - { - if (items[i].quality > 0) - { - if (items[i].name != "Sulfuras, Hand of Ragnaros") - { - items[i].quality = items[i].quality - 1; - } - } - } - else - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - - if (items[i].name == "Backstage passes to a TAFKAL80ETC concert") - { - if (items[i].sellIn < 11) - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - - if (items[i].sellIn < 6) - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - } - } - } - - if (items[i].name != "Sulfuras, Hand of Ragnaros") - { - items[i].sellIn = items[i].sellIn - 1; - } - - if (items[i].sellIn < 0) - { - if (items[i].name != "Aged Brie") - { - if (items[i].name != "Backstage passes to a TAFKAL80ETC concert") - { - if (items[i].quality > 0) - { - if (items[i].name != "Sulfuras, Hand of Ragnaros") - { - items[i].quality = items[i].quality - 1; - } - } - } - else - { - items[i].quality = items[i].quality - items[i].quality; - } - } - else - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - } - } -} diff --git a/cpp-catch2/src/GildedRose.h b/cpp-catch2/src/GildedRose.h deleted file mode 100644 index 8464f87b..00000000 --- a/cpp-catch2/src/GildedRose.h +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using namespace std; - -class Item -{ -public: - string name; - int sellIn; - int quality; - Item(string name, int sellIn, int quality) : name(name), sellIn(sellIn), quality(quality) - {} -}; - -class GildedRose -{ -public: - vector & items; - GildedRose(vector & items); - - void updateQuality(); -}; - diff --git a/cpp-catch2/test/ApprovalTests.hpp b/cpp-catch2/test/ApprovalTests.hpp deleted file mode 100644 index 6da10acd..00000000 --- a/cpp-catch2/test/ApprovalTests.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "ApprovalTests.v.10.0.0.hpp" \ No newline at end of file diff --git a/cpp-catch2/test/gildedrose_catch.cpp b/cpp-catch2/test/gildedrose_catch.cpp deleted file mode 100644 index 753b153b..00000000 --- a/cpp-catch2/test/gildedrose_catch.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#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; -} - -TEST_CASE("UpdateQuality") { - - vector items; - items.push_back(Item("foo", 0, 0)); - GildedRose app(items); - app.updateQuality(); - REQUIRE("fixme" == app.items[0].name); -} diff --git a/cpp-catch2/test/main.cpp b/cpp-catch2/test/main.cpp deleted file mode 100644 index 94bae37b..00000000 --- a/cpp-catch2/test/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define CATCH_CONFIG_MAIN -#define APPROVALS_CATCH - -#include "catch2/catch.hpp" -#include "ApprovalTests.hpp" \ No newline at end of file diff --git a/cpp/.gitignore b/cpp/.gitignore deleted file mode 100644 index 5974ee76..00000000 --- a/cpp/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.idea -.vs -cmake-build-debug -build diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt deleted file mode 100644 index 26325069..00000000 --- a/cpp/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -cmake_minimum_required(VERSION 3.13) -project(gilded-rose-refactoring-kata-cpp) - -# Load FetchContent module. -include(FetchContent) - -# Declare GoogleTest as the content to fetch -FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.8.1 -) - -# Fetch GoogleTest amd make build scripts available -if (NOT googletest_POPULATED) - FetchContent_Populate(googletest) -endif() - -#set(gtest_force_shared_crt OFF CACHE BOOL "" FORCE) -# Force Google Test to link the C/C++ runtimes dynamically when -# building on Visual Studio -# Link: -# * https://github.com/google/googletest/tree/release-1.8.1/googletest#visual-studio-dynamic-vs-static-runtimes -if (MSVC) - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -endif() - -# Bring the populated content into the build -add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) - -# uncomment this line to enable coverage measurements using gcov -# set(CMAKE_CXX_FLAGS "--coverage") - -enable_testing() -add_subdirectory(src) -add_subdirectory(lib) -add_subdirectory(test) diff --git a/cpp/README.md b/cpp/README.md deleted file mode 100644 index 8c9b61e0..00000000 --- a/cpp/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# C++ version of Gilded Rose refactoring kata - -## Introduction -The C++ version of the Gilded Rose refactoring kata is available in four variants using different test frameworks: - -* Catch2 test framework - 1. Traditional unit test with the [Catch2](https://github.com/catchorg/Catch2) test framework in the `test/cpp_catch2_unittest` folder. - 2. [Approval tests](https://github.com/approvals/ApprovalTests.cpp) with the [Catch2](https://github.com/catchorg/Catch2) test framework in the `test/cpp_catch2_approvaltest` folder. -* Google Test framework - 1. Traditional unit test with the [Googletest](https://github.com/google/googletest) test framework in the `test/cpp_googletest_unittest` folder. - 2. [Approval tests](https://github.com/approvals/ApprovalTests.cpp) with the [Googletest](https://github.com/google/googletest) test framework in the `test/cpp_googletest_approvaltest` folder. - -The `GildedRose.cc` file, i.e. the code under test, is identical in all four variants. - -## Prerequisites - -* CMake version >= 3.13 -* C++ compiler that support C++11 - -## How to build and run tests in a terminal - -### Build tests - - $ cd ${GIT_FOLDER}/GildedRose-Refactoring-Kata/cpp - $ mkdir build - $ cd build - $ cmake .. - $ cmake --build . - -### Show available tests - - $ cd ${GIT_FOLDER}/GildedRose-Refactoring-Kata/cpp/build - $ ctest -N - Test project ${GIT_FOLDER}/GildedRose-Refactoring-Kata/cpp/build - Test #1: GildedRoseCatch2ApprovalTests - Test #2: GildedRoseCatch2UnitTests - Test #3: GildedRoseGoogletestApprovalTests - Test #4: GildedRoseGoogletestUnitTests - -### Run all tests - - $ ctest - -### Run all tests with verbose output - - $ ctest -VV - -### Run a specific test with verbose output - - $ ctest -VV --tests-regex Catch2Approval - -## How to build and run tests using the [CLion IDE](https://www.jetbrains.com/clion/) - -1. Start CLion -2. Select menu `File - Open...` -3. Select folder `${GIT_FOLDER}/GildedRose-Refactoring-Kata/cpp` -4. Select menu `Build - Build Project` -4. Select menu `Run - Run...` -4. Select what test variant to run, e.g. `GildedRoseCatch2ApprovalTests`. - -## How to build and run tests using Visual Studio 2019 - -1. Start Visual Studio 2019 -2. Select `Open a local folder` -3. Select folder `${GIT_FOLDER}/GildedRose-Refactoring-Kata/cpp` -4. Wait for message `CMake generation finished.` in the CMake output window at the bottom -5. Select what test variant to run in the drop down menu for Startup Items, e.g. `GildedRoseCatch2ApprovalTests.exe`. -6. Select menu `Debug - Start` diff --git a/cpp/lib/ApprovalTests.hpp b/cpp/lib/ApprovalTests.hpp deleted file mode 100644 index 6da64ef2..00000000 --- a/cpp/lib/ApprovalTests.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef APPROVAL_TEST_1_APPROVALTESTS_HPP -#define APPROVAL_TEST_1_APPROVALTESTS_HPP -#include "ApprovalTests.v.6.0.0.hpp" -#endif diff --git a/cpp/lib/ApprovalTests.v.6.0.0.hpp b/cpp/lib/ApprovalTests.v.6.0.0.hpp deleted file mode 100644 index 026b8569..00000000 --- a/cpp/lib/ApprovalTests.v.6.0.0.hpp +++ /dev/null @@ -1,2943 +0,0 @@ -// Approval Tests version v.6.0.0 -// More information at: https://github.com/approvals/ApprovalTests.cpp -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - // ******************** From: Blocker.h -#ifndef APPROVALTESTS_CPP_BLOCKER_H -#define APPROVALTESTS_CPP_BLOCKER_H - -namespace ApprovalTests { -class Blocker -{ -public: - virtual ~Blocker() = default; - virtual bool isBlockingOnThisMachine() const = 0; -}; -} - -#endif - - // ******************** From: Macros.h -#ifndef APPROVALTESTS_CPP_MACROS_H -#define APPROVALTESTS_CPP_MACROS_H - - - - -#define APPROVAL_TESTS_UNUSED(expr) do { (void)(expr); } while (0) - -#if __cplusplus >= 201703L - #define APPROVAL_TESTS_NO_DISCARD [[nodiscard]] -#else - #define APPROVAL_TESTS_NO_DISCARD -#endif - -#endif - - // ******************** From: WinMinGWUtils.h -#ifndef APPROVALTESTS_CPP_WINMINGWUTILS_H -#define APPROVALTESTS_CPP_WINMINGWUTILS_H - -// - -#if (defined(__MINGW32__) || defined(__MINGW64__)) -#define APPROVAL_TESTS_MINGW -#endif - -#ifdef APPROVAL_TESTS_MINGW -#ifdef __cplusplus -extern "C" { -#endif - -#include /* errno_t, size_t */ - -errno_t getenv_s( - size_t *ret_required_buf_size, - char *buf, - size_t buf_size_in_bytes, - const char *name -); - -#ifdef __cplusplus -} -#endif - -#endif // APPROVAL_TESTS_MINGW - -// - -#endif - - // ******************** From: ApprovalWriter.h -#ifndef APPROVALTESTS_CPP_APPROVALWRITER_H -#define APPROVALTESTS_CPP_APPROVALWRITER_H - -namespace ApprovalTests { -class ApprovalWriter -{ -public: - virtual ~ApprovalWriter() = default; - virtual std::string getFileExtensionWithDot() const = 0; - virtual void write(std::string path) const = 0; - virtual void cleanUpReceived(std::string receivedPath) const = 0; -}; -} - -#endif - - // ******************** From: StringWriter.h -#ifndef APPROVALTESTS_CPP_STRINGWRITER_H -#define APPROVALTESTS_CPP_STRINGWRITER_H - - -namespace ApprovalTests { -class StringWriter : public ApprovalWriter -{ -private: - std::string s; - std::string ext; - -public: - explicit StringWriter( std::string contents, std::string fileExtensionWithDot = ".txt" ) - : s(std::move(contents)), ext(std::move(fileExtensionWithDot)) {} - - std::string getFileExtensionWithDot() const override - { - return ext; - } - - void write( std::string path ) const override - { - std::ofstream out( path.c_str(), std::ofstream::out ); - if ( ! out) - { - throw std::runtime_error("Unable to write file: " + path); - } - this->Write( out ); - out.close(); - } - - void Write( std::ostream &out ) const - { - out << s << "\n"; - } - - virtual void cleanUpReceived(std::string receivedPath) const override { - remove(receivedPath.c_str()); - } - - -}; -} -#endif - - // ******************** From: FileUtils.h - - - - -#ifndef APPROVALTESTS_CPP_FILEUTILS_H -#define APPROVALTESTS_CPP_FILEUTILS_H - - -namespace ApprovalTests { -class FileUtils { -public: - static bool fileExists(const std::string& path) - { - struct stat info{}; - return stat( path.c_str(), &info ) == 0; - } - - static int fileSize(const std::string& path) { - struct stat statbuf{}; - int stat_ok = stat(path.c_str(), &statbuf); - - if (stat_ok == -1) { - return -1; - } - - return int(statbuf.st_size); - } - - static void ensureFileExists(const std::string& fullFilePath) { - if (!fileExists(fullFilePath)) { - StringWriter s("", ""); - s.write(fullFilePath); - } - } - - static std::string getExtensionWithDot(const std::string& filePath) { - std::size_t found = filePath.find_last_of('.'); - return filePath.substr(found); - } - - static void writeToFile(const std::string& filePath, const std::string& content) - { - std::ofstream out(filePath.c_str(), std::ios::binary | std::ofstream::out); - if ( ! out) - { - throw std::runtime_error("Unable to write file: " + filePath); - } - out << content; - } -}; -} - -#endif - - // ******************** From: StringUtils.h - - -#ifndef APPROVALTESTS_CPP_STRINGUTILS_H -#define APPROVALTESTS_CPP_STRINGUTILS_H - - -namespace ApprovalTests { -class StringUtils -{ -public: - static std::string replaceAll(std::string inText, const std::string& find, const std::string& replaceWith) { - size_t start_pos = 0; - while ((start_pos = inText.find(find, start_pos)) != std::string::npos) { - inText.replace(start_pos, find.length(), replaceWith); - start_pos += replaceWith.length(); - } - return inText; - } - - static bool contains(const std::string& inText, const std::string& find) - { - return inText.find(find, 0) != std::string::npos; - } - - static std::string toLower(std::string inText) - { - std::string copy(inText); - std::transform(inText.begin(), inText.end(), copy.begin(), - [](char c){ return static_cast(tolower(c)); }); - return copy; - } - - static bool endsWith(std::string value, std::string ending) - { - if (ending.size() > value.size()) - { - return false; - } - return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); - } - - template - static std::string toString(const T& contents) - { - std::stringstream s; - s << contents; - return s.str(); - } - -}; -} -#endif - - // ******************** From: SystemUtils.h -#ifndef APPROVALTESTS_CPP_SYSTEMUTILS_H -#define APPROVALTESTS_CPP_SYSTEMUTILS_H - -// -#ifdef _WIN32 - // ReSharper disable once CppUnusedIncludeDirective - #include - #include - #include -#else - // ReSharper disable once CppUnusedIncludeDirective - #include -#endif -// - - - -namespace ApprovalTests { -class SystemUtils -{ -public: - static bool isWindowsOs() - { -#ifdef _WIN32 - return true; -#else - return false; -#endif - - } - - static bool isCygwin() - { -#ifdef __CYGWIN__ - return true; -#else - return false; -#endif - } - - static std::string getDirectorySeparator() - { - return isWindowsOs() ? "\\" : "/"; - } - - - static std::string checkFilenameCase(const std::string& fullPath) - { - if (!isWindowsOs() || !FileUtils::fileExists(fullPath)) - { - return fullPath; - } -#ifdef _WIN32 - - WIN32_FIND_DATAA findFileData; - HANDLE hFind = FindFirstFileA(fullPath.c_str(), &findFileData); - - if (hFind != INVALID_HANDLE_VALUE) - { - const std::string fixedFilename = findFileData.cFileName; - const std::string fixedPath = - StringUtils::replaceAll( fullPath, StringUtils::toLower(fixedFilename), fixedFilename ); - FindClose(hFind); - return fixedPath; - } - - -#endif - return fullPath; - - } - - static std::string safeGetEnvForWindows(char const *name) - { - APPROVAL_TESTS_UNUSED(name); -#ifdef _WIN32 - - - - - size_t size; - getenv_s(&size, nullptr, 0, name); - - if (size != 0) - { - std::string result; - result.resize(size); - getenv_s(&size, &*result.begin(), size, name); - result.pop_back(); - return result; - } -#endif - return std::string(); - } - - static std::string safeGetEnvForNonWindows(char const *name) - { - APPROVAL_TESTS_UNUSED(name); - char* p = nullptr; -#ifndef _WIN32 - p = getenv(name); -#endif - return (p != nullptr) ? p : std::string(); - } - - - static std::string safeGetEnv(char const *name) - { - return isWindowsOs() ? safeGetEnvForWindows(name) : safeGetEnvForNonWindows(name); - } - - static std::string getMachineName() - { - auto name = safeGetEnv("COMPUTERNAME"); - if ( ! name.empty()) - { - return name; - } - - name = safeGetEnv("HOSTNAME"); - if ( ! name.empty()) - { - return name; - } - - return "Unknown Computer"; - } - - static void makeDirectoryForWindows(const std::string& directory) - { - APPROVAL_TESTS_UNUSED(directory); -#ifdef _WIN32 - int nError = _mkdir(directory.c_str()); - if (nError != 0) - { - std::string helpMessage = std::string("Unable to create directory: ") + directory; - throw std::runtime_error( helpMessage ); - } -#endif - } - - static void makeDirectoryForNonWindows(const std::string& directory) - { - APPROVAL_TESTS_UNUSED(directory); -#ifndef _WIN32 - mode_t nMode = 0733; - int nError = mkdir(directory.c_str(),nMode); - if (nError != 0) - { - std::string helpMessage = std::string("Unable to create directory: ") + directory; - throw std::runtime_error( helpMessage ); - } -#endif - } - - static void makeDirectory(const std::string& directory) - { - makeDirectoryForWindows(directory); - makeDirectoryForNonWindows(directory); - } - - static void ensureDirectoryExists(const std::string& fullFilePath) - { - if (!FileUtils::fileExists(fullFilePath)) - { - makeDirectory(fullFilePath); - } - } -}; -} -#endif - - // ******************** From: MachineBlocker.h -#ifndef APPROVALTESTS_CPP_MACHINEBLOCKER_H -#define APPROVALTESTS_CPP_MACHINEBLOCKER_H - - -namespace ApprovalTests { -class MachineBlocker : public Blocker -{ -private: - std::string machineName; - bool block; - - MachineBlocker() = delete; - -public: - MachineBlocker(std::string machineName, bool block ) : machineName(std::move(machineName)), block(block) - { - } - - static MachineBlocker onMachineNamed( const std::string& machineName ) - { - return MachineBlocker(machineName, true); - } - - static MachineBlocker onMachinesNotNamed( const std::string& machineName ) - { - return MachineBlocker(machineName, false); - } - - virtual bool isBlockingOnThisMachine() const override - { - const auto isMachine = (SystemUtils::getMachineName() == machineName); - return isMachine == block; - } -}; -} - -#endif - - // ******************** From: FileUtilsSystemSpecific.h -#ifndef APPROVALTESTS_CPP_FILEUTILSSYSTEMSPECIFIC_H -#define APPROVALTESTS_CPP_FILEUTILSSYSTEMSPECIFIC_H - - -namespace ApprovalTests { -class FileUtilsSystemSpecific -{ -public: - static std::string getCommandLineForCopy(const std::string& source, const std::string& destination, bool isWindows) - { - if (isWindows) { - return std::string("copy /Y ") + "\"" + source + "\" \"" + destination + "\""; - } else { - return std::string("cp ") + "\"" + source + "\" \"" + destination + "\""; - } - } - - static void copyFile(const std::string& source, const std::string& destination ) - { - system( getCommandLineForCopy(source, destination, SystemUtils::isWindowsOs()).c_str() ); - } -}; -} -#endif - - // ******************** From: Reporter.h -#ifndef APPROVALTESTS_CPP_REPORTER_H -#define APPROVALTESTS_CPP_REPORTER_H - - -namespace ApprovalTests { - -class Reporter { -public: - virtual ~Reporter() = default; - virtual bool report(std::string received, std::string approved) const = 0; -}; - - -template -using IsNotDerivedFromReporter = typename std::enable_if::value, int>::type; -} - -#endif - - // ******************** From: AutoApproveReporter.h -#ifndef APPROVALTESTS_CPP_AUTOAPPROVEREPORTER_H -#define APPROVALTESTS_CPP_AUTOAPPROVEREPORTER_H - - - -namespace ApprovalTests { -class AutoApproveReporter : public Reporter -{ -public: - bool report(std::string received, std::string approved) const override - { - std::cout << "file " << approved << " automatically approved - next run should succeed\n"; - FileUtilsSystemSpecific::copyFile( received, approved ); - return true; - } -}; -} - -#endif - - // ******************** From: ApprovalNamer.h -#ifndef APPROVALTESTS_CPP_APPROVALNAMER_H -#define APPROVALTESTS_CPP_APPROVALNAMER_H - - -namespace ApprovalTests { -class ApprovalNamer -{ -public: - virtual ~ApprovalNamer() = default; - virtual std::string getApprovedFile(std::string extensionWithDot) const = 0; - virtual std::string getReceivedFile(std::string extensionWithDot) const = 0; - -}; -} - -#endif - - // ******************** From: ApprovalTestNamer.h -#ifndef APPROVALTESTS_CPP_APPROVALTESTNAMER_H -#define APPROVALTESTS_CPP_APPROVALTESTNAMER_H - - -namespace ApprovalTests { -class TestName { -public: - const std::string& getFileName() const { - return fileName; - } - - void setFileName(const std::string &file) { - fileName = SystemUtils::checkFilenameCase(file); - } - - std::vector sections; -private: - std::string fileName; -}; - -class TestConfiguration { -public: - std::string subdirectory; -}; - -class ApprovalTestNamer : public ApprovalNamer { -private: -public: - ApprovalTestNamer() = default; - - std::string getTestName() const { - std::stringstream ext; - auto test = getCurrentTest(); - for (size_t i = 0; i < test.sections.size(); i++) { - if (0 < i) { - ext << "."; - } - ext << test.sections[i]; - } - - return convertToFileName(ext.str()); - } - - static bool isForbidden(char c) - { - static std::string forbiddenChars("\\/:?\"<>|' "); - return std::string::npos != forbiddenChars.find(c); - } - - static std::string convertToFileName(const std::string& fileName) - { - std::stringstream result; - for (auto ch : fileName) - { - if (!isForbidden(ch)) - { - result << ch; - } - else - { - result << "_"; - } - } - return result.str(); - } - - static TestName &getCurrentTest() - { - try - { - return currentTest(); - } - catch( const std::runtime_error& ) - { - std::string helpMessage = getMisconfiguredMainHelp(); - throw std::runtime_error( helpMessage ); - } - } - -// - static std::string getMisconfiguredMainHelp() - { - std::string lineBreak = "************************************************************************************n"; - std::string lineBuffer = "* *n"; - std::string helpMessage = - "nn" + lineBreak + lineBuffer + -R"(* Welcome to Approval Tests. -* -* You have forgotten to configure your test framework for Approval Tests. -* -* To do this in Catch, add the following to your main.cpp: -* -* #define APPROVALS_CATCH -* #include "ApprovalTests.hpp" -* -* To do this in Google Test, add the following to your main.cpp: -* -* #define APPROVALS_GOOGLETEST -* #include "ApprovalTests.hpp" -* -* To do this in doctest, add the following to your main.cpp: -* -* #define APPROVALS_DOCTEST -* #include "ApprovalTests.hpp" -* -* For more information, please visit: -* https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/GettingStarted.md -)" + - lineBuffer + lineBreak + 'n'; - return helpMessage; - } -// - - - - std::string getFileName() const { - return getSourceFileName(); - } - - - std::string getSourceFileName() const { - auto file = getCurrentTest().getFileName(); - auto start = file.rfind(SystemUtils::getDirectorySeparator()) + 1; - auto end = file.rfind('.'); - auto fileName = file.substr(start, end - start); - return convertToFileName(fileName); - } - - std::string getDirectory() const { - auto file = getCurrentTest().getFileName(); - auto end = file.rfind(SystemUtils::getDirectorySeparator()) + 1; - auto directory = file.substr(0, end); - if ( ! testConfiguration().subdirectory.empty() ) - { - directory += testConfiguration().subdirectory + SystemUtils::getDirectorySeparator(); - SystemUtils::ensureDirectoryExists(directory); - } - return directory; - } - - static TestName& currentTest(TestName* value = nullptr) - { - static TestName* staticValue; - if (value != nullptr) - { - staticValue = value; - } - if ( staticValue == nullptr ) - { - throw std::runtime_error("The variable in currentTest() is not initialised"); - } - return *staticValue; - } - - static TestConfiguration& testConfiguration() - { - static TestConfiguration configuration; - return configuration; - } - - virtual std::string getApprovedFile(std::string extensionWithDot) const override { - - return getFullFileName(".approved", extensionWithDot); - } - - virtual std::string getReceivedFile(std::string extensionWithDot) const override { - - return getFullFileName(".received", extensionWithDot); - } - - std::string getOutputFileBaseName() const { - return getSourceFileName() + "." + getTestName(); - } - - std::string getFullFileName(const std::string& approved, const std::string& extensionWithDot) const { - std::stringstream ext; - ext << getDirectory() << getOutputFileBaseName() << approved << extensionWithDot; - return ext.str(); - } -}; -} - -#endif - - // ******************** From: SectionNameDisposer.h -#ifndef APPROVALTESTS_CPP_SECTIONNAMEDISPOSER_H -#define APPROVALTESTS_CPP_SECTIONNAMEDISPOSER_H - - -namespace ApprovalTests { -class APPROVAL_TESTS_NO_DISCARD SectionNameDisposer -{ -public: - SectionNameDisposer(TestName& currentTest, const std::string& scope_name) : - currentTest(currentTest) - { - - - currentTest.sections.push_back(scope_name); - } - - ~SectionNameDisposer() - { - - currentTest.sections.pop_back(); - } -private: - TestName& currentTest; -}; -} - -#endif - - // ******************** From: GoogleCustomizationsFactory.h -#ifndef APPROVALTESTS_CPP_GOOGLECUSTOMIZATIONSFACTORY_H -#define APPROVALTESTS_CPP_GOOGLECUSTOMIZATIONSFACTORY_H - - - -namespace ApprovalTests { -class GoogleCustomizationsFactory -{ -public: - using Comparator = std::function; -private: - using ComparatorContainer = std::vector< Comparator >; - static ComparatorContainer& comparatorContainer() - { - static ComparatorContainer container; - if (container.empty()) - { - auto exactNameMatching = [](const std::string& testFileNameWithExtension, const std::string& testCaseName) - { - return StringUtils::contains(testFileNameWithExtension, testCaseName + "."); - }; - container.push_back( exactNameMatching ); - } - return container; - } - -public: - static ComparatorContainer getEquivalencyChecks() - { - return comparatorContainer(); - } - - APPROVAL_TESTS_NO_DISCARD static bool addTestCaseNameRedundancyCheck(const Comparator& comparator) - { - comparatorContainer().push_back(comparator); - return true; - } - - -}; -} - -#endif - - // ******************** From: CartesianProduct.h -#ifndef APPROVALTESTS_CPP_CARTESIANPRODUCT_H -#define APPROVALTESTS_CPP_CARTESIANPRODUCT_H - - -namespace ApprovalTests { -namespace CartesianProduct { -namespace Detail { - - - -template -using enable_if_t = typename std::enable_if::type; - - -template -struct index_sequence {}; - -template -struct make_index_sequence : make_index_sequence {}; - -template -struct make_index_sequence<0, Is...> : index_sequence {}; - - - - -template -constexpr std::size_t tuple_size() { - return std::tuple_size::type>::value; -} - -template -using make_tuple_idxs = make_index_sequence()>; - - - -template -constexpr auto apply_impl(F&& f, Tuple&& t, index_sequence) - -> decltype(std::forward(f)(std::get(std::forward(t))...)) -{ - return std::forward(f)(std::get(std::forward(t))...); -} - -template -auto apply(F&& f, Tuple&& t) - -> decltype(apply_impl(std::forward(f), std::forward(t), make_tuple_idxs{})) -{ - apply_impl(std::forward(f), std::forward(t), make_tuple_idxs{}); -} - - -template -void for_each_impl(Tuple&& t, F&& f, index_sequence) { - (void)std::initializer_list{ - (std::forward(f)(std::get(std::forward(t))), 0)... - }; -} - -template -void for_each(Tuple&& t, F&& f) { - for_each_impl(std::forward(t), std::forward(f), make_tuple_idxs{}); -} - -template -auto transform_impl(Tuple&& t, F&& f, index_sequence) - -> decltype(std::make_tuple(std::forward(f)(std::get(std::forward(t)))...)) -{ - return std::make_tuple(std::forward(f)(std::get(std::forward(t)))...); -} - -template -auto transform(Tuple&& t, F&& f = {}) - -> decltype(transform_impl(std::forward(t), std::forward(f), make_tuple_idxs{})) -{ - return transform_impl(std::forward(t), std::forward(f), make_tuple_idxs{}); -} - -template -struct find_if_body { - const Predicate& pred; - std::size_t& index; - std::size_t currentIndex = 0; - bool found = false; - - find_if_body(const Predicate& p, std::size_t& i) : pred(p), index(i) {} - - template - void operator()(T&& value) { - if (found) return; - if (pred(std::forward(value))) { - index = currentIndex; - found = true; - } - ++currentIndex; - } -}; - -template -std::size_t find_if(Tuple&& tuple, Predicate pred = {}) { - std::size_t idx = tuple_size(); - for_each(std::forward(tuple), find_if_body(pred, idx)); - return idx; -} - -template -bool any_of(Tuple&& tuple, Predicate pred = {}) { - return find_if(std::forward(tuple), pred) != tuple_size(); -} - -struct is_range_empty { - template - bool operator()(const T& range) const { - using std::begin; - using std::end; - return begin(range) == end(range); - } -}; - - -struct dereference_iterator { - template - auto operator()(It&& it) const -> decltype(*std::forward(it)) { - return *std::forward(it); - } -}; - - -template()-1> -enable_if_t -increment_iterator(Its& it, const Its&, const Its&) { - ++std::get(it); -} - - -template()-1> -enable_if_t -increment_iterator(Its& its, const Its& begins, const Its& ends) { - if (++std::get(its) == std::get(ends)) { - std::get(its) = std::get(begins); - increment_iterator(its, begins, ends); - } -} -} - - - - - -template -void cartesian_product(F&& f, const Ranges&... ranges) { - using std::begin; - using std::end; - - if (Detail::any_of(std::forward_as_tuple(ranges...))) - return; - - const auto begins = std::make_tuple(begin(ranges)...); - const auto ends = std::make_tuple(end(ranges)...); - - for (auto its = begins; std::get<0>(its) != std::get<0>(ends); Detail::increment_iterator(its, begins, ends)) { - - - - - Detail::apply(std::forward(f), Detail::transform(its)); - } -} -} -} - -#endif - - // ******************** From: ExistingFile.h -#ifndef APPROVALTESTS_CPP_EXISTINGFILE_H -#define APPROVALTESTS_CPP_EXISTINGFILE_H - - - -namespace ApprovalTests { -class ExistingFile : public ApprovalWriter{ - std::string filePath; -public: - explicit ExistingFile(std::string filePath) : filePath(std::move(filePath)){} - virtual std::string getFileExtensionWithDot() const override { - return FileUtils::getExtensionWithDot(filePath); - } - virtual void write(std::string ) const override { - - } - virtual void cleanUpReceived(std::string ) const override { - - } -}; -} - -#endif - - // ******************** From: CommandLauncher.h -#ifndef APPROVALTESTS_CPP_COMMANDLAUNCHER_H -#define APPROVALTESTS_CPP_COMMANDLAUNCHER_H - - -namespace ApprovalTests { - -class CommandLauncher -{ -public: - virtual ~CommandLauncher() = default; - virtual bool launch(std::vector argv) = 0; -}; -} - -#endif - - // ******************** From: SystemLauncher.h - -#ifndef APPROVALTESTS_CPP_SYSTEMLAUNCHER_H -#define APPROVALTESTS_CPP_SYSTEMLAUNCHER_H - - -namespace ApprovalTests { - using ConvertArgumentsFunctionPointer = std::vector(*)(std::vector); - -class SystemLauncher : public CommandLauncher -{ -private: - ConvertArgumentsFunctionPointer convertArgumentsForSystemLaunching; -public: - SystemLauncher() : SystemLauncher(doNothing) - { - } - - explicit SystemLauncher(std::vector (*pointer)(std::vector)) : convertArgumentsForSystemLaunching(pointer) - { - } - - - void setConvertArgumentsForSystemLaunchingFunction(ConvertArgumentsFunctionPointer function) - { - convertArgumentsForSystemLaunching = function; - } - - bool exists(const std::string& command) - { - bool foundByWhich = false; - if (!SystemUtils::isWindowsOs()) { - std::string which = "which " + command + " > /dev/null 2>&1"; - int result = system(which.c_str()); - foundByWhich = (result == 0); - } - return foundByWhich || FileUtils::fileExists(command); - - } - - static std::vector doNothing(std::vector argv) - { - return argv; - } - - bool launch(std::vector argv) override - { - if (!exists(argv.front())) - { - return false; - } - - argv = convertArgumentsForSystemLaunching(argv); - - std::string command = std::accumulate(argv.begin(), argv.end(), std::string(""), [](const std::string& a, const std::string& b) {return a + " " + "\"" + b + "\""; }); - std::string launch = SystemUtils::isWindowsOs() ? ("start \"\" " + command) : (command + " &"); - system(launch.c_str()); - return true; - } -}; -} - -#endif - - // ******************** From: CommandReporter.h -#ifndef APPROVALTESTS_CPP_COMMANDREPORTER_H -#define APPROVALTESTS_CPP_COMMANDREPORTER_H - - -namespace ApprovalTests { - -class CommandReporter : public Reporter { -private: - std::string cmd; - CommandLauncher *l; - -protected: - CommandReporter(std::string command, CommandLauncher *launcher) - : cmd(std::move(command)), l(launcher) { - } - -public: - bool report(std::string received, std::string approved) const override { - FileUtils::ensureFileExists(approved); - return l->launch(getFullCommand(received, approved)); - } - - std::vector getFullCommand(const std::string &received, const std::string &approved) const - { - std::vector fullCommand; - fullCommand.push_back(cmd); - fullCommand.push_back(received); - fullCommand.push_back(approved); - return fullCommand; - } -}; -} -#endif - - // ******************** From: DiffInfo.h -#ifndef APPROVALTESTS_CPP_DIFFINFO_H -#define APPROVALTESTS_CPP_DIFFINFO_H - - -namespace ApprovalTests { -enum class Type { TEXT, IMAGE, TEXT_AND_IMAGE }; - - - -struct DiffInfo -{ - DiffInfo(std::string program, Type type) : - program(std::move(program)), - arguments("%s %s"), - type(type) - { - } - DiffInfo(std::string program, std::string arguments, Type type) : - program(std::move(program)), - arguments(std::move(arguments)), - type(type) - { - } - std::string program; - std::string arguments; - Type type; - - std::string getProgramForOs() const - { - std::string result = program; - if (result.rfind("{ProgramFiles}", 0) == 0) - { - const std::vector envVars = - { - "ProgramFiles", - "ProgramW6432", - "ProgramFiles(x86)" - }; - - for(const auto& envVar : envVars) - { - std::string envVarValue = SystemUtils::safeGetEnv(envVar); - if (envVarValue.empty()) - { - continue; - } - envVarValue += '\\'; - - auto result1 = StringUtils::replaceAll(result, "{ProgramFiles}", envVarValue); - if (FileUtils::fileExists(result1)) - { - return result1; - } - } - } - return result; - } -}; -} - -#endif - - // ******************** From: DiffPrograms.h -#ifndef APPROVALTESTS_CPP_DIFFPROGRAMS_H -#define APPROVALTESTS_CPP_DIFFPROGRAMS_H - - - -#define APPROVAL_TESTS_MACROS_ENTRY(name, defaultValue) \ - static DiffInfo name() { return defaultValue; } - - -namespace ApprovalTests { -namespace DiffPrograms { - - - namespace Mac { - APPROVAL_TESTS_MACROS_ENTRY(DIFF_MERGE, - DiffInfo("/Applications/DiffMerge.app/Contents/MacOS/DiffMerge", "%s %s -nosplash", Type::TEXT)) - - APPROVAL_TESTS_MACROS_ENTRY(BEYOND_COMPARE, DiffInfo("/Applications/Beyond Compare.app/Contents/MacOS/bcomp", Type::TEXT)) - - APPROVAL_TESTS_MACROS_ENTRY(KALEIDOSCOPE, DiffInfo("/Applications/Kaleidoscope.app/Contents/MacOS/ksdiff", Type::TEXT_AND_IMAGE)) - - APPROVAL_TESTS_MACROS_ENTRY(KDIFF3, DiffInfo("/Applications/kdiff3.app/Contents/MacOS/kdiff3", "%s %s -m", Type::TEXT)) - - APPROVAL_TESTS_MACROS_ENTRY(P4MERGE, DiffInfo("/Applications/p4merge.app/Contents/MacOS/p4merge", Type::TEXT_AND_IMAGE)) - - APPROVAL_TESTS_MACROS_ENTRY(TK_DIFF, DiffInfo("/Applications/TkDiff.app/Contents/MacOS/tkdiff", Type::TEXT)) - - APPROVAL_TESTS_MACROS_ENTRY(VS_CODE, DiffInfo("/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code", "-d %s %s", Type::TEXT)) - } - namespace Linux { - - APPROVAL_TESTS_MACROS_ENTRY(KDIFF3, DiffInfo("kdiff3", Type::TEXT)) - - APPROVAL_TESTS_MACROS_ENTRY(MELD, DiffInfo("meld", Type::TEXT)) - } - namespace Windows { - APPROVAL_TESTS_MACROS_ENTRY(BEYOND_COMPARE_3, DiffInfo("{ProgramFiles}Beyond Compare 3\\BCompare.exe", Type::TEXT_AND_IMAGE)) - - APPROVAL_TESTS_MACROS_ENTRY(BEYOND_COMPARE_4, DiffInfo("{ProgramFiles}Beyond Compare 4\\BCompare.exe", Type::TEXT_AND_IMAGE)) - - APPROVAL_TESTS_MACROS_ENTRY(TORTOISE_IMAGE_DIFF, - DiffInfo("{ProgramFiles}TortoiseSVN\\bin\\TortoiseIDiff.exe", "/left:%s /right:%s", Type::IMAGE)) - - APPROVAL_TESTS_MACROS_ENTRY(TORTOISE_TEXT_DIFF, DiffInfo("{ProgramFiles}TortoiseSVN\\bin\\TortoiseMerge.exe", Type::TEXT)) - - APPROVAL_TESTS_MACROS_ENTRY(WIN_MERGE_REPORTER, DiffInfo("{ProgramFiles}WinMerge\\WinMergeU.exe", Type::TEXT_AND_IMAGE)) - - APPROVAL_TESTS_MACROS_ENTRY(ARAXIS_MERGE, DiffInfo("{ProgramFiles}Araxis\\Araxis Merge\\Compare.exe", Type::TEXT_AND_IMAGE)) - - APPROVAL_TESTS_MACROS_ENTRY(CODE_COMPARE, DiffInfo("{ProgramFiles}Devart\\Code Compare\\CodeCompare.exe", Type::TEXT)) - - APPROVAL_TESTS_MACROS_ENTRY(KDIFF3, DiffInfo("{ProgramFiles}KDiff3\\kdiff3.exe", Type::TEXT)) - APPROVAL_TESTS_MACROS_ENTRY(VS_CODE, DiffInfo("{ProgramFiles}Microsoft VS Code\\Code.exe", "-d %s %s", Type::TEXT)) - - } -} -} - -#endif - - // ******************** From: GenericDiffReporter.h -#ifndef APPROVALTESTS_CPP_GENERICDIFFREPORTER_H -#define APPROVALTESTS_CPP_GENERICDIFFREPORTER_H - - -namespace ApprovalTests { -class GenericDiffReporter : public CommandReporter { -private: - SystemLauncher launcher; -public: - explicit GenericDiffReporter(const std::string& program) : CommandReporter(program, &launcher) - { - checkForCygwin(); - } - explicit GenericDiffReporter(const DiffInfo& info) : CommandReporter(info.getProgramForOs(), &launcher) - { - checkForCygwin(); - } - - void checkForCygwin() - { - if ( SystemUtils::isCygwin()) - { - launcher.setConvertArgumentsForSystemLaunchingFunction(convertForCygwin); - } - } - - static std::vector convertForCygwin(std::vector argv) - { - if (! SystemUtils::isCygwin()) - { - return argv; - } - std::vector copy = argv; - for( size_t i = 0; i != argv.size(); ++i ) - { - if ( i == 0) - { - copy[i] = "$(cygpath '" + argv[i] + "')"; - } - else - { - copy[i] = "$(cygpath -aw '" + argv[i] + "')"; - } - } - return copy; - } -}; -} - -#endif - - // ******************** From: FirstWorkingReporter.h -#ifndef APPROVALTESTS_CPP_FIRSTWORKINGREPORTER_H -#define APPROVALTESTS_CPP_FIRSTWORKINGREPORTER_H - - -namespace ApprovalTests { -class FirstWorkingReporter : public Reporter -{ -private: - std::vector< std::unique_ptr > reporters; -public: - - explicit FirstWorkingReporter(const std::vector& theReporters) - { - for(auto r : theReporters) - { - reporters.push_back(std::unique_ptr(r)); - } - } - - bool report(std::string received, std::string approved) const override - { - for(auto& r : reporters) - { - if (r->report(received, approved)) - { - return true; - } - } - return false; - } -}; -} - -#endif - - // ******************** From: LinuxReporters.h -#ifndef APPROVALTESTS_CPP_LINUXREPORTERS_H -#define APPROVALTESTS_CPP_LINUXREPORTERS_H - - -namespace ApprovalTests { -namespace Linux -{ - class KDiff3Reporter : public GenericDiffReporter { - public: - KDiff3Reporter() : GenericDiffReporter(DiffPrograms::Linux::KDIFF3()) {} - }; - - class MeldReporter : public GenericDiffReporter { - public: - MeldReporter() : GenericDiffReporter(DiffPrograms::Linux::MELD()) {} - }; - - class LinuxDiffReporter : public FirstWorkingReporter - { - public: - LinuxDiffReporter() : FirstWorkingReporter( - { - - new MeldReporter(), - new KDiff3Reporter() - - } - ) - { - } - }; - -} -} - -#endif - - // ******************** From: MacReporters.h -#ifndef APPROVALTESTS_CPP_MACREPORTERS_H -#define APPROVALTESTS_CPP_MACREPORTERS_H - - -namespace ApprovalTests { -namespace Mac { - class DiffMergeReporter : public GenericDiffReporter { - public: - DiffMergeReporter() : GenericDiffReporter(DiffPrograms::Mac::DIFF_MERGE()) {} - }; - - class VisualStudioCodeReporter : public GenericDiffReporter { - public: - VisualStudioCodeReporter() : GenericDiffReporter(DiffPrograms::Mac::VS_CODE()) {} - }; - - class BeyondCompareReporter : public GenericDiffReporter { - public: - BeyondCompareReporter() : GenericDiffReporter(DiffPrograms::Mac::BEYOND_COMPARE()) {} - }; - - class KaleidoscopeReporter : public GenericDiffReporter { - public: - KaleidoscopeReporter() : GenericDiffReporter(DiffPrograms::Mac::KALEIDOSCOPE()) {} - }; - - class KDiff3Reporter : public GenericDiffReporter { - public: - KDiff3Reporter() : GenericDiffReporter(DiffPrograms::Mac::KDIFF3()) {} - }; - - class P4MergeReporter : public GenericDiffReporter { - public: - P4MergeReporter() : GenericDiffReporter(DiffPrograms::Mac::P4MERGE()) {} - }; - - class TkDiffReporter : public GenericDiffReporter { - public: - TkDiffReporter() : GenericDiffReporter(DiffPrograms::Mac::TK_DIFF()) {} - }; - - class MacDiffReporter : public FirstWorkingReporter { - public: - MacDiffReporter() : FirstWorkingReporter( - { - - new BeyondCompareReporter(), - new DiffMergeReporter(), - new KaleidoscopeReporter(), - new P4MergeReporter(), - new KDiff3Reporter(), - new TkDiffReporter(), - new VisualStudioCodeReporter() - - } - ) { - } - }; -} -} - -#endif - - // ******************** From: WindowsReporters.h -#ifndef APPROVALTESTS_CPP_WINDOWSREPORTERS_H -#define APPROVALTESTS_CPP_WINDOWSREPORTERS_H - - -namespace ApprovalTests { -namespace Windows { - class BeyondCompare3Reporter : public GenericDiffReporter { - public: - BeyondCompare3Reporter() : GenericDiffReporter(DiffPrograms::Windows::BEYOND_COMPARE_3()) {} - }; - - class VisualStudioCodeReporter : public GenericDiffReporter { - public: - VisualStudioCodeReporter() : GenericDiffReporter(DiffPrograms::Windows::VS_CODE()) {} - }; - - class BeyondCompare4Reporter : public GenericDiffReporter { - public: - BeyondCompare4Reporter() : GenericDiffReporter(DiffPrograms::Windows::BEYOND_COMPARE_4()) {} - }; - - class BeyondCompareReporter : public FirstWorkingReporter { - public: - BeyondCompareReporter() : FirstWorkingReporter({new BeyondCompare4Reporter(), new BeyondCompare3Reporter()}) { - } - }; - - class TortoiseImageDiffReporter : public GenericDiffReporter { - public: - TortoiseImageDiffReporter() : GenericDiffReporter(DiffPrograms::Windows::TORTOISE_IMAGE_DIFF()) {} - }; - - class TortoiseTextDiffReporter : public GenericDiffReporter { - public: - TortoiseTextDiffReporter() : GenericDiffReporter(DiffPrograms::Windows::TORTOISE_TEXT_DIFF()) {} - }; - - class TortoiseDiffReporter : public FirstWorkingReporter { - public: - TortoiseDiffReporter() : FirstWorkingReporter( - {new TortoiseTextDiffReporter(), new TortoiseImageDiffReporter()}) { - } - }; - - class WinMergeReporter : public GenericDiffReporter { - public: - WinMergeReporter() : GenericDiffReporter(DiffPrograms::Windows::WIN_MERGE_REPORTER()) {} - }; - - class AraxisMergeReporter : public GenericDiffReporter { - public: - AraxisMergeReporter() : GenericDiffReporter(DiffPrograms::Windows::ARAXIS_MERGE()) {} - }; - - class CodeCompareReporter : public GenericDiffReporter { - public: - CodeCompareReporter() : GenericDiffReporter(DiffPrograms::Windows::CODE_COMPARE()) {} - }; - - class KDiff3Reporter : public GenericDiffReporter { - public: - KDiff3Reporter() : GenericDiffReporter(DiffPrograms::Windows::KDIFF3()) {} - }; - - class WindowsDiffReporter : public FirstWorkingReporter { - public: - WindowsDiffReporter() : FirstWorkingReporter( - { - - new TortoiseDiffReporter(), - new BeyondCompareReporter(), - new WinMergeReporter(), - new AraxisMergeReporter(), - new CodeCompareReporter(), - new KDiff3Reporter(), - new VisualStudioCodeReporter(), - - } - ) { - } - }; -} -} - -#endif - - // ******************** From: DiffReporter.h -#ifndef APPROVALTESTS_CPP_DIFFREPORTER_H -#define APPROVALTESTS_CPP_DIFFREPORTER_H - - -namespace ApprovalTests { -class DiffReporter : public FirstWorkingReporter -{ -public: - DiffReporter() : FirstWorkingReporter( - { - new Mac::MacDiffReporter(), - new Linux::LinuxDiffReporter(), - new Windows::WindowsDiffReporter() - } - ) - { - } -}; -} - -#endif - - // ******************** From: DefaultReporterFactory.h -#ifndef APPROVALTESTS_CPP_DEFAULTREPORTERFACTORY_H -#define APPROVALTESTS_CPP_DEFAULTREPORTERFACTORY_H - - - -namespace ApprovalTests { - -class DefaultReporterFactory -{ - -private: - static std::shared_ptr& defaultReporter() - { - static std::shared_ptr reporter = std::make_shared(); - return reporter; - } - -public: - static std::shared_ptr getDefaultReporter() - { - return defaultReporter(); - } - - static void setDefaultReporter( const std::shared_ptr& reporter) - { - defaultReporter() = reporter; - } - - -}; -} - -#endif - - // ******************** From: DefaultReporterDisposer.h -#ifndef APPROVALTESTS_CPP_DEFAULTREPORTERDISPOSER_H -#define APPROVALTESTS_CPP_DEFAULTREPORTERDISPOSER_H - - -namespace ApprovalTests { - -class APPROVAL_TESTS_NO_DISCARD DefaultReporterDisposer -{ -private: - std::shared_ptr previous_result; -public: - explicit DefaultReporterDisposer(const std::shared_ptr& reporter) - { - previous_result = DefaultReporterFactory::getDefaultReporter(); - DefaultReporterFactory::setDefaultReporter(reporter); - } - - ~DefaultReporterDisposer() - { - DefaultReporterFactory::setDefaultReporter(previous_result); - } -}; -} - -#endif - - // ******************** From: DefaultReporter.h -#ifndef APPROVALTESTS_CPP_DEFAULTREPORTER_H -#define APPROVALTESTS_CPP_DEFAULTREPORTER_H - - - -namespace ApprovalTests { -class DefaultReporter : public Reporter -{ -public: - virtual bool report(std::string received, std::string approved) const override - { - return DefaultReporterFactory::getDefaultReporter()->report(received, approved); - } -}; -} - -#endif - - // ******************** From: SubdirectoryDisposer.h -#ifndef APPROVALTESTS_CPP_SUBDIRECTORYDISPOSER_H -#define APPROVALTESTS_CPP_SUBDIRECTORYDISPOSER_H - - - -namespace ApprovalTests { - -class APPROVAL_TESTS_NO_DISCARD SubdirectoryDisposer -{ -private: - std::string previous_result; -public: - explicit SubdirectoryDisposer(std::string subdirectory) - { - previous_result = ApprovalTestNamer::testConfiguration().subdirectory; - ApprovalTestNamer::testConfiguration().subdirectory = std::move(subdirectory); - } - - ~SubdirectoryDisposer() - { - ApprovalTestNamer::testConfiguration().subdirectory = previous_result; - } -}; -} - -#endif - - // ******************** From: DefaultNamerFactory.h -#ifndef APPROVALTESTS_CPP_DEFAULTNAMERFACTORY_H -#define APPROVALTESTS_CPP_DEFAULTNAMERFACTORY_H - - - -namespace ApprovalTests { - - using NamerCreator = std::function()>; - - -class DefaultNamerFactory -{ -private: - static NamerCreator& defaultNamer() - { - static NamerCreator namer = [](){return std::make_shared();}; - return namer; - } - -public: - static NamerCreator getDefaultNamer() - { - return defaultNamer(); - } - - static void setDefaultNamer( NamerCreator namer) - { - defaultNamer() = std::move(namer); - } - -}; -} - -#endif - - // ******************** From: ExistingFileNamer.h -#ifndef APPROVALTESTS_CPP_EXISTINGFILENAMER_H -#define APPROVALTESTS_CPP_EXISTINGFILENAMER_H - - -namespace ApprovalTests { -class ExistingFileNamer: public ApprovalNamer{ - std::string filePath; -public: - explicit ExistingFileNamer(std::string filePath): filePath(std::move(filePath)){ - - } - virtual std::string getApprovedFile(std::string extensionWithDot) const override { - return DefaultNamerFactory::getDefaultNamer()()->getApprovedFile(extensionWithDot); - } - virtual std::string getReceivedFile(std::string ) const override { - return filePath; - } - -}; -} - -#endif - - // ******************** From: DefaultNamerDisposer.h -#ifndef APPROVALTESTS_CPP_DEFAULTNAMERDISPOSER_H -#define APPROVALTESTS_CPP_DEFAULTNAMERDISPOSER_H - - -namespace ApprovalTests { - -class APPROVAL_TESTS_NO_DISCARD DefaultNamerDisposer -{ -private: - NamerCreator previous_result; -public: - explicit DefaultNamerDisposer(NamerCreator namerCreator) - { - previous_result = DefaultNamerFactory::getDefaultNamer(); - DefaultNamerFactory::setDefaultNamer(std::move(namerCreator)); - } - - ~DefaultNamerDisposer() - { - DefaultNamerFactory::setDefaultNamer(previous_result); - } -}; -} - -#endif - - // ******************** From: QuietReporter.h -#ifndef APPROVALTESTS_CPP_QUIETREPORTER_H -#define APPROVALTESTS_CPP_QUIETREPORTER_H - - -namespace ApprovalTests { - -class QuietReporter : public Reporter -{ -public: - bool report(std::string , std::string ) const override - { - return true; - } -}; -} - -#endif - - // ******************** From: CIBuildOnlyReporter.h -#ifndef APPROVALTESTS_CPP_CIBUILDONLYREPORTER_H -#define APPROVALTESTS_CPP_CIBUILDONLYREPORTER_H - - - -namespace ApprovalTests -{ - - class CIBuildOnlyReporter : public Reporter - { - private: - std::shared_ptr m_reporter; - - public: - explicit CIBuildOnlyReporter(std::shared_ptr reporter = std::make_shared()) - : m_reporter(reporter) - { - } - - bool report(std::string received, std::string approved) const override - { - if (!isRunningUnderCI()) - { - return false; - } - m_reporter->report(received, approved); - - - return true; - } - - static bool isRunningUnderCI() - { - - auto environmentVariablesForCI = { - - "CI", - "CONTINUOUS_INTEGRATION", - "GO_SERVER_URL", - "JENKINS_URL", - "TEAMCITY_VERSION" - - }; - for (const auto& variable : environmentVariablesForCI) - { - if (!SystemUtils::safeGetEnv(variable).empty()) - { - return true; - } - } - return false; - } - }; -} - -#endif - - // ******************** From: DefaultFrontLoadedReporter.h -#ifndef APPROVALTESTS_CPP_DEFAULTFRONTLOADEDREPORTER_H -#define APPROVALTESTS_CPP_DEFAULTFRONTLOADEDREPORTER_H - - -namespace ApprovalTests { -class DefaultFrontLoadedReporter : public FirstWorkingReporter -{ -public: - DefaultFrontLoadedReporter() : FirstWorkingReporter( - { - new CIBuildOnlyReporter() - } - ) - { - } -}; -} - -#endif - - // ******************** From: FrontLoadedReporterFactory.h -#ifndef APPROVALTESTS_CPP_FRONTLOADEDREPORTERFACTORY_H -#define APPROVALTESTS_CPP_FRONTLOADEDREPORTERFACTORY_H - - - -namespace ApprovalTests { - -class FrontLoadedReporterFactory -{ - static std::shared_ptr& frontLoadedReporter() - { - static std::shared_ptr reporter = std::make_shared(); - return reporter; - } - -public: - static std::shared_ptr getFrontLoadedReporter() - { - return frontLoadedReporter(); - } - - static void setFrontLoadedReporter( const std::shared_ptr& reporter) - { - frontLoadedReporter() = reporter; - } -}; -} - -#endif - - // ******************** From: FrontLoadedReporterDisposer.h -#ifndef APPROVALTESTS_CPP_FRONTLOADEDREPORTERDISPOSER_H -#define APPROVALTESTS_CPP_FRONTLOADEDREPORTERDISPOSER_H - - -namespace ApprovalTests { - -class APPROVAL_TESTS_NO_DISCARD FrontLoadedReporterDisposer -{ -private: - std::shared_ptr previous_result; -public: - explicit FrontLoadedReporterDisposer(const std::shared_ptr& reporter) - { - previous_result = FrontLoadedReporterFactory::getFrontLoadedReporter(); - FrontLoadedReporterFactory::setFrontLoadedReporter(reporter); - } - - ~FrontLoadedReporterDisposer() - { - FrontLoadedReporterFactory::setFrontLoadedReporter(previous_result); - } - -}; -} - -#endif - - // ******************** From: ApprovalException.h -#ifndef APPROVALTESTS_CPP_APPROVALEXCEPTION_H -#define APPROVALTESTS_CPP_APPROVALEXCEPTION_H - - -namespace ApprovalTests { -class ApprovalException : public std::exception -{ -private: - std::string message; -public: - explicit ApprovalException( const std::string& msg ) : message( msg ) {} - - virtual const char *what() const noexcept override - { - return message.c_str(); - } -}; - -class ApprovalMismatchException : public ApprovalException -{ -private: - std::string format( const std::string &received, const std::string &approved ) - { - std::stringstream s; - s << "Failed Approval: \n" - << "Received does not match approved \n" - << "Received : \"" << received << "\" \n" - << "Approved : \"" << approved << "\""; - return s.str(); - } -public: - ApprovalMismatchException(const std::string& received, const std::string& approved ) - : ApprovalException( format( received, approved ) ) - { - } -}; - -class ApprovalMissingException : public ApprovalException -{ -private: - std::string format( const std::string &file ) - { - std::stringstream s; - s << "Failed Approval: \n" - << "Approval File Not Found \n" - << "File: \"" << file << '"'; - return s.str(); - } -public: - ApprovalMissingException(const std::string& , const std::string& approved ) - : ApprovalException( format( approved ) ) - { - } -}; -} - -#endif - - // ******************** From: ApprovalComparator.h -#ifndef APPROVALTESTS_CPP_APPROVALCOMPARATOR_H -#define APPROVALTESTS_CPP_APPROVALCOMPARATOR_H - - -namespace ApprovalTests { -class ApprovalComparator -{ -public: - virtual ~ApprovalComparator() = default; - - virtual bool contentsAreEquivalent(std::string receivedPath, - std::string approvedPath) const = 0; -}; -} - -#endif - - // ******************** From: TextFileComparator.h -#ifndef APPROVALTESTS_CPP_TEXTFILECOMPARATOR_H -#define APPROVALTESTS_CPP_TEXTFILECOMPARATOR_H - - -namespace ApprovalTests { -class TextFileComparator : public ApprovalComparator -{ -public: - static std::ifstream::int_type getNextRelevantCharacter(std::ifstream& astream) - { - auto ch = astream.get(); - if (ch == '\r') - { - return astream.get(); - } - else - { - return ch; - } - } - - virtual bool contentsAreEquivalent(std::string receivedPath, - std::string approvedPath) const override - { - std::ifstream astream(approvedPath.c_str(), - std::ios::binary | std::ifstream::in); - std::ifstream rstream(receivedPath.c_str(), - std::ios::binary | std::ifstream::in); - - while (astream.good() && rstream.good()) { - int a = getNextRelevantCharacter(astream); - int r = getNextRelevantCharacter(rstream); - - if (a != r) { - return false; - } - } - return true; - } -}; -} -#endif - - // ******************** From: ComparatorDisposer.h -#ifndef APPROVALTESTS_CPP_COMPARATORDISPOSER_H -#define APPROVALTESTS_CPP_COMPARATORDISPOSER_H - - -namespace ApprovalTests -{ - -using ComparatorContainer = std::map >; - -class APPROVAL_TESTS_NO_DISCARD ComparatorDisposer -{ -public: - ComparatorDisposer( - ComparatorContainer &comparators, - std::string extensionWithDot, - std::shared_ptr previousComparator, - std::shared_ptr newComparator) - : - comparators(comparators), - ext_(extensionWithDot), - previousComparator(previousComparator) - { - comparators[extensionWithDot] = newComparator; - } - - ~ComparatorDisposer() - { - comparators[ext_] = previousComparator; - } - -private: - ComparatorContainer &comparators; - std::string ext_; - std::shared_ptr previousComparator; -}; - -} - -#endif - - // ******************** From: ComparatorFactory.h -#ifndef APPROVALTESTS_CPP_COMPARATORFACTORY_H -#define APPROVALTESTS_CPP_COMPARATORFACTORY_H - - -namespace ApprovalTests { - -class ComparatorFactory { -private: - static ComparatorContainer &comparators() { - static ComparatorContainer allComparators; - return allComparators; - } - -public: - static ComparatorDisposer - registerComparator(const std::string &extensionWithDot, std::shared_ptr comparator) { - return ComparatorDisposer(comparators(), extensionWithDot, - getComparatorForFileExtensionWithDot(extensionWithDot), - comparator); - } - - static std::shared_ptr getComparatorForFile(const std::string &receivedPath) { - const std::string fileExtension = FileUtils::getExtensionWithDot(receivedPath); - return getComparatorForFileExtensionWithDot(fileExtension); - } - - static std::shared_ptr - getComparatorForFileExtensionWithDot(const std::string &fileExtensionWithDot) { - auto iterator = comparators().find(fileExtensionWithDot); - if (iterator != comparators().end()) { - return iterator->second; - } - return std::make_shared(); - } -}; - -} - -#endif - - // ******************** From: FileApprover.h -#ifndef APPROVALTESTS_CPP_FILEAPPROVER_H -#define APPROVALTESTS_CPP_FILEAPPROVER_H - - -namespace ApprovalTests { - -class FileApprover { - -public: - FileApprover() = default; - - ~FileApprover() = default; - - static ComparatorDisposer registerComparatorForExtension(const std::string& extensionWithDot, std::shared_ptr comparator) - { - return ComparatorFactory::registerComparator(extensionWithDot, comparator); - } - - - static void verify(const std::string& receivedPath, - const std::string& approvedPath, - const ApprovalComparator& comparator) { - if (!FileUtils::fileExists(approvedPath)) { - throw ApprovalMissingException(receivedPath, approvedPath); - } - - if (!FileUtils::fileExists(receivedPath)) { - throw ApprovalMissingException(approvedPath, receivedPath); - } - - if (!comparator.contentsAreEquivalent(receivedPath, approvedPath)) { - throw ApprovalMismatchException(receivedPath, approvedPath); - } - } - - static void verify(const std::string& receivedPath, - const std::string& approvedPath) { - verify(receivedPath, approvedPath, *ComparatorFactory::getComparatorForFile(receivedPath)); - } - - static void verify(const ApprovalNamer& n, const ApprovalWriter& s, const Reporter& r) { - std::string approvedPath = n.getApprovedFile(s.getFileExtensionWithDot()); - std::string receivedPath = n.getReceivedFile(s.getFileExtensionWithDot()); - s.write(receivedPath); - try - { - verify(receivedPath, approvedPath); - s.cleanUpReceived(receivedPath); - } - catch (const ApprovalException&) { - reportAfterTryingFrontLoadedReporter(receivedPath, approvedPath, r); - throw; - } - } - - static void - reportAfterTryingFrontLoadedReporter(const std::string &receivedPath, const std::string &approvedPath, const Reporter &r) - { - auto tryFirst = FrontLoadedReporterFactory::getFrontLoadedReporter(); - if (!tryFirst->report(receivedPath, approvedPath)) - { - r.report(receivedPath, approvedPath); - } - } - - -}; -} - -#endif - - // ******************** From: Approvals.h -#ifndef APPROVALTESTS_CPP_APPROVALS_H -#define APPROVALTESTS_CPP_APPROVALS_H - - -namespace ApprovalTests { -class Approvals { -private: - Approvals() = default; - - ~Approvals() = default; - -public: - static std::shared_ptr getDefaultNamer() - { - return DefaultNamerFactory::getDefaultNamer()(); - } - - static void verify(std::string contents, const Reporter &reporter = DefaultReporter()) { - verifyWithExtension(contents, ".txt", reporter); - } - - static void verifyWithExtension(std::string contents, const std::string& fileExtensionWithDot, const Reporter &reporter = DefaultReporter()) { - StringWriter writer(contents, fileExtensionWithDot); - FileApprover::verify(*getDefaultNamer(), writer, reporter); - } - - static void verify(const ApprovalWriter& writer, const Reporter &reporter = DefaultReporter()) - { - FileApprover::verify(*getDefaultNamer(), writer, reporter); - } - - template - using IsNotDerivedFromWriter = typename std::enable_if::value, int>::type; - - template< - typename T, - typename = IsNotDerivedFromWriter> - static void verify(const T& contents, const Reporter &reporter = DefaultReporter()) { - verify(StringUtils::toString(contents), reporter); - } - - template< - typename T, - typename = IsNotDerivedFromWriter> - static void verifyWithExtension(const T& contents, const std::string& fileExtensionWithDot, const Reporter &reporter = DefaultReporter()) { - verifyWithExtension(StringUtils::toString(contents), fileExtensionWithDot, reporter); - } - - template< - typename T, - typename Function, - typename = IsNotDerivedFromReporter> - static void verify(const T& contents, - Function converter, - const Reporter &reporter = DefaultReporter()) - { - std::stringstream s; - converter(contents, s); - verify(s.str(), reporter); - } - - template< - typename T, - typename Function, - typename = IsNotDerivedFromReporter> - static void verifyWithExtension(const T& contents, - Function converter, - const std::string& fileExtensionWithDot, - const Reporter &reporter = DefaultReporter()) - { - std::stringstream s; - converter(contents, s); - verifyWithExtension(s.str(), fileExtensionWithDot, reporter); - } - - static void verifyExceptionMessage( - std::function functionThatThrows, - const Reporter &reporter = DefaultReporter()) - { - std::string message = "*** no exception thrown ***"; - try - { - functionThatThrows(); - } - catch(const std::exception& e) - { - message = e.what(); - } - verify(message, reporter); - } - - template - static void verifyAll(std::string header, - const Iterator &start, const Iterator &finish, - std::function converter, - const Reporter &reporter = DefaultReporter()) { - std::stringstream s; - if (!header.empty()) { - s << header << "\n\n\n"; - } - for (auto it = start; it != finish; ++it) { - converter(*it, s); - s << '\n'; - } - verify(s.str(), reporter); - } - - template - static void verifyAll(std::string header, - const Container &list, - std::function converter, - const Reporter &reporter = DefaultReporter()) { - verifyAll(header, list.begin(), list.end(), converter, reporter); - } - - template - static void verifyAll(std::string header, - const std::vector &list, - const Reporter &reporter = DefaultReporter()) { - int i = 0; - verifyAll>(header, list, [&](T e, std::ostream &s) { s << "[" << i++ << "] = " << e; }, - reporter); - } - - template - static void verifyAll(const std::vector &list, - const Reporter &reporter = DefaultReporter()) { - verifyAll("", list, reporter); - } - - static void verifyExistingFile(const std::string filePath, const Reporter &reporter = DefaultReporter()) { - ExistingFile writer(filePath); - ExistingFileNamer namer(filePath); - FileApprover::verify(namer, writer, reporter); - } - - static SubdirectoryDisposer useApprovalsSubdirectory(std::string subdirectory = "approval_tests") - { - return SubdirectoryDisposer(subdirectory); - } - - static DefaultReporterDisposer useAsDefaultReporter(const std::shared_ptr& reporter) - { - return DefaultReporterDisposer(reporter); - } - - static FrontLoadedReporterDisposer useAsFrontLoadedReporter(const std::shared_ptr& reporter) - { - return FrontLoadedReporterDisposer(reporter); - } - - static DefaultNamerDisposer useAsDefaultNamer(NamerCreator namerCreator) - { - return DefaultNamerDisposer(namerCreator); - } - -}; -} - -#endif - - // ******************** From: CombinationApprovals.h -#ifndef APPROVALTESTS_CPP_COMBINATIONAPPROVALS_H -#define APPROVALTESTS_CPP_COMBINATIONAPPROVALS_H - - -namespace ApprovalTests { -namespace CombinationApprovals { -namespace Detail { - - - - -template struct disjunction : std::false_type {}; -template struct disjunction : B1 {}; -template -struct disjunction : std::conditional>::type {}; - - - -struct print_input { - std::ostream& out; - template - void operator()(const T& input) { - out << ", " << input; - } -}; - - -template -struct serialize { - std::ostream& out; - Converter converter; - template - void operator()(T&& input1, Ts&&... inputs) { - - out << "(" << input1; - - CartesianProduct::Detail::for_each(std::forward_as_tuple(inputs...), print_input{out}); - out << ") => " << converter(input1, inputs...) << '\n'; - } -}; -} - -template -void verifyAllCombinations(Converter&& converter, const Reporter& reporter, const Container& input0, const Containers&... inputs) -{ - std::stringstream s; - CartesianProduct::cartesian_product(Detail::serialize{s, std::forward(converter)}, input0, inputs...); - Approvals::verify(s.str(), reporter); -} - -template -CartesianProduct::Detail::enable_if_t...>::value> -verifyAllCombinations(Converter&& converter, const Containers&... inputs) -{ - verifyAllCombinations(std::forward(converter), DefaultReporter(), inputs...); -} - -} -} - -#endif - - // ******************** From: Catch2Approvals.h - -#ifndef APPROVALTESTS_CPP_CATCH2APPROVALS_H -#define APPROVALTESTS_CPP_CATCH2APPROVALS_H - - -// -#if defined(APPROVALS_CATCH_EXISTING_MAIN) - #define APPROVALS_CATCH - #define CATCH_CONFIG_RUNNER -#elif defined(APPROVALS_CATCH) - #define CATCH_CONFIG_MAIN -#endif - -#ifdef APPROVALS_CATCH - -#include - -//namespace ApprovalTests { -struct Catch2ApprovalListener : Catch::TestEventListenerBase { - ApprovalTests::TestName currentTest; - using TestEventListenerBase::TestEventListenerBase; // This using allows us to use all base-class constructors - virtual void testCaseStarting(Catch::TestCaseInfo const &testInfo) override { - - currentTest.setFileName(testInfo.lineInfo.file); - ApprovalTests::ApprovalTestNamer::currentTest(¤tTest); - } - - virtual void testCaseEnded(Catch::TestCaseStats const &/*testCaseStats*/) override { - while (!currentTest.sections.empty()) { - currentTest.sections.pop_back(); - } - } - - virtual void sectionStarting(Catch::SectionInfo const §ionInfo) override { - currentTest.sections.push_back(sectionInfo.name); - } - - virtual void sectionEnded(Catch::SectionStats const &/*sectionStats*/) override { - currentTest.sections.pop_back(); - } -}; -//} -CATCH_REGISTER_LISTENER(Catch2ApprovalListener) - -#endif -#ifdef TEST_COMMIT_REVERT_CATCH - -//namespace ApprovalTests { -struct Catch2TestCommitRevert : Catch::TestEventListenerBase { - using TestEventListenerBase::TestEventListenerBase; // This using allows us to use all base-class constructors - virtual void testRunEnded( Catch::TestRunStats const& testRunStats )override{ - bool commit = testRunStats.totals.testCases.allOk(); - std::string message = "r "; - if (commit) { - std::cout << "git add -A n"; - std::cout << "git commit -m " << message; - } else - { - std::cout << "git clean -fd n"; - std::cout << "git reset --hard HEAD n"; - } - } -}; -//} -CATCH_REGISTER_LISTENER(Catch2TestCommitRevert) -#endif -// -#endif - - // ******************** From: DocTestApprovals.h -#ifndef APPROVALTESTS_CPP_DOCTESTAPPROVALS_H -#define APPROVALTESTS_CPP_DOCTESTAPPROVALS_H - - -// -#ifdef APPROVALS_DOCTEST - -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN - -#include - -namespace ApprovalTests { -// anonymous namespace to prevent compiler -Wsubobject-linkage warnings -// This is OK as this code is only compiled on main() -namespace { - struct AbstractReporter : doctest::IReporter { - virtual void report_query(const doctest::QueryData&) override {} - // called when the whole test run starts - virtual void test_run_start() override {} - - // called when the whole test run ends (caching a pointer to the input doesn't make sense here) - virtual void test_run_end(const doctest::TestRunStats &) override {} - - // called when a test case is started (safe to cache a pointer to the input) - virtual void test_case_start(const doctest::TestCaseData &) override {} - -#if 20305 <= DOCTEST_VERSION - // called when a test case is reentered because of unfinished subcases (safe to cache a pointer to the input) - virtual void test_case_reenter(const doctest::TestCaseData&) override {} -#endif - - // called when a test case has ended - virtual void test_case_end(const doctest::CurrentTestCaseStats &) override {} - - // called when an exception is thrown from the test case (or it crashes) - virtual void test_case_exception(const doctest::TestCaseException &) override {} - - // called whenever a subcase is entered (don't cache pointers to the input) - virtual void subcase_start(const doctest::SubcaseSignature &) override {} - - // called whenever a subcase is exited (don't cache pointers to the input) - virtual void subcase_end() override {} - - // called for each assert (don't cache pointers to the input) - virtual void log_assert(const doctest::AssertData &) override {} - - // called for each message (don't cache pointers to the input) - virtual void log_message(const doctest::MessageData &) override {} - - // called when a test case is skipped either because it doesn't pass the filters, has a skip decorator - // or isn't in the execution range (between first and last) (safe to cache a pointer to the input) - virtual void test_case_skipped(const doctest::TestCaseData &) override {} - - - }; - - struct DocTestApprovalListener : AbstractReporter { - TestName currentTest; - - // constructor has to accept the ContextOptions by ref as a single argument - explicit DocTestApprovalListener(const doctest::ContextOptions & /*in*/) { - } - - void test_case_start(const doctest::TestCaseData &testInfo) override { - - currentTest.sections.emplace_back(testInfo.m_name); - currentTest.setFileName(testInfo.m_file); - ApprovalTestNamer::currentTest(¤tTest); - } - - void test_case_end(const doctest::CurrentTestCaseStats & /*in*/) override { - - while (!currentTest.sections.empty()) { - currentTest.sections.pop_back(); - } - } - - void subcase_start(const doctest::SubcaseSignature &signature) override { - - currentTest.sections.emplace_back(signature.m_name); - } - - void subcase_end() override { - - currentTest.sections.pop_back(); - } - }; -} -} - -REGISTER_LISTENER("approvals", 0, ApprovalTests::DocTestApprovalListener); - - -#endif // APPROVALS_DOCTEST -// -#endif - - // ******************** From: GoogleConfiguration.h -#ifndef APPROVALTESTS_CPP_GOOGLECONFIGURATION_H -#define APPROVALTESTS_CPP_GOOGLECONFIGURATION_H - - -namespace ApprovalTests { -class GoogleConfiguration -{ -public: - - APPROVAL_TESTS_NO_DISCARD static bool addTestCaseNameRedundancyCheck(GoogleCustomizationsFactory::Comparator comparator) - { - return GoogleCustomizationsFactory::addTestCaseNameRedundancyCheck(comparator); - } - - - APPROVAL_TESTS_NO_DISCARD static bool addIgnorableTestCaseNameSuffix(std::string suffix) - { - return addTestCaseNameRedundancyCheck( createIgnorableTestCaseNameSuffixCheck(suffix) ); - } - - static GoogleCustomizationsFactory::Comparator createIgnorableTestCaseNameSuffixCheck( const std::string& suffix ) - { - return [suffix](std::string testFileNameWithExtension, std::string testCaseName) - { - if (testCaseName.length() <= suffix.length() || !StringUtils::endsWith(testCaseName, suffix)) - { - return false; - } - - auto withoutSuffix = testCaseName.substr(0, testCaseName.length() - suffix.length()); - auto withFileExtension = withoutSuffix + "."; - return StringUtils::contains(testFileNameWithExtension, withFileExtension); - }; - } -}; -} - -#endif - - // ******************** From: GoogleTestApprovals.h -#ifndef APPROVALTESTS_CPP_GOOGLTESTAPPPROVALS_H -#define APPROVALTESTS_CPP_GOOGLTESTAPPPROVALS_H - - -#ifdef APPROVALS_GOOGLETEST_EXISTING_MAIN -#define APPROVALS_GOOGLETEST -#endif - -#ifdef APPROVALS_GOOGLETEST - -// -#include "gtest/gtest.h" - -namespace ApprovalTests { -class GoogleTestListener : public testing::EmptyTestEventListener -{ - TestName currentTest; -public: - bool isDuplicate(std::string testFileNameWithExtension, std::string testCaseName) - { - for( auto check : GoogleCustomizationsFactory::getEquivalencyChecks()) - { - if (check(testFileNameWithExtension, testCaseName)) - { - return true; - } - } - return false; - } - - virtual void OnTestStart(const testing::TestInfo& testInfo) override - { - currentTest.setFileName(testInfo.file()); - currentTest.sections = {}; - if (! isDuplicate(currentTest.getFileName(), testInfo.test_case_name())) - { - currentTest.sections.emplace_back(testInfo.test_case_name()); - } - if (! std::string(testInfo.name()).empty()) - { - currentTest.sections.emplace_back(testInfo.name()); - } - - ApprovalTestNamer::currentTest(¤tTest); - } -}; - -inline void initializeApprovalTestsForGoogleTests() { - auto& listeners = testing::UnitTest::GetInstance()->listeners(); - listeners.Append(new GoogleTestListener); -} -} - -#ifndef APPROVALS_GOOGLETEST_EXISTING_MAIN -int main(int argc, char** argv) -{ - ::testing::InitGoogleTest(&argc, argv); - ApprovalTests::initializeApprovalTestsForGoogleTests(); - return RUN_ALL_TESTS(); -} -#endif //APPROVALS_GOOGLETEST_EXISTING_MAIN - -// -#endif -#endif - - // ******************** From: NamerFactory.h -#ifndef APPROVALTESTS_CPP_NAMERFACTORY_H -#define APPROVALTESTS_CPP_NAMERFACTORY_H - - - -namespace ApprovalTests { -struct NamerFactory -{ - static SectionNameDisposer appendToOutputFilename(const std::string& sectionName) - { - return SectionNameDisposer(ApprovalTestNamer::currentTest(), sectionName); - } -}; -} - -#endif - - // ******************** From: SeparateApprovedAndReceivedDirectoriesNamer.h -#ifndef APPROVALTESTS_CPP_SEPARATEAPPROVEDANDRECEIVEDDIRECTORIESNAMER_H -#define APPROVALTESTS_CPP_SEPARATEAPPROVEDANDRECEIVEDDIRECTORIESNAMER_H - - -namespace ApprovalTests { -class SeparateApprovedAndReceivedDirectoriesNamer : public ApprovalTestNamer -{ -public: - virtual ~SeparateApprovedAndReceivedDirectoriesNamer() = default; - - std::string getFullFileNameWithExtraDirectory(const std::string& approved, const std::string& extensionWithDot) const - { - std::string outputDirectory = getDirectory() + approved; - SystemUtils::ensureDirectoryExists(outputDirectory); - - std::string outputFile = getFileName() + "." + getTestName() + extensionWithDot; - - return outputDirectory + SystemUtils::getDirectorySeparator() + outputFile; - } - - virtual std::string getApprovedFile(std::string extensionWithDot) const override - { - return getFullFileNameWithExtraDirectory("approved", extensionWithDot); - } - - virtual std::string getReceivedFile(std::string extensionWithDot) const override - { - return getFullFileNameWithExtraDirectory("received", extensionWithDot); - } - - static DefaultNamerDisposer useAsDefaultNamer() - { - return Approvals::useAsDefaultNamer([](){return std::make_shared();}); - } - -}; -} - -#endif - - // ******************** From: AutoApproveIfMissingReporter.h -#ifndef APPROVALTESTS_CPP_AUTOAPPROVEIFMISSINGREPORTER_H -#define APPROVALTESTS_CPP_AUTOAPPROVEIFMISSINGREPORTER_H - - -namespace ApprovalTests { -class AutoApproveIfMissingReporter : public Reporter -{ -public: - bool report(std::string received, std::string approved) const override - { - if (FileUtils::fileExists(approved)) - { - return false; - } - - return AutoApproveReporter().report(received, approved); - } -}; -} - -#endif - - // ******************** From: BlockingReporter.h -#ifndef APPROVALTESTS_CPP_BLOCKINGREPORTER_H -#define APPROVALTESTS_CPP_BLOCKINGREPORTER_H - - - -namespace ApprovalTests { -class BlockingReporter : public Reporter -{ -private: - std::shared_ptr blocker; - - BlockingReporter() = delete; - -public: - explicit BlockingReporter( std::shared_ptr blocker ) : blocker(std::move(blocker)) - { - } - - static std::shared_ptr onMachineNamed( const std::string& machineName ) - { - auto machineBlocker = std::make_shared( MachineBlocker::onMachineNamed(machineName) ); - return std::make_shared(machineBlocker); - } - - static std::shared_ptr onMachinesNotNamed( const std::string& machineName ) - { - auto machineBlocker = std::make_shared( MachineBlocker::onMachinesNotNamed(machineName) ); - return std::make_shared(machineBlocker); - } - - virtual bool report(std::string , std::string ) const override - { - return blocker->isBlockingOnThisMachine(); - } -}; -} - -#endif - - // ******************** From: CIBuildOnlyReporterUtils.h -#ifndef APPROVALTESTS_CPP_CIBUILDONLYREPORTERUTILS_H -#define APPROVALTESTS_CPP_CIBUILDONLYREPORTERUTILS_H - - -namespace ApprovalTests -{ - namespace CIBuildOnlyReporterUtils - { - inline FrontLoadedReporterDisposer useAsFrontLoadedReporter(const std::shared_ptr& reporter) - { - return Approvals::useAsFrontLoadedReporter( - std::make_shared( reporter )); - } - } -} - -#endif - - // ******************** From: ClipboardReporter.h -#ifndef APPROVALTESTS_CPP_COMMANDLINEREPORTER_H -#define APPROVALTESTS_CPP_COMMANDLINEREPORTER_H - - - - -namespace ApprovalTests { -class ClipboardReporter : public Reporter { -public: - static std::string getCommandLineFor(const std::string& received, const std::string& approved, bool isWindows) - { - if (isWindows) { - return std::string("move /Y ") + "\"" + received + "\" \"" + approved + "\""; - } else { - return std::string("mv ") + "\"" + received + "\" \"" + approved + "\""; - } - } - - virtual bool report(std::string received, std::string approved) const override - { - copyToClipboard(getCommandLineFor(received, approved, SystemUtils::isWindowsOs())); - return true; - } - - static void copyToClipboard(const std::string& newClipboard) { - - - const std::string clipboardCommand = SystemUtils::isWindowsOs() ? "clip" : "pbclip"; - auto cmd = std::string("echo ") + newClipboard + " | " + clipboardCommand; - system(cmd.c_str()); - } -}; -} - -#endif - - // ******************** From: CombinationReporter.h -#ifndef APPROVALTESTS_CPP_COMBINATIONREPORTER_H -#define APPROVALTESTS_CPP_COMBINATIONREPORTER_H - - -namespace ApprovalTests { -class CombinationReporter : public Reporter -{ -private: - std::vector< std::unique_ptr > reporters; -public: - - explicit CombinationReporter(const std::vector& theReporters) - { - for(auto r : theReporters) - { - reporters.push_back(std::unique_ptr(r)); - } - } - - bool report(std::string received, std::string approved) const override - { - bool result = false; - for(auto& r : reporters) - { - result |= r->report(received, approved); - } - return result; - } -}; -} - -#endif - - // ******************** From: ExceptionCollector.h -#ifndef APPROVALTESTS_CPP_EXCEPTIONCOLLECTOR_H -#define APPROVALTESTS_CPP_EXCEPTIONCOLLECTOR_H - - -namespace ApprovalTests { -class ExceptionCollector -{ - std::vector exceptionMessages; - -public: - void gather(std::function functionThatThrows) - { - try - { - functionThatThrows(); - } - catch(const std::exception& e) - { - exceptionMessages.emplace_back(e.what()); - } - } - ~ExceptionCollector() - { - if ( ! exceptionMessages.empty()) - { - exceptionMessages.emplace_back("ERROR: Calling code forgot to call exceptionCollector.release()"); - } - release(); - } - - void release() - { - if (! exceptionMessages.empty()) - { - std::stringstream s; - s << exceptionMessages.size() << " exceptions were thrown:\n\n"; - int count = 1; - for( const auto& error : exceptionMessages) - { - s << count++ << ") " << error << '\n'; - } - exceptionMessages.clear(); - throw std::runtime_error(s.str()); - } - } -}; -} - -#endif - diff --git a/cpp/lib/CMakeLists.txt b/cpp/lib/CMakeLists.txt deleted file mode 100644 index b04d9a2a..00000000 --- a/cpp/lib/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -set(LIB_NAME lib) -add_library(${LIB_NAME} INTERFACE) -target_include_directories(${LIB_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) \ No newline at end of file diff --git a/cpp/lib/Catch.hpp b/cpp/lib/Catch.hpp deleted file mode 100644 index b4eccfc1..00000000 --- a/cpp/lib/Catch.hpp +++ /dev/null @@ -1,17597 +0,0 @@ -/* - * Catch v2.11.0 - * Generated: 2019-11-15 15:01:56.628356 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2019 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -// start catch.hpp - - -#define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 11 -#define CATCH_VERSION_PATCH 0 - -#ifdef __clang__ -# pragma clang system_header -#elif defined __GNUC__ -# pragma GCC system_header -#endif - -// start catch_suppress_warnings.h - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif -#elif defined __GNUC__ - // Because REQUIREs trigger GCC's -Wparentheses, and because still - // supported version of g++ have only buggy support for _Pragmas, - // Wparentheses have to be suppressed globally. -# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wpadded" -#endif -// end catch_suppress_warnings.h -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -# define CATCH_CONFIG_ALL_PARTS -#endif - -// In the impl file, we want to have access to all parts of the headers -// Can also be used to sanely support PCHs -#if defined(CATCH_CONFIG_ALL_PARTS) -# define CATCH_CONFIG_EXTERNAL_INTERFACES -# if defined(CATCH_CONFIG_DISABLE_MATCHERS) -# undef CATCH_CONFIG_DISABLE_MATCHERS -# endif -# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) -# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -# endif -#endif - -#if !defined(CATCH_CONFIG_IMPL_ONLY) -// start catch_platform.h - -#ifdef __APPLE__ -# include -# if TARGET_OS_OSX == 1 -# define CATCH_PLATFORM_MAC -# elif TARGET_OS_IPHONE == 1 -# define CATCH_PLATFORM_IPHONE -# endif - -#elif defined(linux) || defined(__linux) || defined(__linux__) -# define CATCH_PLATFORM_LINUX - -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) -# define CATCH_PLATFORM_WINDOWS -#endif - -// end catch_platform.h - -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// start catch_user_interfaces.h - -namespace Catch { - unsigned int rngSeed(); -} - -// end catch_user_interfaces.h -// start catch_tag_alias_autoregistrar.h - -// start catch_common.h - -// start catch_compiler_capabilities.h - -// Detect a number of compiler features - by compiler -// The following features are defined: -// -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -#ifdef __cplusplus - -# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -# define CATCH_CPP14_OR_GREATER -# endif - -# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CATCH_CPP17_OR_GREATER -# endif - -#endif - -#if defined(CATCH_CPP17_OR_GREATER) -# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -#endif - -// We have to avoid both ICC and Clang, because they try to mask themselves -// as gcc, and we want only GCC in this block -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) -#endif - -#if defined(__clang__) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) - -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ - _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") - -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) - -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// Assume that non-Windows platforms support posix signals by default -#if !defined(CATCH_PLATFORM_WINDOWS) - #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS -#endif - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) - #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -#endif - -#ifdef __OS400__ -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Android somehow still does not support std::to_string -#if defined(__ANDROID__) -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING -# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Not all Windows environments support SEH properly -#if defined(__MINGW32__) -# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH -#endif - -//////////////////////////////////////////////////////////////////////////////// -// PS4 -#if defined(__ORBIS__) -# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -# define _BSD_SOURCE -// some versions of cygwin (most) do not support std::to_string. Use the libstd check. -// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 -# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ - && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) - -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING - -# endif -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#if defined(_MSC_VER) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) - -# if _MSC_VER >= 1900 // Visual Studio 2015 or newer -# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -# endif - -// Universal Windows platform does not support SEH -// Or console colours (or console at all...) -# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -# define CATCH_CONFIG_COLOUR_NONE -# else -# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH -# endif - -// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ -// _MSVC_TRADITIONAL == 0 means new conformant preprocessor -// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor -# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -# endif -#endif // _MSC_VER - -#if defined(_REENTRANT) || defined(_MSC_VER) -// Enable async processing, as -pthread is specified or no additional linking is required -# define CATCH_INTERNAL_CONFIG_USE_ASYNC -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// Check if we are compiled with -fno-exceptions or equivalent -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) -# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED -#endif - -//////////////////////////////////////////////////////////////////////////////// -// DJGPP -#ifdef __DJGPP__ -# define CATCH_INTERNAL_CONFIG_NO_WCHAR -#endif // __DJGPP__ - -//////////////////////////////////////////////////////////////////////////////// -// Embarcadero C++Build -#if defined(__BORLANDC__) - #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// Use of __COUNTER__ is suppressed during code analysis in -// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly -// handled by it. -// Otherwise all supported compilers support COUNTER macro, -// but user still might want to turn it off -#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) - #define CATCH_INTERNAL_CONFIG_COUNTER -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// RTX is a special version of Windows that is real time. -// This means that it is detected as Windows, but does not provide -// the same set of capabilities as real Windows does. -#if defined(UNDER_RTSS) || defined(RTX64_BUILD) - #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH - #define CATCH_INTERNAL_CONFIG_NO_ASYNC - #define CATCH_CONFIG_COLOUR_NONE -#endif - -#if defined(__UCLIBC__) -#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Various stdlib support checks that require __has_include -#if defined(__has_include) - // Check if string_view is available and usable - #if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW - #endif - - // Check if optional is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if byte is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_BYTE - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if variant is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # if defined(__clang__) && (__clang_major__ < 8) - // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 - // fix should be in clang 8, workaround in libstdc++ 8.2 - # include - # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # define CATCH_CONFIG_NO_CPP17_VARIANT - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__clang__) && (__clang_major__ < 8) - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // defined(__has_include) - -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) -# define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) -# define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. -#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_CONFIG_POSIX_SIGNALS -#endif -// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. -#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) -# define CATCH_CONFIG_WCHAR -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) -# define CATCH_CONFIG_CPP11_TO_STRING -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) -# define CATCH_CONFIG_CPP17_OPTIONAL -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) -# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) -# define CATCH_CONFIG_CPP17_STRING_VIEW -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) -# define CATCH_CONFIG_CPP17_VARIANT -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) -# define CATCH_CONFIG_CPP17_BYTE -#endif - -#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) -# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) -# define CATCH_CONFIG_NEW_CAPTURE -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -# define CATCH_CONFIG_DISABLE_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) -# define CATCH_CONFIG_POLYFILL_ISNAN -#endif - -#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) -# define CATCH_CONFIG_USE_ASYNC -#endif - -#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) -# define CATCH_CONFIG_ANDROID_LOGWRITE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) -# define CATCH_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Even if we do not think the compiler has that warning, we still have -// to provide a macro that can be used by the code. -#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS -#endif - -#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#elif defined(__clang__) && (__clang_major__ < 5) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -#define CATCH_TRY if ((true)) -#define CATCH_CATCH_ALL if ((false)) -#define CATCH_CATCH_ANON(type) if ((false)) -#else -#define CATCH_TRY try -#define CATCH_CATCH_ALL catch (...) -#define CATCH_CATCH_ANON(type) catch (type) -#endif - -#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) -#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#endif - -// end catch_compiler_capabilities.h -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - -#include -#include -#include - -// We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy {}; -std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); - -namespace Catch { - - struct CaseSensitive { enum Choice { - Yes, - No - }; }; - - class NonCopyable { - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; - - protected: - NonCopyable(); - virtual ~NonCopyable(); - }; - - struct SourceLineInfo { - - SourceLineInfo() = delete; - SourceLineInfo( char const* _file, std::size_t _line ) noexcept - : file( _file ), - line( _line ) - {} - - SourceLineInfo( SourceLineInfo const& other ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo( SourceLineInfo&& ) noexcept = default; - SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; - - bool empty() const noexcept { return file[0] == '\0'; } - bool operator == ( SourceLineInfo const& other ) const noexcept; - bool operator < ( SourceLineInfo const& other ) const noexcept; - - char const* file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // Bring in operator<< from global namespace into Catch namespace - // This is necessary because the overload of operator<< above makes - // lookup stop at namespace Catch - using ::operator<<; - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() const; - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO \ - ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) - -// end catch_common.h -namespace Catch { - - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - -// end catch_tag_alias_autoregistrar.h -// start catch_test_registry.h - -// start catch_interfaces_testcase.h - -#include - -namespace Catch { - - class TestSpec; - - struct ITestInvoker { - virtual void invoke () const = 0; - virtual ~ITestInvoker(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool isThrowSafe( TestCase const& testCase, IConfig const& config ); - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} - -// end catch_interfaces_testcase.h -// start catch_stringref.h - -#include -#include -#include -#include - -namespace Catch { - - /// A non-owning string class (similar to the forthcoming std::string_view) - /// Note that, because a StringRef may be a substring of another string, - /// it may not be null terminated. - class StringRef { - public: - using size_type = std::size_t; - using const_iterator = const char*; - - private: - static constexpr char const* const s_empty = ""; - - char const* m_start = s_empty; - size_type m_size = 0; - - public: // construction - constexpr StringRef() noexcept = default; - - StringRef( char const* rawChars ) noexcept; - - constexpr StringRef( char const* rawChars, size_type size ) noexcept - : m_start( rawChars ), - m_size( size ) - {} - - StringRef( std::string const& stdString ) noexcept - : m_start( stdString.c_str() ), - m_size( stdString.size() ) - {} - - explicit operator std::string() const { - return std::string(m_start, m_size); - } - - public: // operators - auto operator == ( StringRef const& other ) const noexcept -> bool; - auto operator != (StringRef const& other) const noexcept -> bool { - return !(*this == other); - } - - auto operator[] ( size_type index ) const noexcept -> char { - assert(index < m_size); - return m_start[index]; - } - - public: // named queries - constexpr auto empty() const noexcept -> bool { - return m_size == 0; - } - constexpr auto size() const noexcept -> size_type { - return m_size; - } - - // Returns the current start pointer. If the StringRef is not - // null-terminated, throws std::domain_exception - auto c_str() const -> char const*; - - public: // substrings and searches - // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, size()). - // If start > size(), then the substring is empty. - auto substr( size_type start, size_type length ) const noexcept -> StringRef; - - // Returns the current start pointer. May not be null-terminated. - auto data() const noexcept -> char const*; - - constexpr auto isNullTerminated() const noexcept -> bool { - return m_start[m_size] == '\0'; - } - - public: // iterators - constexpr const_iterator begin() const { return m_start; } - constexpr const_iterator end() const { return m_start + m_size; } - }; - - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; - auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; - - constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { - return StringRef( rawChars, size ); - } -} // namespace Catch - -constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { - return Catch::StringRef( rawChars, size ); -} - -// end catch_stringref.h -// start catch_preprocessor.hpp - - -#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ -#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) - -#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ -// MSVC needs more evaluations -#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) -#else -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) -#endif - -#define CATCH_REC_END(...) -#define CATCH_REC_OUT - -#define CATCH_EMPTY() -#define CATCH_DEFER(id) id CATCH_EMPTY() - -#define CATCH_REC_GET_END2() 0, CATCH_REC_END -#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 -#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 -#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT -#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) -#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) - -#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) - -#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) - -// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, -// and passes userdata as the first parameter to each invocation, -// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) -#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) -#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ -#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ -#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) -#else -// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) -#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) -#endif - -#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ -#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) - -#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) - -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) -#else -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) -#endif - -#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ - CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) - -#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) -#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) -#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) -#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) -#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) -#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) -#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _4, _5, _6) -#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) -#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) -#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) -#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) - -#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N - -#define INTERNAL_CATCH_TYPE_GEN\ - template struct TypeList {};\ - template\ - constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ - template class...> struct TemplateTypeList{};\ - template class...Cs>\ - constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ - template\ - struct append;\ - template\ - struct rewrap;\ - template class, typename...>\ - struct create;\ - template class, typename>\ - struct convert;\ - \ - template \ - struct append { using type = T; };\ - template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ - struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ - template< template class L1, typename...E1, typename...Rest>\ - struct append, TypeList, Rest...> { using type = L1; };\ - \ - template< template class Container, template class List, typename...elems>\ - struct rewrap, List> { using type = TypeList>; };\ - template< template class Container, template class List, class...Elems, typename...Elements>\ - struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ - \ - template