CSC161 2010F, Class 28: More Debugging with DDD Overview: * Sam does exercise 1, more or less * Lab. Admin: * Are there general questions on Assignment 5? * Reading for Friday: K&R 4.11. * The reading on Make is now due Monday after break. Questions on assignment 5? * How do I write part of my Makefile? * Step one: Identify important components array_utils.h, array_utils.c, utest_swap.c * Step two: Write dependencies that say "To make the application, we need the .o file" utest_swap: array_utils.o utest_swap.o $(CFLAGS) -o utest_swap array_utils.o utest_swap.o Also okay to write cc -o utest_swap array_utils.o utest_swap.o Also okay to write utest_swap: array_utils.c utest_swap.c array_utils.h $(CFLAGS) -o utest_swap array_utils.o utest_swap.o * Step three: Write dependencies that say "The .o files depend on the .h file" array_utils.o: array_utils.c array_utils.h utest_swap.o: utest_swap.c array_utils.h * I didn't get that. What should the Makefile end up looking like? utest_swap: array_utils.o utest_swap.o $(CFLAGS) -o utest_swap array_utils.o utest_swap.o array_utils.o: array_utils.c array_utils.h utest_swap.o: utest_swap.c array_utils.h * Testing of swap. How do I test it, given that it doesn't return a value. int a[] = { 0, 1, 2, 3 }; swap (a, 1, 2); if (a[1] != 2) { ++errors; printf ("Error: After swap (a,1,2), we have %d at a[1]\n", a[1]); } if (a[2] != 1) { ++errors; printf ("Error: After swap (a,1,2), we have %d at a[2]\n", a[1]); } * Of course, you really should write helper to make all of this more concise. * What do you mean by "systematic testing" * Think back to our testing of binary search * We want a large group of tests that broadly explore the testing space * We want to rely on the computer to build as much of tests as we can (no one wants to write 100 tests by hand) * How many tests is enough? * Probably between 100 and 10000. * Will you help me figure out this error message? * During lab * Do we need to include array_util.h in both array_util.c and utest_whatever.c? * Yes! * In both? * Yes * Why? * Because I said so * Weren't you told not to say "Because I said so"? * Yes, but when I asked why, they said ...