1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 * GObject introspection: Test typelib hashing
4 * Copyright (C) 2010 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include <glib-object.h>
23 #include "gitypelib-internal.h"
26 test_build_retrieve (void)
28 GITypelibHashBuilder *builder;
32 builder = _gi_typelib_hash_builder_new ();
34 _gi_typelib_hash_builder_add_string (builder, "Action", 0);
35 _gi_typelib_hash_builder_add_string (builder, "ZLibDecompressor", 42);
36 _gi_typelib_hash_builder_add_string (builder, "VolumeMonitor", 9);
37 _gi_typelib_hash_builder_add_string (builder, "FileMonitorFlags", 31);
39 if (!_gi_typelib_hash_builder_prepare (builder))
40 g_assert_not_reached ();
42 bufsize = _gi_typelib_hash_builder_get_buffer_size (builder);
44 buf = g_malloc (bufsize);
46 _gi_typelib_hash_builder_pack (builder, buf, bufsize);
48 _gi_typelib_hash_builder_destroy (builder);
50 g_assert (_gi_typelib_hash_search (buf, "Action") == 0);
51 g_assert (_gi_typelib_hash_search (buf, "ZLibDecompressor") == 42);
52 g_assert (_gi_typelib_hash_search (buf, "VolumeMonitor") == 9);
53 g_assert (_gi_typelib_hash_search (buf, "FileMonitorFlags") == 31);
57 main(int argc, char **argv)
60 g_test_init (&argc, &argv, NULL);
62 g_test_add_func ("/gthash/build-retrieve", test_build_retrieve);