のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

test_layout

  500 main (int argc, char *argv[])
  501 {
  502   GDir *dir;
  503   GError *error = NULL;
  504   const gchar *name;
  505   gchar *path;
  506 
  507   g_setenv ("LC_ALL", "C", TRUE);
  508   setlocale (LC_ALL, "");
  509 
  510   g_test_init (&argc, &argv, NULL);
  511 
  512   context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
  513 
  514   /* allow to easily generate expected output for new test cases */
  515   if (argc > 1)
  516     {
  517       GString *string;
  518 
  519       string = g_string_sized_new (0);
  520       test_file (argv[1], string);
  521       g_print ("%s", string->str);
  522 
  523       return 0;
  524     }
  525 
  526   path = g_test_build_filename (G_TEST_DIST, "layouts", NULL);
  527   dir = g_dir_open (path, 0, &error);
  528   g_free (path);
  529   g_assert_no_error (error);
  530   while ((name = g_dir_read_name (dir)) != NULL)
  531     {
  532       if (!strstr (name, "markup"))
  533         continue;
  534 
  535       path = g_strdup_printf ("/layout/%s", name);
  536       g_test_add_data_func_full (path, g_test_build_filename (G_TEST_DIST, "layouts", name, NULL),
  537                                  test_layout, g_free);
  538       g_free (path);
  539     }
  540   g_dir_close (dir);
  541 
  542   return g_test_run ();
  543 }