Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.vscode/
CMakeFiles/
*zip
check_assignment*c
7 changes: 5 additions & 2 deletions hw1/Makefile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions hw1/assignment1.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <stdbool.h>

/**
* @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)
{
Expand Down
23 changes: 23 additions & 0 deletions hw1/assignment1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
#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);

39 changes: 19 additions & 20 deletions hw1/test_assignment1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(); */
/* } */