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