diff --git a/Tennis/cpp/defactored1/Makefile b/Tennis/cpp/defactored1/Makefile deleted file mode 100644 index a97fcd8b..00000000 --- a/Tennis/cpp/defactored1/Makefile +++ /dev/null @@ -1,75 +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, except GTEST_HEADERS, which you can use in your own targets -# but shouldn't modify. - -# Points to the root of Google Test, relative to where this file is. -# Remember to tweak this if you move this file. -GTEST_DIR = gtest - -# Where to find user code. -USER_DIR = . - -# Flags passed to the preprocessor. -CPPFLAGS += -I$(GTEST_DIR)/include - -# Flags passed to the C++ compiler. -CXXFLAGS += -g -Wall -Wextra - -# All tests produced by this Makefile. Remember to add new tests you -# created to the list. -TESTS = Tennis - -# All Google Test headers. Usually you shouldn't change this -# definition. -GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ - $(GTEST_DIR)/include/gtest/internal/*.h - -# House-keeping build targets. - -all : $(TESTS) - -clean : - rm -f $(TESTS) gtest.a gtest_main.a *.o - -# Builds gtest.a and gtest_main.a. - -# Usually you shouldn't tweak such internal variables, indicated by a -# trailing _. -GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) - -# For simplicity and to avoid depending on Google Test's -# implementation details, the dependencies specified below are -# conservative and not optimized. This is fine as Google Test -# compiles fast and for ordinary users its source rarely changes. -gtest-all.o : $(GTEST_SRCS_) - $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ - $(GTEST_DIR)/src/gtest-all.cc - -gtest_main.o : $(GTEST_SRCS_) - $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ - $(GTEST_DIR)/src/gtest_main.cc - -gtest.a : gtest-all.o - $(AR) $(ARFLAGS) $@ $^ - -gtest_main.a : gtest-all.o gtest_main.o - $(AR) $(ARFLAGS) $@ $^ - -# Builds a sample test. A test should link with either gtest.a or -# gtest_main.a, depending on whether it defines its own main() -# function. - -Tennis.o : $(USER_DIR)/Tennis.cc \ - $(GTEST_HEADERS) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/Tennis.cc - -Tennis : Tennis.o gtest_main.a - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ diff --git a/Tennis/cpp/defactored1/README b/Tennis/cpp/defactored1/README deleted file mode 100644 index 59cd984e..00000000 --- a/Tennis/cpp/defactored1/README +++ /dev/null @@ -1,14 +0,0 @@ -These files were created: - README is what you are currently reading - run-once.sh runs your tests once - run-endless.sh runs your tests endlessly via run-once.sh - -Run run-endless.sh and start your kata. (On Mac/Linux you have to call ./run-endless.sh.) - -Assumptions: - - make and a C++ compiler (like gcc) is installed on your system and is in the PATH - - The GTest framework is in the directory gtest. - - If your IDE does the compilation and linking, you should remove the first 3 lines - in the run-once.sh file. - -The support for C++/GTest was contributed by Stefan Roock. diff --git a/Tennis/cpp/defactored1/Tennis.cc b/Tennis/cpp/defactored1/Tennis.cc deleted file mode 100644 index 0f340f5f..00000000 --- a/Tennis/cpp/defactored1/Tennis.cc +++ /dev/null @@ -1,227 +0,0 @@ -#include - -const std::string tennis_score(int p1Score, int p2Score) { - std::string score = ""; - int tempScore=0; - if (p1Score==p2Score) - { - switch (p1Score) - { - case 0: - score = "Love-All"; - break; - case 1: - score = "Fifteen-All"; - break; - case 2: - score = "Thirty-All"; - break; - case 3: - score = "Deuce"; - break; - default: - score = "Deuce"; - break; - - } - } - else if (p1Score>=4 || p2Score>=4) - { - int minusResult = p1Score-p2Score; - if (minusResult==1) score ="Advantage player1"; - else if (minusResult ==-1) score ="Advantage player2"; - else if (minusResult>=2) score = "Win for player1"; - else score ="Win for player2"; - } - else - { - for (int i=1; i<3; i++) - { - if (i==1) tempScore = p1Score; - else { score+="-"; tempScore = p2Score;} - switch(tempScore) - { - case 0: - score+="Love"; - break; - case 1: - score+="Fifteen"; - break; - case 2: - score+="Thirty"; - break; - case 3: - score+="Forty"; - break; - } - } - } - return score; - -} - -TEST(TennisTest, LoveAll_0_0) { - EXPECT_EQ("Love-All", tennis_score(0, 0)); -} - - -TEST(TennisTest, FifteenAll_1_1) { - EXPECT_EQ("Fifteen-All", tennis_score(1, 1)); -} - - -TEST(TennisTest, ThirtyAll_2_2) { - EXPECT_EQ("Thirty-All", tennis_score(2, 2)); -} - - -TEST(TennisTest, Deuce_3_3) { - EXPECT_EQ("Deuce", tennis_score(3, 3)); -} - - -TEST(TennisTest, Deuce_4_4) { - EXPECT_EQ("Deuce", tennis_score(4, 4)); -} - - -TEST(TennisTest, FifteenLove_1_0) { - EXPECT_EQ("Fifteen-Love", tennis_score(1, 0)); -} - - -TEST(TennisTest, LoveFifteen_0_1) { - EXPECT_EQ("Love-Fifteen", tennis_score(0, 1)); -} - - -TEST(TennisTest, ThirtyLove_2_0) { - EXPECT_EQ("Thirty-Love", tennis_score(2, 0)); -} - - -TEST(TennisTest, LoveThirty_0_2) { - EXPECT_EQ("Love-Thirty", tennis_score(0, 2)); -} - - -TEST(TennisTest, FortyLove_3_0) { - EXPECT_EQ("Forty-Love", tennis_score(3, 0)); -} - - -TEST(TennisTest, LoveForty_0_3) { - EXPECT_EQ("Love-Forty", tennis_score(0, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_0) { - EXPECT_EQ("Win for player1", tennis_score(4, 0)); -} - - -TEST(TennisTest, Winforplayer2_0_4) { - EXPECT_EQ("Win for player2", tennis_score(0, 4)); -} - - -TEST(TennisTest, ThirtyFifteen_2_1) { - EXPECT_EQ("Thirty-Fifteen", tennis_score(2, 1)); -} - - -TEST(TennisTest, FifteenThirty_1_2) { - EXPECT_EQ("Fifteen-Thirty", tennis_score(1, 2)); -} - - -TEST(TennisTest, FortyFifteen_3_1) { - EXPECT_EQ("Forty-Fifteen", tennis_score(3, 1)); -} - - -TEST(TennisTest, FifteenForty_1_3) { - EXPECT_EQ("Fifteen-Forty", tennis_score(1, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_1) { - EXPECT_EQ("Win for player1", tennis_score(4, 1)); -} - - -TEST(TennisTest, Winforplayer2_1_4) { - EXPECT_EQ("Win for player2", tennis_score(1, 4)); -} - - -TEST(TennisTest, FortyThirty_3_2) { - EXPECT_EQ("Forty-Thirty", tennis_score(3, 2)); -} - - -TEST(TennisTest, ThirtyForty_2_3) { - EXPECT_EQ("Thirty-Forty", tennis_score(2, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_2) { - EXPECT_EQ("Win for player1", tennis_score(4, 2)); -} - - -TEST(TennisTest, Winforplayer2_2_4) { - EXPECT_EQ("Win for player2", tennis_score(2, 4)); -} - - -TEST(TennisTest, Advantageplayer1_4_3) { - EXPECT_EQ("Advantage player1", tennis_score(4, 3)); -} - - -TEST(TennisTest, Advantageplayer2_3_4) { - EXPECT_EQ("Advantage player2", tennis_score(3, 4)); -} - - -TEST(TennisTest, Advantageplayer1_5_4) { - EXPECT_EQ("Advantage player1", tennis_score(5, 4)); -} - - -TEST(TennisTest, Advantageplayer2_4_5) { - EXPECT_EQ("Advantage player2", tennis_score(4, 5)); -} - - -TEST(TennisTest, Advantageplayer1_15_14) { - EXPECT_EQ("Advantage player1", tennis_score(15, 14)); -} - - -TEST(TennisTest, Advantageplayer2_14_15) { - EXPECT_EQ("Advantage player2", tennis_score(14, 15)); -} - - -TEST(TennisTest, Winforplayer1_6_4) { - EXPECT_EQ("Win for player1", tennis_score(6, 4)); -} - - -TEST(TennisTest, Winforplayer2_4_6) { - EXPECT_EQ("Win for player2", tennis_score(4, 6)); -} - - -TEST(TennisTest, Winforplayer1_16_14) { - EXPECT_EQ("Win for player1", tennis_score(16, 14)); -} - - -TEST(TennisTest, Winforplayer2_14_16) { - EXPECT_EQ("Win for player2", tennis_score(14, 16)); -} - - diff --git a/Tennis/cpp/defactored1/run-once.sh b/Tennis/cpp/defactored1/run-once.sh deleted file mode 100755 index 1b1bffef..00000000 --- a/Tennis/cpp/defactored1/run-once.sh +++ /dev/null @@ -1,4 +0,0 @@ -rm Tennis -rm Tennis.o -make -./Tennis \ No newline at end of file diff --git a/Tennis/cpp/defactored2/Makefile b/Tennis/cpp/defactored2/Makefile deleted file mode 100644 index a97fcd8b..00000000 --- a/Tennis/cpp/defactored2/Makefile +++ /dev/null @@ -1,75 +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, except GTEST_HEADERS, which you can use in your own targets -# but shouldn't modify. - -# Points to the root of Google Test, relative to where this file is. -# Remember to tweak this if you move this file. -GTEST_DIR = gtest - -# Where to find user code. -USER_DIR = . - -# Flags passed to the preprocessor. -CPPFLAGS += -I$(GTEST_DIR)/include - -# Flags passed to the C++ compiler. -CXXFLAGS += -g -Wall -Wextra - -# All tests produced by this Makefile. Remember to add new tests you -# created to the list. -TESTS = Tennis - -# All Google Test headers. Usually you shouldn't change this -# definition. -GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ - $(GTEST_DIR)/include/gtest/internal/*.h - -# House-keeping build targets. - -all : $(TESTS) - -clean : - rm -f $(TESTS) gtest.a gtest_main.a *.o - -# Builds gtest.a and gtest_main.a. - -# Usually you shouldn't tweak such internal variables, indicated by a -# trailing _. -GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) - -# For simplicity and to avoid depending on Google Test's -# implementation details, the dependencies specified below are -# conservative and not optimized. This is fine as Google Test -# compiles fast and for ordinary users its source rarely changes. -gtest-all.o : $(GTEST_SRCS_) - $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ - $(GTEST_DIR)/src/gtest-all.cc - -gtest_main.o : $(GTEST_SRCS_) - $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ - $(GTEST_DIR)/src/gtest_main.cc - -gtest.a : gtest-all.o - $(AR) $(ARFLAGS) $@ $^ - -gtest_main.a : gtest-all.o gtest_main.o - $(AR) $(ARFLAGS) $@ $^ - -# Builds a sample test. A test should link with either gtest.a or -# gtest_main.a, depending on whether it defines its own main() -# function. - -Tennis.o : $(USER_DIR)/Tennis.cc \ - $(GTEST_HEADERS) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/Tennis.cc - -Tennis : Tennis.o gtest_main.a - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ diff --git a/Tennis/cpp/defactored2/README b/Tennis/cpp/defactored2/README deleted file mode 100644 index 59cd984e..00000000 --- a/Tennis/cpp/defactored2/README +++ /dev/null @@ -1,14 +0,0 @@ -These files were created: - README is what you are currently reading - run-once.sh runs your tests once - run-endless.sh runs your tests endlessly via run-once.sh - -Run run-endless.sh and start your kata. (On Mac/Linux you have to call ./run-endless.sh.) - -Assumptions: - - make and a C++ compiler (like gcc) is installed on your system and is in the PATH - - The GTest framework is in the directory gtest. - - If your IDE does the compilation and linking, you should remove the first 3 lines - in the run-once.sh file. - -The support for C++/GTest was contributed by Stefan Roock. diff --git a/Tennis/cpp/defactored2/Tennis.cc b/Tennis/cpp/defactored2/Tennis.cc deleted file mode 100644 index 8ff36536..00000000 --- a/Tennis/cpp/defactored2/Tennis.cc +++ /dev/null @@ -1,258 +0,0 @@ -#include - -const std::string tennis_score(int p1Score, int p2Score) { - std::string score = ""; - std::string P1res = ""; - std::string P2res = ""; - if (p1Score == p2Score && p1Score < 4) - { - if (p1Score==0) - score = "Love"; - if (p1Score==1) - score = "Fifteen"; - if (p1Score==2) - score = "Thirty"; - if (p1Score==3) - score = "Forty"; - score += "-All"; - } - if (p1Score==p2Score && p1Score>2) - score = "Deuce"; - - if (p1Score > 0 && p2Score==0) - { - if (p1Score==1) - P1res = "Fifteen"; - if (p1Score==2) - P1res = "Thirty"; - if (p1Score==3) - P1res = "Forty"; - - P2res = "Love"; - score = P1res + "-" + P2res; - } - if (p2Score > 0 && p1Score==0) - { - if (p2Score==1) - P2res = "Fifteen"; - if (p2Score==2) - P2res = "Thirty"; - if (p2Score==3) - P2res = "Forty"; - - P1res = "Love"; - score = P1res + "-" + P2res; - } - - if (p1Score>p2Score && p1Score < 4) - { - if (p1Score==2) - P1res="Thirty"; - if (p1Score==3) - P1res="Forty"; - if (p2Score==1) - P2res="Fifteen"; - if (p2Score==2) - P2res="Thirty"; - score = P1res + "-" + P2res; - } - if (p2Score>p1Score && p2Score < 4) - { - if (p2Score==2) - P2res="Thirty"; - if (p2Score==3) - P2res="Forty"; - if (p1Score==1) - P1res="Fifteen"; - if (p1Score==2) - P1res="Thirty"; - score = P1res + "-" + P2res; - } - - if (p1Score > p2Score && p2Score >= 3) - { - score = "Advantage player1"; - } - - if (p2Score > p1Score && p1Score >= 3) - { - score = "Advantage player2"; - } - - if (p1Score>=4 && p2Score>=0 && (p1Score-p2Score)>=2) - { - score = "Win for player1"; - } - if (p2Score>=4 && p1Score>=0 && (p2Score-p1Score)>=2) - { - score = "Win for player2"; - } - return score; - -} - -TEST(TennisTest, LoveAll_0_0) { - EXPECT_EQ("Love-All", tennis_score(0, 0)); -} - - -TEST(TennisTest, FifteenAll_1_1) { - EXPECT_EQ("Fifteen-All", tennis_score(1, 1)); -} - - -TEST(TennisTest, ThirtyAll_2_2) { - EXPECT_EQ("Thirty-All", tennis_score(2, 2)); -} - - -TEST(TennisTest, Deuce_3_3) { - EXPECT_EQ("Deuce", tennis_score(3, 3)); -} - - -TEST(TennisTest, Deuce_4_4) { - EXPECT_EQ("Deuce", tennis_score(4, 4)); -} - - -TEST(TennisTest, FifteenLove_1_0) { - EXPECT_EQ("Fifteen-Love", tennis_score(1, 0)); -} - - -TEST(TennisTest, LoveFifteen_0_1) { - EXPECT_EQ("Love-Fifteen", tennis_score(0, 1)); -} - - -TEST(TennisTest, ThirtyLove_2_0) { - EXPECT_EQ("Thirty-Love", tennis_score(2, 0)); -} - - -TEST(TennisTest, LoveThirty_0_2) { - EXPECT_EQ("Love-Thirty", tennis_score(0, 2)); -} - - -TEST(TennisTest, FortyLove_3_0) { - EXPECT_EQ("Forty-Love", tennis_score(3, 0)); -} - - -TEST(TennisTest, LoveForty_0_3) { - EXPECT_EQ("Love-Forty", tennis_score(0, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_0) { - EXPECT_EQ("Win for player1", tennis_score(4, 0)); -} - - -TEST(TennisTest, Winforplayer2_0_4) { - EXPECT_EQ("Win for player2", tennis_score(0, 4)); -} - - -TEST(TennisTest, ThirtyFifteen_2_1) { - EXPECT_EQ("Thirty-Fifteen", tennis_score(2, 1)); -} - - -TEST(TennisTest, FifteenThirty_1_2) { - EXPECT_EQ("Fifteen-Thirty", tennis_score(1, 2)); -} - - -TEST(TennisTest, FortyFifteen_3_1) { - EXPECT_EQ("Forty-Fifteen", tennis_score(3, 1)); -} - - -TEST(TennisTest, FifteenForty_1_3) { - EXPECT_EQ("Fifteen-Forty", tennis_score(1, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_1) { - EXPECT_EQ("Win for player1", tennis_score(4, 1)); -} - - -TEST(TennisTest, Winforplayer2_1_4) { - EXPECT_EQ("Win for player2", tennis_score(1, 4)); -} - - -TEST(TennisTest, FortyThirty_3_2) { - EXPECT_EQ("Forty-Thirty", tennis_score(3, 2)); -} - - -TEST(TennisTest, ThirtyForty_2_3) { - EXPECT_EQ("Thirty-Forty", tennis_score(2, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_2) { - EXPECT_EQ("Win for player1", tennis_score(4, 2)); -} - - -TEST(TennisTest, Winforplayer2_2_4) { - EXPECT_EQ("Win for player2", tennis_score(2, 4)); -} - - -TEST(TennisTest, Advantageplayer1_4_3) { - EXPECT_EQ("Advantage player1", tennis_score(4, 3)); -} - - -TEST(TennisTest, Advantageplayer2_3_4) { - EXPECT_EQ("Advantage player2", tennis_score(3, 4)); -} - - -TEST(TennisTest, Advantageplayer1_5_4) { - EXPECT_EQ("Advantage player1", tennis_score(5, 4)); -} - - -TEST(TennisTest, Advantageplayer2_4_5) { - EXPECT_EQ("Advantage player2", tennis_score(4, 5)); -} - - -TEST(TennisTest, Advantageplayer1_15_14) { - EXPECT_EQ("Advantage player1", tennis_score(15, 14)); -} - - -TEST(TennisTest, Advantageplayer2_14_15) { - EXPECT_EQ("Advantage player2", tennis_score(14, 15)); -} - - -TEST(TennisTest, Winforplayer1_6_4) { - EXPECT_EQ("Win for player1", tennis_score(6, 4)); -} - - -TEST(TennisTest, Winforplayer2_4_6) { - EXPECT_EQ("Win for player2", tennis_score(4, 6)); -} - - -TEST(TennisTest, Winforplayer1_16_14) { - EXPECT_EQ("Win for player1", tennis_score(16, 14)); -} - - -TEST(TennisTest, Winforplayer2_14_16) { - EXPECT_EQ("Win for player2", tennis_score(14, 16)); -} - - diff --git a/Tennis/cpp/defactored2/run-once.sh b/Tennis/cpp/defactored2/run-once.sh deleted file mode 100755 index 1b1bffef..00000000 --- a/Tennis/cpp/defactored2/run-once.sh +++ /dev/null @@ -1,4 +0,0 @@ -rm Tennis -rm Tennis.o -make -./Tennis \ No newline at end of file diff --git a/Tennis/cpp/defactored3/Makefile b/Tennis/cpp/defactored3/Makefile deleted file mode 100644 index a97fcd8b..00000000 --- a/Tennis/cpp/defactored3/Makefile +++ /dev/null @@ -1,75 +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, except GTEST_HEADERS, which you can use in your own targets -# but shouldn't modify. - -# Points to the root of Google Test, relative to where this file is. -# Remember to tweak this if you move this file. -GTEST_DIR = gtest - -# Where to find user code. -USER_DIR = . - -# Flags passed to the preprocessor. -CPPFLAGS += -I$(GTEST_DIR)/include - -# Flags passed to the C++ compiler. -CXXFLAGS += -g -Wall -Wextra - -# All tests produced by this Makefile. Remember to add new tests you -# created to the list. -TESTS = Tennis - -# All Google Test headers. Usually you shouldn't change this -# definition. -GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ - $(GTEST_DIR)/include/gtest/internal/*.h - -# House-keeping build targets. - -all : $(TESTS) - -clean : - rm -f $(TESTS) gtest.a gtest_main.a *.o - -# Builds gtest.a and gtest_main.a. - -# Usually you shouldn't tweak such internal variables, indicated by a -# trailing _. -GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) - -# For simplicity and to avoid depending on Google Test's -# implementation details, the dependencies specified below are -# conservative and not optimized. This is fine as Google Test -# compiles fast and for ordinary users its source rarely changes. -gtest-all.o : $(GTEST_SRCS_) - $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ - $(GTEST_DIR)/src/gtest-all.cc - -gtest_main.o : $(GTEST_SRCS_) - $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ - $(GTEST_DIR)/src/gtest_main.cc - -gtest.a : gtest-all.o - $(AR) $(ARFLAGS) $@ $^ - -gtest_main.a : gtest-all.o gtest_main.o - $(AR) $(ARFLAGS) $@ $^ - -# Builds a sample test. A test should link with either gtest.a or -# gtest_main.a, depending on whether it defines its own main() -# function. - -Tennis.o : $(USER_DIR)/Tennis.cc \ - $(GTEST_HEADERS) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/Tennis.cc - -Tennis : Tennis.o gtest_main.a - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ diff --git a/Tennis/cpp/defactored3/README b/Tennis/cpp/defactored3/README deleted file mode 100644 index 59cd984e..00000000 --- a/Tennis/cpp/defactored3/README +++ /dev/null @@ -1,14 +0,0 @@ -These files were created: - README is what you are currently reading - run-once.sh runs your tests once - run-endless.sh runs your tests endlessly via run-once.sh - -Run run-endless.sh and start your kata. (On Mac/Linux you have to call ./run-endless.sh.) - -Assumptions: - - make and a C++ compiler (like gcc) is installed on your system and is in the PATH - - The GTest framework is in the directory gtest. - - If your IDE does the compilation and linking, you should remove the first 3 lines - in the run-once.sh file. - -The support for C++/GTest was contributed by Stefan Roock. diff --git a/Tennis/cpp/defactored3/Tennis.cc b/Tennis/cpp/defactored3/Tennis.cc deleted file mode 100644 index 4cce3d6a..00000000 --- a/Tennis/cpp/defactored3/Tennis.cc +++ /dev/null @@ -1,183 +0,0 @@ -#include - -const std::string tennis_score(int p1, int p2) { - std::string s; - std::string p1N = "player1"; - std::string p2N = "player2"; - if (p1 < 4 && p2 < 4 && !(p1 == 3 && p2 == 3)) { - std::string p[4] = {"Love", "Fifteen", "Thirty", "Forty"}; - s = p[p1]; - return (p1 == p2) ? s + "-All" : s + "-" + p[p2]; - } else { - if (p1 == p2) - return "Deuce"; - s = p1 > p2 ? p1N : p2N; - return ((p1-p2)*(p1-p2) == 1) ? "Advantage " + s : "Win for " + s; - } -} - -TEST(TennisTest, LoveAll_0_0) { - EXPECT_EQ("Love-All", tennis_score(0, 0)); -} - - -TEST(TennisTest, FifteenAll_1_1) { - EXPECT_EQ("Fifteen-All", tennis_score(1, 1)); -} - - -TEST(TennisTest, ThirtyAll_2_2) { - EXPECT_EQ("Thirty-All", tennis_score(2, 2)); -} - - -TEST(TennisTest, Deuce_3_3) { - EXPECT_EQ("Deuce", tennis_score(3, 3)); -} - - -TEST(TennisTest, Deuce_4_4) { - EXPECT_EQ("Deuce", tennis_score(4, 4)); -} - - -TEST(TennisTest, FifteenLove_1_0) { - EXPECT_EQ("Fifteen-Love", tennis_score(1, 0)); -} - - -TEST(TennisTest, LoveFifteen_0_1) { - EXPECT_EQ("Love-Fifteen", tennis_score(0, 1)); -} - - -TEST(TennisTest, ThirtyLove_2_0) { - EXPECT_EQ("Thirty-Love", tennis_score(2, 0)); -} - - -TEST(TennisTest, LoveThirty_0_2) { - EXPECT_EQ("Love-Thirty", tennis_score(0, 2)); -} - - -TEST(TennisTest, FortyLove_3_0) { - EXPECT_EQ("Forty-Love", tennis_score(3, 0)); -} - - -TEST(TennisTest, LoveForty_0_3) { - EXPECT_EQ("Love-Forty", tennis_score(0, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_0) { - EXPECT_EQ("Win for player1", tennis_score(4, 0)); -} - - -TEST(TennisTest, Winforplayer2_0_4) { - EXPECT_EQ("Win for player2", tennis_score(0, 4)); -} - - -TEST(TennisTest, ThirtyFifteen_2_1) { - EXPECT_EQ("Thirty-Fifteen", tennis_score(2, 1)); -} - - -TEST(TennisTest, FifteenThirty_1_2) { - EXPECT_EQ("Fifteen-Thirty", tennis_score(1, 2)); -} - - -TEST(TennisTest, FortyFifteen_3_1) { - EXPECT_EQ("Forty-Fifteen", tennis_score(3, 1)); -} - - -TEST(TennisTest, FifteenForty_1_3) { - EXPECT_EQ("Fifteen-Forty", tennis_score(1, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_1) { - EXPECT_EQ("Win for player1", tennis_score(4, 1)); -} - - -TEST(TennisTest, Winforplayer2_1_4) { - EXPECT_EQ("Win for player2", tennis_score(1, 4)); -} - - -TEST(TennisTest, FortyThirty_3_2) { - EXPECT_EQ("Forty-Thirty", tennis_score(3, 2)); -} - - -TEST(TennisTest, ThirtyForty_2_3) { - EXPECT_EQ("Thirty-Forty", tennis_score(2, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_2) { - EXPECT_EQ("Win for player1", tennis_score(4, 2)); -} - - -TEST(TennisTest, Winforplayer2_2_4) { - EXPECT_EQ("Win for player2", tennis_score(2, 4)); -} - - -TEST(TennisTest, Advantageplayer1_4_3) { - EXPECT_EQ("Advantage player1", tennis_score(4, 3)); -} - - -TEST(TennisTest, Advantageplayer2_3_4) { - EXPECT_EQ("Advantage player2", tennis_score(3, 4)); -} - - -TEST(TennisTest, Advantageplayer1_5_4) { - EXPECT_EQ("Advantage player1", tennis_score(5, 4)); -} - - -TEST(TennisTest, Advantageplayer2_4_5) { - EXPECT_EQ("Advantage player2", tennis_score(4, 5)); -} - - -TEST(TennisTest, Advantageplayer1_15_14) { - EXPECT_EQ("Advantage player1", tennis_score(15, 14)); -} - - -TEST(TennisTest, Advantageplayer2_14_15) { - EXPECT_EQ("Advantage player2", tennis_score(14, 15)); -} - - -TEST(TennisTest, Winforplayer1_6_4) { - EXPECT_EQ("Win for player1", tennis_score(6, 4)); -} - - -TEST(TennisTest, Winforplayer2_4_6) { - EXPECT_EQ("Win for player2", tennis_score(4, 6)); -} - - -TEST(TennisTest, Winforplayer1_16_14) { - EXPECT_EQ("Win for player1", tennis_score(16, 14)); -} - - -TEST(TennisTest, Winforplayer2_14_16) { - EXPECT_EQ("Win for player2", tennis_score(14, 16)); -} - - diff --git a/Tennis/cpp/defactored3/run-once.sh b/Tennis/cpp/defactored3/run-once.sh deleted file mode 100755 index 1b1bffef..00000000 --- a/Tennis/cpp/defactored3/run-once.sh +++ /dev/null @@ -1,4 +0,0 @@ -rm Tennis -rm Tennis.o -make -./Tennis \ No newline at end of file diff --git a/Tennis/cpp/starting/Makefile b/Tennis/cpp/starting/Makefile deleted file mode 100644 index a97fcd8b..00000000 --- a/Tennis/cpp/starting/Makefile +++ /dev/null @@ -1,75 +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, except GTEST_HEADERS, which you can use in your own targets -# but shouldn't modify. - -# Points to the root of Google Test, relative to where this file is. -# Remember to tweak this if you move this file. -GTEST_DIR = gtest - -# Where to find user code. -USER_DIR = . - -# Flags passed to the preprocessor. -CPPFLAGS += -I$(GTEST_DIR)/include - -# Flags passed to the C++ compiler. -CXXFLAGS += -g -Wall -Wextra - -# All tests produced by this Makefile. Remember to add new tests you -# created to the list. -TESTS = Tennis - -# All Google Test headers. Usually you shouldn't change this -# definition. -GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ - $(GTEST_DIR)/include/gtest/internal/*.h - -# House-keeping build targets. - -all : $(TESTS) - -clean : - rm -f $(TESTS) gtest.a gtest_main.a *.o - -# Builds gtest.a and gtest_main.a. - -# Usually you shouldn't tweak such internal variables, indicated by a -# trailing _. -GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) - -# For simplicity and to avoid depending on Google Test's -# implementation details, the dependencies specified below are -# conservative and not optimized. This is fine as Google Test -# compiles fast and for ordinary users its source rarely changes. -gtest-all.o : $(GTEST_SRCS_) - $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ - $(GTEST_DIR)/src/gtest-all.cc - -gtest_main.o : $(GTEST_SRCS_) - $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ - $(GTEST_DIR)/src/gtest_main.cc - -gtest.a : gtest-all.o - $(AR) $(ARFLAGS) $@ $^ - -gtest_main.a : gtest-all.o gtest_main.o - $(AR) $(ARFLAGS) $@ $^ - -# Builds a sample test. A test should link with either gtest.a or -# gtest_main.a, depending on whether it defines its own main() -# function. - -Tennis.o : $(USER_DIR)/Tennis.cc \ - $(GTEST_HEADERS) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/Tennis.cc - -Tennis : Tennis.o gtest_main.a - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ diff --git a/Tennis/cpp/starting/README b/Tennis/cpp/starting/README deleted file mode 100644 index 59cd984e..00000000 --- a/Tennis/cpp/starting/README +++ /dev/null @@ -1,14 +0,0 @@ -These files were created: - README is what you are currently reading - run-once.sh runs your tests once - run-endless.sh runs your tests endlessly via run-once.sh - -Run run-endless.sh and start your kata. (On Mac/Linux you have to call ./run-endless.sh.) - -Assumptions: - - make and a C++ compiler (like gcc) is installed on your system and is in the PATH - - The GTest framework is in the directory gtest. - - If your IDE does the compilation and linking, you should remove the first 3 lines - in the run-once.sh file. - -The support for C++/GTest was contributed by Stefan Roock. diff --git a/Tennis/cpp/starting/Tennis.cc b/Tennis/cpp/starting/Tennis.cc deleted file mode 100644 index 87ce94ac..00000000 --- a/Tennis/cpp/starting/Tennis.cc +++ /dev/null @@ -1,171 +0,0 @@ -#include - -const std::string tennis_score(int p1Score, int p2Score) { - return "foo"; -} - -TEST(TennisTest, LoveAll_0_0) { - EXPECT_EQ("Love-All", tennis_score(0, 0)); -} - - -TEST(TennisTest, FifteenAll_1_1) { - EXPECT_EQ("Fifteen-All", tennis_score(1, 1)); -} - - -TEST(TennisTest, ThirtyAll_2_2) { - EXPECT_EQ("Thirty-All", tennis_score(2, 2)); -} - - -TEST(TennisTest, Deuce_3_3) { - EXPECT_EQ("Deuce", tennis_score(3, 3)); -} - - -TEST(TennisTest, Deuce_4_4) { - EXPECT_EQ("Deuce", tennis_score(4, 4)); -} - - -TEST(TennisTest, FifteenLove_1_0) { - EXPECT_EQ("Fifteen-Love", tennis_score(1, 0)); -} - - -TEST(TennisTest, LoveFifteen_0_1) { - EXPECT_EQ("Love-Fifteen", tennis_score(0, 1)); -} - - -TEST(TennisTest, ThirtyLove_2_0) { - EXPECT_EQ("Thirty-Love", tennis_score(2, 0)); -} - - -TEST(TennisTest, LoveThirty_0_2) { - EXPECT_EQ("Love-Thirty", tennis_score(0, 2)); -} - - -TEST(TennisTest, FortyLove_3_0) { - EXPECT_EQ("Forty-Love", tennis_score(3, 0)); -} - - -TEST(TennisTest, LoveForty_0_3) { - EXPECT_EQ("Love-Forty", tennis_score(0, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_0) { - EXPECT_EQ("Win for player1", tennis_score(4, 0)); -} - - -TEST(TennisTest, Winforplayer2_0_4) { - EXPECT_EQ("Win for player2", tennis_score(0, 4)); -} - - -TEST(TennisTest, ThirtyFifteen_2_1) { - EXPECT_EQ("Thirty-Fifteen", tennis_score(2, 1)); -} - - -TEST(TennisTest, FifteenThirty_1_2) { - EXPECT_EQ("Fifteen-Thirty", tennis_score(1, 2)); -} - - -TEST(TennisTest, FortyFifteen_3_1) { - EXPECT_EQ("Forty-Fifteen", tennis_score(3, 1)); -} - - -TEST(TennisTest, FifteenForty_1_3) { - EXPECT_EQ("Fifteen-Forty", tennis_score(1, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_1) { - EXPECT_EQ("Win for player1", tennis_score(4, 1)); -} - - -TEST(TennisTest, Winforplayer2_1_4) { - EXPECT_EQ("Win for player2", tennis_score(1, 4)); -} - - -TEST(TennisTest, FortyThirty_3_2) { - EXPECT_EQ("Forty-Thirty", tennis_score(3, 2)); -} - - -TEST(TennisTest, ThirtyForty_2_3) { - EXPECT_EQ("Thirty-Forty", tennis_score(2, 3)); -} - - -TEST(TennisTest, Winforplayer1_4_2) { - EXPECT_EQ("Win for player1", tennis_score(4, 2)); -} - - -TEST(TennisTest, Winforplayer2_2_4) { - EXPECT_EQ("Win for player2", tennis_score(2, 4)); -} - - -TEST(TennisTest, Advantageplayer1_4_3) { - EXPECT_EQ("Advantage player1", tennis_score(4, 3)); -} - - -TEST(TennisTest, Advantageplayer2_3_4) { - EXPECT_EQ("Advantage player2", tennis_score(3, 4)); -} - - -TEST(TennisTest, Advantageplayer1_5_4) { - EXPECT_EQ("Advantage player1", tennis_score(5, 4)); -} - - -TEST(TennisTest, Advantageplayer2_4_5) { - EXPECT_EQ("Advantage player2", tennis_score(4, 5)); -} - - -TEST(TennisTest, Advantageplayer1_15_14) { - EXPECT_EQ("Advantage player1", tennis_score(15, 14)); -} - - -TEST(TennisTest, Advantageplayer2_14_15) { - EXPECT_EQ("Advantage player2", tennis_score(14, 15)); -} - - -TEST(TennisTest, Winforplayer1_6_4) { - EXPECT_EQ("Win for player1", tennis_score(6, 4)); -} - - -TEST(TennisTest, Winforplayer2_4_6) { - EXPECT_EQ("Win for player2", tennis_score(4, 6)); -} - - -TEST(TennisTest, Winforplayer1_16_14) { - EXPECT_EQ("Win for player1", tennis_score(16, 14)); -} - - -TEST(TennisTest, Winforplayer2_14_16) { - EXPECT_EQ("Win for player2", tennis_score(14, 16)); -} - - diff --git a/Tennis/cpp/starting/run-once.sh b/Tennis/cpp/starting/run-once.sh deleted file mode 100755 index 1b1bffef..00000000 --- a/Tennis/cpp/starting/run-once.sh +++ /dev/null @@ -1,4 +0,0 @@ -rm Tennis -rm Tennis.o -make -./Tennis \ No newline at end of file