feat(01): Solved part 2
This commit is contained in:
parent
6f9d90bf4d
commit
c64b0d008c
3 changed files with 88 additions and 15 deletions
01/tests/src
|
@ -35,16 +35,47 @@ public:
|
|||
TEST_F(Trebuchet, AssignmentInput) {
|
||||
testing::internal::CaptureStdout();
|
||||
stream_add(input, "1abc2\npqr3stu8vwx\na1b2c3d4e5f\ntreb7uchet");
|
||||
char* argv[2];
|
||||
char *argv[2];
|
||||
mainTest(input, 1, argv);
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
// Check the output of the program.
|
||||
EXPECT_EQ("The sum of the calibration values is 142\n", output);
|
||||
}
|
||||
|
||||
TEST_F(Trebuchet, AssignmentInput2){
|
||||
testing::internal::CaptureStdout();
|
||||
stream_add(input, "two1nine\neightwothree\nabcone2threexyz\nxtwone3four\n4nineeightseven2\nzoneight234\n7pqrstsixteen");
|
||||
char *argv[2];
|
||||
mainTest(input, 1, argv);
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
// Check the output of the program.
|
||||
EXPECT_EQ("The sum of the calibration values is 281\n", output);
|
||||
}
|
||||
|
||||
TEST_F(Trebuchet, getVal) {
|
||||
EXPECT_EQ(12, getVal((char *)"1abc2"));
|
||||
EXPECT_EQ(38, getVal((char *)"pqr3stu8vwx"));
|
||||
EXPECT_EQ(15, getVal((char *)"a1b2c3d4e5f"));
|
||||
EXPECT_EQ(77, getVal((char *)"treb7uchet"));
|
||||
EXPECT_EQ(11, getVal((char *)"1"));
|
||||
}
|
||||
|
||||
TEST_F(Trebuchet, getNum) {
|
||||
EXPECT_EQ(0, getNum((char *)"zero"));
|
||||
EXPECT_EQ(1, getNum((char *)"one"));
|
||||
EXPECT_EQ(2, getNum((char *)"two"));
|
||||
EXPECT_EQ(3, getNum((char *)"three"));
|
||||
EXPECT_EQ(4, getNum((char *)"four"));
|
||||
EXPECT_EQ(5, getNum((char *)"five"));
|
||||
EXPECT_EQ(6, getNum((char *)"six"));
|
||||
EXPECT_EQ(7, getNum((char *)"seven"));
|
||||
EXPECT_EQ(8, getNum((char *)"eight"));
|
||||
EXPECT_EQ(9, getNum((char *)"nine"));
|
||||
|
||||
EXPECT_EQ(1, getNum((char *)"1"));
|
||||
EXPECT_EQ(1, getNum((char *)"one"));
|
||||
EXPECT_EQ(1, getNum((char *)"1two"));
|
||||
EXPECT_EQ(2, getNum((char *)"two1"));
|
||||
|
||||
EXPECT_EQ(1, getNum((char *)"1threeone"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue