LCOV - code coverage report
Current view: top level - glib/girepository/tests - gthash.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 21 21 100.0 %
Date: 2024-05-07 05:15:23 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
       2                 :            :  * GObject introspection: Test typelib hashing
       3                 :            :  *
       4                 :            :  * Copyright (C) 2010 Red Hat, Inc.
       5                 :            :  *
       6                 :            :  * SPDX-License-Identifier: LGPL-2.1-or-later
       7                 :            :  *
       8                 :            :  * This library is free software; you can redistribute it and/or
       9                 :            :  * modify it under the terms of the GNU Lesser General Public
      10                 :            :  * License as published by the Free Software Foundation; either
      11                 :            :  * version 2 of the License, or (at your option) any later version.
      12                 :            :  *
      13                 :            :  * This library is distributed in the hope that it will be useful,
      14                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16                 :            :  * Lesser General Public License for more details.
      17                 :            :  *
      18                 :            :  * You should have received a copy of the GNU Lesser General Public
      19                 :            :  * License along with this library; if not, write to the
      20                 :            :  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      21                 :            :  * Boston, MA 02111-1307, USA.
      22                 :            :  */
      23                 :            : 
      24                 :            : #include <stdint.h>
      25                 :            : #include <glib-object.h>
      26                 :            : #include "gitypelib-internal.h"
      27                 :            : 
      28                 :            : static void
      29                 :          1 : test_build_retrieve (void)
      30                 :            : {
      31                 :            :   GITypelibHashBuilder *builder;
      32                 :            :   uint32_t bufsize;
      33                 :            :   uint8_t* buf;
      34                 :            : 
      35                 :          1 :   builder = gi_typelib_hash_builder_new ();
      36                 :            : 
      37                 :          1 :   gi_typelib_hash_builder_add_string (builder, "Action", 0);
      38                 :          1 :   gi_typelib_hash_builder_add_string (builder, "ZLibDecompressor", 42);
      39                 :          1 :   gi_typelib_hash_builder_add_string (builder, "VolumeMonitor", 9);
      40                 :          1 :   gi_typelib_hash_builder_add_string (builder, "FileMonitorFlags", 31);
      41                 :            : 
      42                 :          1 :   g_assert_true (gi_typelib_hash_builder_prepare (builder));
      43                 :            : 
      44                 :          1 :   bufsize = gi_typelib_hash_builder_get_buffer_size (builder);
      45                 :            : 
      46                 :          1 :   buf = g_malloc (bufsize);
      47                 :            : 
      48                 :          1 :   gi_typelib_hash_builder_pack (builder, buf, bufsize);
      49                 :            : 
      50                 :          1 :   gi_typelib_hash_builder_destroy (builder);
      51                 :            : 
      52                 :          1 :   g_assert_cmpuint (gi_typelib_hash_search (buf, "Action", 4), ==, 0);
      53                 :          1 :   g_assert_cmpuint (gi_typelib_hash_search (buf, "ZLibDecompressor", 4), ==, 42);
      54                 :          1 :   g_assert_cmpuint (gi_typelib_hash_search (buf, "VolumeMonitor", 4), ==, 9);
      55                 :          1 :   g_assert_cmpuint (gi_typelib_hash_search (buf, "FileMonitorFlags", 4), ==, 31);
      56                 :            : 
      57                 :          1 :   g_free (buf);
      58                 :          1 : }
      59                 :            : 
      60                 :            : int
      61                 :          1 : main(int argc, char **argv)
      62                 :            : {
      63                 :          1 :   g_test_init (&argc, &argv, NULL);
      64                 :            : 
      65                 :          1 :   g_test_add_func ("/gthash/build-retrieve", test_build_retrieve);
      66                 :            : 
      67                 :          1 :   return g_test_run ();
      68                 :            : }
      69                 :            : 

Generated by: LCOV version 1.14