~ubuntu-branches/ubuntu/trusty/gobject-introspection/trusty

« back to all changes in this revision

Viewing changes to girepository/gthash-test.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2011-03-22 00:32:36 UTC
  • mfrom: (1.4.1 upstream) (3.3.33 multiarch)
  • Revision ID: james.westby@ubuntu.com-20110322003236-4spdgfk1vai6xay1
Tags: 0.10.4-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GObject introspection: Test typelib hashing
 
2
 *
 
3
 * Copyright (C) 2010 Red Hat, Inc.
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 */
 
20
 
 
21
#include <glib-object.h>
 
22
#include "gitypelib-internal.h"
 
23
 
 
24
static void
 
25
test_build_retrieve (void)
 
26
{
 
27
  GITypelibHashBuilder *builder;
 
28
  guint32 bufsize;
 
29
  guint8* buf;
 
30
 
 
31
  builder = _gi_typelib_hash_builder_new ();
 
32
 
 
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);
 
37
 
 
38
  if (!_gi_typelib_hash_builder_prepare (builder))
 
39
    g_assert_not_reached ();
 
40
 
 
41
  bufsize = _gi_typelib_hash_builder_get_buffer_size (builder);
 
42
 
 
43
  buf = g_malloc (bufsize);
 
44
 
 
45
  _gi_typelib_hash_builder_pack (builder, buf, bufsize);
 
46
 
 
47
  _gi_typelib_hash_builder_destroy (builder);
 
48
 
 
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);
 
53
}
 
54
 
 
55
int
 
56
main(int argc, char **argv)
 
57
{
 
58
  g_type_init ();
 
59
  g_test_init (&argc, &argv, NULL);
 
60
 
 
61
  g_test_add_func ("/gthash/build-retrieve", test_build_retrieve);
 
62
 
 
63
  return g_test_run ();
 
64
}
 
65