mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-13 04:42:23 +00:00
generate test cases for cyber-dojo
This commit is contained in:
parent
91630a3a34
commit
810ebd7d7e
@ -1,9 +1,4 @@
|
|||||||
|
|
||||||
template = """\
|
|
||||||
TEST(TennisTest, %(testcase_name)s) {
|
|
||||||
EXPECT_EQ("%(score)s", tennis_score(%(p1Points)s, %(p2Points)s));
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
|
|
||||||
test_cases = [dict(p1Points=0, p2Points=0, score="Love-All"),
|
test_cases = [dict(p1Points=0, p2Points=0, score="Love-All"),
|
||||||
dict(p1Points=1, p2Points=1, score="Fifteen-All"),
|
dict(p1Points=1, p2Points=1, score="Fifteen-All"),
|
||||||
@ -44,12 +39,40 @@ test_cases = [dict(p1Points=0, p2Points=0, score="Love-All"),
|
|||||||
dict(p1Points=16, p2Points=14, score="Win for player1"),
|
dict(p1Points=16, p2Points=14, score="Win for player1"),
|
||||||
dict(p1Points=14, p2Points=16, score="Win for player2"),
|
dict(p1Points=14, p2Points=16, score="Win for player2"),
|
||||||
]
|
]
|
||||||
|
|
||||||
for test in test_cases:
|
def create_testcase_dicts():
|
||||||
cleaned = test["score"]
|
testcase_dicts = []
|
||||||
cleaned = cleaned.replace("-", "")
|
for test in test_cases:
|
||||||
cleaned = cleaned.replace(" ", "")
|
cleaned = test["score"]
|
||||||
test["cleaned"] = cleaned
|
cleaned = cleaned.replace("-", "")
|
||||||
test["testcase_name"] = "%(cleaned)s_%(p1Points)s_%(p2Points)s" % test
|
cleaned = cleaned.replace(" ", "")
|
||||||
|
test["cleaned"] = cleaned
|
||||||
|
test["testcase_name"] = "%(cleaned)s_%(p1Points)s_%(p2Points)s" % test
|
||||||
|
testcase_dicts.append(test)
|
||||||
|
return testcase_dicts
|
||||||
|
|
||||||
|
testcase_dicts = create_testcase_dicts()
|
||||||
|
|
||||||
|
gtest_template = """\
|
||||||
|
TEST(TennisTest, %(testcase_name)s) {
|
||||||
|
EXPECT_EQ("%(score)s", tennis_score(%(p1Points)s, %(p2Points)s));
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
template = """\
|
||||||
|
void test_%(testcase_name)s()
|
||||||
|
{
|
||||||
|
assert("%(score)s" == tennis_score(%(p1Points)s, %(p2Points)s));
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
# test cases
|
||||||
|
for test in testcase_dicts:
|
||||||
print template % test
|
print template % test
|
||||||
print
|
|
||||||
|
# all_tests.cpp
|
||||||
|
for test in testcase_dicts:
|
||||||
|
print " test_%(testcase_name)s," % test
|
||||||
|
|
||||||
|
# all_tests.hpp
|
||||||
|
for test in testcase_dicts:
|
||||||
|
print "void test_%(testcase_name)s();" % test
|
||||||
Loading…
Reference in New Issue
Block a user