LCOV - code coverage report
Current view: top level - glib/glib/tests - memchunk.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 14 14 100.0 %
Date: 2024-04-16 05:15:53 Functions: 2 2 100.0 %
Branches: 6 6 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* GLIB - Library of useful routines for C programming
       2                 :            :  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
       3                 :            :  *
       4                 :            :  * SPDX-License-Identifier: LGPL-2.1-or-later
       5                 :            :  *
       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.1 of the License, or (at your option) any later version.
      10                 :            :  *
      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.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU Lesser General Public
      17                 :            :  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
      18                 :            :  */
      19                 :            : 
      20                 :            : /*
      21                 :            :  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
      22                 :            :  * file for a list of people on the GLib Team.  See the ChangeLog
      23                 :            :  * files for a list of changes.  These files are distributed with
      24                 :            :  * GLib at ftp://ftp.gtk.org/pub/gtk/.
      25                 :            :  */
      26                 :            : 
      27                 :            : /* We are testing some deprecated APIs here */
      28                 :            : #ifndef GLIB_DISABLE_DEPRECATION_WARNINGS
      29                 :            : #define GLIB_DISABLE_DEPRECATION_WARNINGS
      30                 :            : #endif
      31                 :            : 
      32                 :            : #include <glib.h>
      33                 :            : 
      34                 :            : static void
      35                 :          1 : test_basic (void)
      36                 :            : {
      37                 :            :   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
      38                 :            : 
      39                 :          1 :   GMemChunk *mem_chunk = g_mem_chunk_new ("test mem chunk", 50, 100, G_ALLOC_AND_FREE);
      40                 :            :   gchar *mem[10000];
      41                 :            :   guint i;
      42         [ +  + ]:      10001 :   for (i = 0; i < 10000; i++)
      43                 :            :     {
      44                 :            :       guint j;
      45                 :      10000 :       mem[i] = g_chunk_new (gchar, mem_chunk);
      46         [ +  + ]:     510000 :       for (j = 0; j < 50; j++)
      47                 :     500000 :         mem[i][j] = i * j;
      48                 :            :     }
      49         [ +  + ]:      10001 :   for (i = 0; i < 10000; i++)
      50                 :      10000 :     g_mem_chunk_free (mem_chunk, mem[i]);
      51                 :            : 
      52                 :          1 :   g_mem_chunk_destroy (mem_chunk);
      53                 :            : 
      54                 :            :   G_GNUC_END_IGNORE_DEPRECATIONS
      55                 :          1 : }
      56                 :            : 
      57                 :            : int
      58                 :          1 : main (int   argc,
      59                 :            :       char *argv[])
      60                 :            : {
      61                 :          1 :   g_test_init (&argc, &argv, NULL);
      62                 :            : 
      63                 :          1 :   g_test_add_func ("/memchunk/basic", test_basic);
      64                 :            : 
      65                 :          1 :   return g_test_run ();
      66                 :            : }

Generated by: LCOV version 1.14