LCOV - code coverage report
Current view: top level - glib/glib/tests - gutils-user-database.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 11 11 100.0 %
Date: 2024-04-23 05:16:05 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright © 2020 Red Hat, Inc.
       3                 :            :  *
       4                 :            :  * Author: Jakub Jelen <jjelen@redhat.com>
       5                 :            :  *
       6                 :            :  * SPDX-License-Identifier: LGPL-2.1-or-later
       7                 :            :  *
       8                 :            :  * This program 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.1 of the License, or (at your option) any later version.
      12                 :            :  *
      13                 :            :  * See the included COPYING file for more information.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include <glib.h>
      17                 :            : 
      18                 :            : /* The function g_get_user_database_entry() is called from the
      19                 :            :  * g_get_real_name(), g_get_user_name() and g_build_home_dir()
      20                 :            :  * functions. These two calls are here just to invoke the code
      21                 :            :  * paths. The real-test is the ld_preload used to inject the
      22                 :            :  * NULL in place of pw->pw_name.
      23                 :            :  */
      24                 :            : static void
      25                 :          1 : test_get_user_database_entry (void)
      26                 :            : {
      27                 :          1 :   const gchar *r = NULL;
      28                 :            : 
      29                 :          1 :   r = g_get_user_name ();
      30                 :          1 :   g_assert_cmpstr (r, ==, "somebody");
      31                 :            : 
      32                 :          1 :   r = g_get_real_name ();
      33                 :          1 :   g_assert_cmpstr (r, ==, "Unknown");
      34                 :          1 : }
      35                 :            : 
      36                 :            : int
      37                 :          1 : main (int argc, char *argv[])
      38                 :            : {
      39                 :          1 :   g_test_init (&argc, &argv, NULL);
      40                 :            : 
      41                 :          1 :   g_test_add_func ("/gutils/get_user_database_entry", test_get_user_database_entry);
      42                 :            : 
      43                 :          1 :   return g_test_run ();
      44                 :            : }

Generated by: LCOV version 1.14