Commit 863b9cf
Changed files (2)
gol.c
@@ -3,22 +3,40 @@
int tests_run = 0;
-int foo = 7;
-int bar = 5;
+static char* test_foo() {
+ int foo = 7;
+ assert_equal(foo == 7, "error, foo != 7");
+ return 0;
+}
+
+static char* test_bar() {
+ int bar = 5;
+ assert_equal(bar == 5, "error, bar != 5");
+ return 0;
+}
+
+int evolve(int* cell) {
+ return 0;
+}
-static char * test_foo() {
- mu_assert("error, foo != 7", foo == 7);
+static char* any_live_cell_with_fewer_than_two_live_neighbours_dies_as_if_caused_by_under_population() {
+ int cells[] = { 0, 0, 0, 1, 1 };
+ assert_equal(evolve(&cells[3]) == 0, "should die because has 1 living neighbours");
+ assert_equal(evolve(&cells[1]) == 0, "should die because has 0 living neighbours");
return 0;
}
-static char * test_bar() {
- mu_assert("error, bar != 5", bar == 5);
+static char* any_live_cell_with_two_or_three_live_neighbours_lives_on_to_the_next_generation() {
+ int cells[] = { 0, 0, 0, 1, 1 };
+ /*assert_equal();*/
return 0;
}
-static char * all_tests() {
- mu_run_test(test_foo);
- mu_run_test(test_bar);
+static char* all_tests() {
+ run_test(test_foo);
+ run_test(test_bar);
+ run_test(any_live_cell_with_fewer_than_two_live_neighbours_dies_as_if_caused_by_under_population);
+ run_test(any_live_cell_with_two_or_three_live_neighbours_lives_on_to_the_next_generation);
return 0;
}
miniunit.h
@@ -1,5 +1,4 @@
- /* file: minunit.h */
- #define mu_assert(message, test) do { if (!(test)) return message; } while (0)
- #define mu_run_test(test) do { char *message = test(); tests_run++; \
+ #define assert_equal(test, message) do { if (!(test)) return message; } while (0)
+ #define run_test(test) do { char *message = test(); tests_run++; \
if (message) return message; } while (0)
extern int tests_run;