diff --git a/.gitignore b/.gitignore index 3dec058..1f92494 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ .vscode/ CMakeFiles/ *zip +check_assignment*c diff --git a/hw1/Makefile b/hw1/Makefile index 9951937..7217093 100644 --- a/hw1/Makefile +++ b/hw1/Makefile @@ -1,2 +1,5 @@ -test_assignment1: test_assignment1.c assignment1.c - gcc -Wall -std=c99 -o test_assignment1 test_assignment1.c assignment1.c +test_assignment1: test_assignment1.c assignment1.c check_assignment1.c + gcc -Wall -std=c99 -o test_assignment1 test_assignment1.c assignment1.c check_assignment1.c -lcheck + +check_assignment1.c: assignment1.ts + checkmk assignment1.ts > check_assignment1.c diff --git a/hw1/assignment1.c b/hw1/assignment1.c index d0d6865..d5a463a 100644 --- a/hw1/assignment1.c +++ b/hw1/assignment1.c @@ -5,10 +5,10 @@ #include /** - * @brief count even numbers between x and y, inclusive - * @param x starting number + * @brief count even numbers between x and y, inclusive + * @param x starting number * @param y ending number - * @return a long with the amount of even numbers between x and y, inclusive + * @return a long with the amount of even numbers between x and y, inclusive */ long count_even(long x, long y) { diff --git a/hw1/assignment1.ts b/hw1/assignment1.ts new file mode 100644 index 0000000..7160650 --- /dev/null +++ b/hw1/assignment1.ts @@ -0,0 +1,23 @@ +#include +#include "assignment1.h" + +#suite HW 1 + +#tcase Count even numbers + +static const int samples[4][3] = { + {1, 4, 2}, + {10, 3, 4}, + {7, -8, 8}, + {-11, -11, 0}, +}; + +#test-loop(0, 4) count_even_table + int start = samples[_i][0]; + int end = samples[_i][1]; + int expected = samples[_i][2]; + ck_assert_int_eq(count_even(start, end), expected); + +#test count_even_4 + ck_assert_int_eq(count_even(-11, -11), 0); + diff --git a/hw1/test_assignment1.c b/hw1/test_assignment1.c index a739ef3..b3edd49 100644 --- a/hw1/test_assignment1.c +++ b/hw1/test_assignment1.c @@ -249,24 +249,23 @@ bool test_q5_3() { // when testing your code, it may be convenient // to comment out some of the test cases // and focus only on the one you are working on right now -int main() { - test_q1_1(); - test_q1_2(); - test_q1_3(); - - test_q2_1(); - test_q2_2(); - - test_q3_1(); - test_q3_2(); -// - test_q4_1(); - test_q4_2(); - test_q4_3(); - - test_q5_1(); - test_q5_2(); - test_q5_3(); - return 0; -} +/* int main() { */ +/* test_q1_1(); */ +/* test_q1_2(); */ +/* test_q1_3(); */ + +/* test_q2_1(); */ +/* test_q2_2(); */ + +/* test_q3_1(); */ +/* test_q3_2(); */ + +/* test_q4_1(); */ +/* test_q4_2(); */ +/* test_q4_3(); */ + +/* test_q5_1(); */ +/* test_q5_2(); */ +/* test_q5_3(); */ +/* } */