void unit_test(void) { test_constants_and_sizes(); test_rectangle(); test_image(); test_gray(); test_streams(); test_image_io(); test_gray_io(); }
int main (int argc, char **argv) { const char *datadir = "data/streams"; gboolean gen_data = TRUE; char *stream_name = NULL; char path[256], *p; GDir *dir, *outdir; const char *dent; int i; g_mime_init (0); testsuite_init (argc, argv); for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { datadir = argv[i]; break; } } testsuite_start ("Stream tests"); p = g_stpcpy (path, datadir); *p++ = G_DIR_SEPARATOR; strcpy (p, "output"); if (!(outdir = g_dir_open (path, 0, NULL))) { if (gen_test_data (datadir, &stream_name) == -1 || !(outdir = g_dir_open (path, 0, NULL))) goto exit; gen_data = FALSE; } p = g_stpcpy (p, "input"); if (!(dir = g_dir_open (path, 0, NULL))) { if (!gen_data || gen_test_data (datadir, &stream_name) == -1 || !(dir = g_dir_open (path, 0, NULL))) { g_dir_close (outdir); goto exit; } gen_data = FALSE; } if (gen_data) { while ((dent = g_dir_read_name (dir))) { if (dent[0] == '.' || !strcmp (dent, "README")) continue; gen_data = FALSE; break; } g_dir_rewind (dir); if (gen_data && gen_test_data (datadir, &stream_name) == -1) goto exit; } *p++ = G_DIR_SEPARATOR; *p = '\0'; while ((dent = g_dir_read_name (dir))) { if (dent[0] == '.' || !strcmp (dent, "README")) continue; test_streams (outdir, datadir, dent); strcpy (p, dent); test_stream_buffer_gets (path); } if (gen_data && stream_name && testsuite_total_errors () == 0) { /* since all tests were successful, unlink the generated test data */ strcpy (p, stream_name); unlink (path); p = g_stpcpy (path, datadir); *p++ = G_DIR_SEPARATOR; p = g_stpcpy (p, "output"); *p++ = G_DIR_SEPARATOR; g_dir_rewind (outdir); while ((dent = g_dir_read_name (outdir))) { if (!strncmp (dent, stream_name, strlen (stream_name))) { strcpy (p, dent); unlink (path); } } g_free (stream_name); } g_dir_close (outdir); g_dir_close (dir); exit: testsuite_end (); g_mime_shutdown (); return testsuite_exit (); }