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

             Branch data     Line data    Source code
       1                 :             : /* GLib testing framework examples and tests
       2                 :             :  *
       3                 :             :  * Copyright © 2022 Endless OS Foundation, LLC
       4                 :             :  *
       5                 :             :  * SPDX-License-Identifier: LGPL-2.1-or-later
       6                 :             :  *
       7                 :             :  * This library is free software; you can redistribute it and/or
       8                 :             :  * modify it under the terms of the GNU Lesser General Public
       9                 :             :  * License as published by the Free Software Foundation; either
      10                 :             :  * version 2.1 of the License, or (at your option) any later version.
      11                 :             :  *
      12                 :             :  * This library is distributed in the hope that it will be useful,
      13                 :             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15                 :             :  * Lesser General Public License for more details.
      16                 :             :  *
      17                 :             :  * You should have received a copy of the GNU Lesser General
      18                 :             :  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
      19                 :             :  *
      20                 :             :  * Author: Philip Withnall <pwithnall@endlessos.org>
      21                 :             :  */
      22                 :             : 
      23                 :             : #include <glib.h>
      24                 :             : #include <locale.h>
      25                 :             : 
      26                 :             : 
      27                 :             : /* All of GThread is deprecated, but that’s OK */
      28                 :             : G_GNUC_BEGIN_IGNORE_DEPRECATIONS
      29                 :             : 
      30                 :             : static void
      31                 :           1 : test_thread_deprecated_init (void)
      32                 :             : {
      33                 :           1 :   const GThreadFunctions functions = {
      34                 :             :     NULL, NULL, NULL, NULL,
      35                 :             :     NULL, NULL, NULL, NULL,
      36                 :             :     NULL, NULL, NULL, NULL,
      37                 :             :     NULL, NULL, NULL, NULL,
      38                 :             :     NULL, NULL, NULL, NULL,
      39                 :             :     NULL
      40                 :             :   };
      41                 :             : 
      42                 :             :   /* Should be a no-op. */
      43                 :           1 :   g_thread_init (NULL);
      44                 :             : 
      45                 :             :   /* Should emit a warning. */
      46                 :           1 :   g_test_expect_message ("GThread", G_LOG_LEVEL_WARNING,
      47                 :             :                          "GThread system no longer supports custom thread implementations.");
      48                 :           1 :   g_thread_init ((gpointer) &functions);
      49                 :           1 :   g_test_assert_expected_messages ();
      50                 :           1 : }
      51                 :             : 
      52                 :             : static void
      53                 :           1 : test_thread_deprecated_init_with_errorcheck_mutexes (void)
      54                 :             : {
      55                 :             :   /* Should warn. */
      56                 :           1 :   g_test_expect_message ("GThread", G_LOG_LEVEL_WARNING,
      57                 :             :                          "GThread system no longer supports errorcheck mutexes.");
      58                 :           1 :   g_thread_init_with_errorcheck_mutexes (NULL);
      59                 :           1 :   g_test_assert_expected_messages ();
      60                 :           1 : }
      61                 :             : 
      62                 :             : int
      63                 :           1 : main (int   argc,
      64                 :             :       char *argv[])
      65                 :             : {
      66                 :           1 :   setlocale (LC_ALL, "");
      67                 :           1 :   g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
      68                 :             : 
      69                 :           1 :   g_test_add_func ("/thread/deprecated/init", test_thread_deprecated_init);
      70                 :           1 :   g_test_add_func ("/thread/deprecated/init-with-errorcheck-mutexes", test_thread_deprecated_init_with_errorcheck_mutexes);
      71                 :             : 
      72                 :           1 :   return g_test_run ();
      73                 :             : }
      74                 :             : 
      75                 :             : G_GNUC_END_IGNORE_DEPRECATIONS
        

Generated by: LCOV version 2.0-1