+ | TestOutputFileMD5 (seq, filename) ->
+ pr " /* TestOutputFileMD5 for %s (%d) */\n" name i;
+ pr " char expected[33];\n";
+ pr " md5sum (\"%s\", expected);\n" filename;
+ let seq, last = get_seq_last seq in
+ let test () =
+ pr " if (STRNEQ (r, expected)) {\n";
+ pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", expected, r);\n" test_name;
+ pr " return -1;\n";
+ pr " }\n"
+ in
+ List.iter (generate_test_command_call test_name) seq;
+ generate_test_command_call ~test test_name last
+ | TestOutputDevice (seq, expected) ->
+ pr " /* TestOutputDevice for %s (%d) */\n" name i;
+ pr " const char *expected = \"%s\";\n" (c_quote expected);
+ let seq, last = get_seq_last seq in
+ let test () =
+ pr " r[5] = 's';\n";
+ pr " if (STRNEQ (r, expected)) {\n";
+ pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", expected, r);\n" test_name;
+ pr " return -1;\n";
+ pr " }\n"
+ in
+ List.iter (generate_test_command_call test_name) seq;
+ generate_test_command_call ~test test_name last
+ | TestOutputHashtable (seq, fields) ->
+ pr " /* TestOutputHashtable for %s (%d) */\n" name i;
+ pr " const char *key, *expected, *value;\n";
+ let seq, last = get_seq_last seq in
+ let test () =
+ List.iter (
+ fun (key, value) ->
+ pr " key = \"%s\";\n" (c_quote key);
+ pr " expected = \"%s\";\n" (c_quote value);
+ pr " value = get_key (r, key);\n";
+ pr " if (value == NULL) {\n";
+ pr " fprintf (stderr, \"%s: key \\\"%%s\\\" not found in hash: expecting \\\"%%s\\\"\\n\", key, expected);\n" test_name;
+ pr " return -1;\n";
+ pr " }\n";
+ pr " if (STRNEQ (value, expected)) {\n";
+ pr " fprintf (stderr, \"%s: key \\\"%%s\\\": expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", key, expected, value);\n" test_name;
+ pr " return -1;\n";
+ pr " }\n";
+ ) fields
+ in
+ List.iter (generate_test_command_call test_name) seq;
+ generate_test_command_call ~test test_name last