Line | Branch | Exec | Source |
---|---|---|---|
1 | /* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ | ||
2 | /* utils.c | ||
3 | * | ||
4 | * Copyright 2019 Purism SPC | ||
5 | * | ||
6 | * This program is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation, either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program 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 | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | * | ||
19 | * Author(s): | ||
20 | * Mohammed Sadiq <sadiq@sadiqpk.org> | ||
21 | * | ||
22 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
23 | */ | ||
24 | |||
25 | #undef NDEBUG | ||
26 | #undef G_DISABLE_ASSERT | ||
27 | #undef G_DISABLE_CHECKS | ||
28 | #undef G_DISABLE_CAST_CHECKS | ||
29 | #undef G_LOG_DOMAIN | ||
30 | |||
31 | #include <glib.h> | ||
32 | |||
33 | /* Including ‘.c’ file to test static functions */ | ||
34 | #include "cc-wifi-panel.c" | ||
35 | #include "cc-qr-code.c" | ||
36 | |||
37 | static void | ||
38 | 1 | test_escape_qr_string (void) | |
39 | { | ||
40 | char *str; | ||
41 | |||
42 | 1 | str = escape_string (NULL, TRUE); | |
43 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | g_assert_null (str); |
44 | |||
45 | 1 | str = escape_string ("Wifi's password:empty", TRUE); | |
46 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | g_assert_cmpstr (str, ==, "\"Wifi\'s password\\:empty\""); |
47 | 1 | g_free (str); | |
48 | |||
49 | 1 | str = escape_string ("random;string:;\\", TRUE); | |
50 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | g_assert_cmpstr (str, ==, "\"random\\;string\\:\\;\\\\\""); |
51 | 1 | g_free (str); | |
52 | |||
53 | 1 | str = escape_string ("random-string", TRUE); | |
54 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | g_assert_cmpstr (str, ==, "\"random-string\""); |
55 | 1 | g_free (str); | |
56 | |||
57 | 1 | str = escape_string ("random-string", FALSE); | |
58 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | g_assert_cmpstr (str, ==, "random-string"); |
59 | 1 | g_free (str); | |
60 | |||
61 | 1 | str = escape_string ("വൈഫൈ", TRUE); | |
62 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | g_assert_cmpstr (str, ==, "\"വൈഫൈ\""); |
63 | 1 | g_free (str); | |
64 | 1 | } | |
65 | |||
66 | int | ||
67 | 1 | main (int argc, | |
68 | char *argv[]) | ||
69 | { | ||
70 | 1 | g_test_init (&argc, &argv, NULL); | |
71 | |||
72 | 1 | g_test_add_func ("/wifi/escape-qr-string", test_escape_qr_string); | |
73 | |||
74 | 1 | return g_test_run (); | |
75 | } | ||
76 |