-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Binary test for Assignment 1: Method 5
- Loading branch information
Sam A. Markelon
committed
Feb 18, 2019
1 parent
ca6e721
commit a3a8001
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,19 @@ FactorsContainer factor(const std::string path, const NumberToFactor n) { | |
return factors; | ||
} | ||
|
||
std::string english_factor(const std::string path, const NumberToFactor n) { | ||
subprocess::popen cmd(path, {}); | ||
cmd.stdin() << n << std::endl; | ||
cmd.close(); | ||
|
||
std::stringstream s; | ||
s << cmd.stdout().rdbuf(); | ||
std::string out = s.str(); | ||
|
||
return out; | ||
} | ||
|
||
|
||
const std::map<NumberToFactor, FactorsContainer> tests = { | ||
{ 20, { 2, 2, 5 } }, | ||
{ 29, { 29 } }, | ||
|
@@ -43,6 +56,18 @@ const std::map<NumberToFactor, FactorsContainer> tests = { | |
{ 1234567890987654321, { 3, 3, 7, 19, 928163, 1111211111 } } | ||
}; | ||
|
||
|
||
const std::map<NumberToFactor, std::string> english_tests = { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Brandon
Owner
|
||
{ 20, "The prime factors of 20 are 2, 2 and 5.\n"}, | ||
{ 29, "The prime factor of 29 is 29.\n"}, | ||
{ 49, "The prime factors of 49 are 7 and 7.\n"}, | ||
{ 625, "The prime factors of 625 are 5, 5, 5 and 5.\n"}, | ||
{ 324324, "The prime factors of 324324 are 2, 2, 3, 3, 3, 3, 7, 11 and 13.\n"}, | ||
{ 9876543210, "The prime factors of 9876543210 are 2, 3, 3, 5, 17, 17 and 379721.\n"}, | ||
{ 1234567890987654321, "The prime factors of 1234567890987654321 are 3, 3, 7, 19, 928163 and 1111211111.\n"} | ||
}; | ||
|
||
|
||
TEST_CASE("Method 1: Print the factors directly") { | ||
for (const auto p : tests) { | ||
CHECK_THAT(factor("./asgn1/q1", p.first), Catch::Equals(p.second)); | ||
|
@@ -69,3 +94,9 @@ TEST_CASE("Method 4: Store the factors in a stack") { | |
CHECK_THAT(factor("./asgn1/q4", p.first), Catch::Equals(reversed)); | ||
} | ||
} | ||
|
||
TEST_CASE("Method 5: Factoring a number in English"){ | ||
for (const auto p : english_tests) { | ||
CHECK_THAT(english_factor("./asgn1/q5", p.first), Catch::Contains(p.second)); | ||
} | ||
} |
@sam15124
I'm wondering if we should be picky about the
s
in factors. I lean towards no since Dr. Michel said to be lenient towards grading during the beginning of the semester.What do you think?