// Sum array, test-driven. #include #include #include int sum(int a[], int n) { int total = 0; for (int i = 0; i < n; i++) { total += a[i]; } return total; } void ok(int a, int b) { if (a != b) { fprintf(stderr, "error: TEST FAILURE: %d != %d\n", a, b); abort(); } } void test_sum() { int ints[] = {3, 53, 33}; ok(sum(ints, 3), 3 + 53 + 33); } int main() { test_sum(); }