LCOV - code coverage report
Current view: top level - gio/tests - cxx.cpp (source / functions) Coverage Total Hit
Test: unnamed Lines: 100.0 % 28 28
Test Date: 2024-11-26 05:23:01 Functions: 100.0 % 3 3
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Copyright (C) 2001 Sebastian Wilhelmi <wilhelmi@google.com>
       2                 :             :  *
       3                 :             :  * SPDX-License-Identifier: LGPL-2.1-or-later
       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.1 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 License
      16                 :             :  * along with this library; if not, see <http://www.gnu.org/licenses/>.
      17                 :             :  */
      18                 :             : 
      19                 :             : /* A trivial C++ program to be compiled in C++ mode, which
      20                 :             :  * smoketests that the GIO headers are valid C++ headers. */
      21                 :             : 
      22                 :             : #include <gio/gio.h>
      23                 :             : 
      24                 :             : static void
      25                 :           8 : test_name (void)
      26                 :             : {
      27                 :           8 :   GTask *task = NULL;
      28                 :           8 :   char *orig = g_strdup ("some task");
      29                 :             : 
      30                 :           8 :   task = g_task_new (NULL, NULL, NULL, NULL);
      31                 :           8 :   (g_task_set_name) (task, orig);
      32                 :           8 :   g_assert_cmpstr (g_task_get_name (task), ==, "some task");
      33                 :             : 
      34                 :           8 :   (g_task_set_name) (task, "some other name");
      35                 :           8 :   g_assert_cmpstr (g_task_get_name (task), ==, "some other name");
      36                 :             : 
      37                 :           8 :   g_clear_object (&task);
      38                 :           8 :   g_free (orig);
      39                 :           8 : }
      40                 :             : 
      41                 :             : static void
      42                 :           8 : test_name_macro_wrapper (void)
      43                 :             : {
      44                 :           8 :   GTask *task = NULL;
      45                 :           8 :   char *orig = g_strdup ("some task");
      46                 :             : 
      47                 :           8 :   task = g_task_new (NULL, NULL, NULL, NULL);
      48                 :           8 :   g_task_set_name (task, orig);
      49                 :           8 :   g_assert_cmpstr (g_task_get_name (task), ==, "some task");
      50                 :             : 
      51                 :           8 :   g_task_set_name (task, "some other name");
      52                 :           8 :   g_assert_cmpstr (g_task_get_name (task), ==, "some other name");
      53                 :             : 
      54                 :           8 :   g_clear_object (&task);
      55                 :           8 :   g_free (orig);
      56                 :           8 : }
      57                 :             : 
      58                 :             : int
      59                 :           8 : main (int argc, char **argv)
      60                 :             : {
      61                 :             : #if G_CXX_STD_CHECK_VERSION (11)
      62                 :           6 :   g_test_init (&argc, &argv, nullptr);
      63                 :             : #else
      64                 :           2 :   g_test_init (&argc, &argv, static_cast<void *>(NULL));
      65                 :             : #endif
      66                 :             : 
      67                 :           8 :   g_test_add_func ("/gtask/name", test_name);
      68                 :           8 :   g_test_add_func ("/gtask/name/macro-wrapper", test_name_macro_wrapper);
      69                 :             : 
      70                 :           8 :   return g_test_run ();
      71                 :             : }
        

Generated by: LCOV version 2.0-1