示例#1
0
static int check_get_resource(const char *str_database, const char *res_name, const char *res_class, const char *value,
        bool expected_xlib_mismatch) {
    xcb_xrm_database_t *database;

    bool err = false;
    char *xcb_value;
    char *xlib_value;

    fprintf(stderr, "== Assert that getting resource <%s> / <%s> returns <%s>\n",
            res_name, res_class, value);

    database = xcb_xrm_database_from_string(str_database);
    if (xcb_xrm_resource_get_string(database, res_name, res_class, &xcb_value) < 0) {
        if (value != NULL) {
            fprintf(stderr, "xcb_xrm_resource_get_string() returned NULL\n");
            err = true;
        }

        if (!expected_xlib_mismatch) {
            xlib_value = check_get_resource_xlib(str_database, res_name, res_class);
            err |= check_strings(NULL, xlib_value, "Returned NULL, but Xlib returned <%s>\n", xlib_value);
            if (xlib_value != NULL)
                free(xlib_value);
        }

        goto done_get_resource;
    }

    err |= check_strings(value, xcb_value, "Expected <%s>, but got <%s>\n", value, xcb_value);
    free(xcb_value);

    if (!expected_xlib_mismatch) {
        /* And for good measure, also compare it against Xlib. */
        xlib_value = check_get_resource_xlib(str_database, res_name, res_class);
        err |= check_strings(value, xlib_value, "Xlib returns <%s>, but expected <%s>\n",
                xlib_value, value);
        if (xlib_value != NULL)
            free(xlib_value);
    }

done_get_resource:
    xcb_xrm_database_free(database);
    return err;
}
示例#2
0
static void
test_data(struct test_data_s *pdata)
{
	gs_error_t *gse = NULL;
	struct gs_grid_storage_s *gs = NULL;
	struct gs_container_s *container = NULL;

	gs = gs_grid_storage_init_flags(pdata->ns, GSCLIENT_NOINIT, 60, 60, &gse);
	g_assert((gs != NULL) ^ (gse != NULL));
	if (!gs)
		g_debug("gs_grid_storage_init_flags failed : (%d) %s\n",
				gse->code, gse->msg);
	g_assert(gse == NULL);

	check_strings(pdata->pns, gs->ni.name);
	check_strings(pdata->ns, gs->full_vns);
	check_strings(pdata->pns, gs->physical_namespace);
	check_strings(pdata->vns, gs_get_virtual_namespace(gs));

	container = gs_init_container(gs, pdata->refname, 0, &gse);
	g_assert((container != NULL) ^ (gse != NULL));
	if (!container)
		g_debug("gs_init_container failed : (%d) %s\n",
				gse->code, gse->msg);
	g_assert(gse == NULL);

	check_strings(pdata->refname, container->info.name);
	check_strings(pdata->refhexa, container->str_cID);

	gs_container_free(container);
	gs_grid_storage_free(gs);
}
示例#3
0
文件: gc.c 项目: fengye/swfdec
int
main (int argc, char **argv)
{
  guint errors = 0;

  g_type_init ();

  errors += check_strings ();
  errors += check_objects ();
  errors += check_object_variables ();

  g_print ("TOTAL ERRORS: %u\n", errors);
  return errors;
}
示例#4
0
文件: gen.cpp 项目: aseprite/aseprite
static void run(int argc, const char* argv[])
{
  PO po;
  PO::Option& inputOpt = po.add("input").requiresValue("<filename>");
  PO::Option& widgetId = po.add("widgetid").requiresValue("<id>");
  PO::Option& prefH = po.add("pref-h");
  PO::Option& prefCpp = po.add("pref-cpp");
  PO::Option& theme = po.add("theme");
  PO::Option& strings = po.add("strings");
  PO::Option& commandIds = po.add("command-ids");
  PO::Option& widgetsDir = po.add("widgets-dir").requiresValue("<dir>");
  PO::Option& stringsDir = po.add("strings-dir").requiresValue("<dir>");
  PO::Option& guiFile = po.add("gui-file").requiresValue("<filename>");
  po.parse(argc, argv);

  // Try to load the XML file
  TiXmlDocument* doc = nullptr;

  std::string inputFilename = po.value_of(inputOpt);
  if (!inputFilename.empty() &&
      base::get_file_extension(inputFilename) == "xml") {
    base::FileHandle inputFile(base::open_file(inputFilename, "rb"));
    doc = new TiXmlDocument();
    doc->SetValue(inputFilename.c_str());
    if (!doc->LoadFile(inputFile.get())) {
      std::cerr << doc->Value() << ":"
                << doc->ErrorRow() << ":"
                << doc->ErrorCol() << ": "
                << "error " << doc->ErrorId() << ": "
                << doc->ErrorDesc() << "\n";

      throw std::runtime_error("invalid input file");
    }
  }

  if (doc) {
    // Generate widget class
    if (po.enabled(widgetId))
      gen_ui_class(doc, inputFilename, po.value_of(widgetId));
    // Generate preference header file
    else if (po.enabled(prefH))
      gen_pref_header(doc, inputFilename);
    // Generate preference c++ file
    else if (po.enabled(prefCpp))
      gen_pref_impl(doc, inputFilename);
    // Generate theme class
    else if (po.enabled(theme))
      gen_theme_class(doc, inputFilename);
  }
  // Generate strings.ini.h file
  else if (po.enabled(strings)) {
    gen_strings_class(inputFilename);
  }
  // Generate command_ids.ini.h file
  else if (po.enabled(commandIds)) {
    gen_command_ids(inputFilename);
  }
  // Check all translation files (en.ini, es.ini, etc.)
  else if (po.enabled(widgetsDir) &&
           po.enabled(stringsDir)) {
    check_strings(po.value_of(widgetsDir),
                  po.value_of(stringsDir),
                  po.value_of(guiFile));
  }
}