summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMohammed Sadiq <sadiq@sadiqpk.org>2019-12-05 16:09:01 +0530
committerMohammed Sadiq <sadiq@sadiqpk.org>2020-08-05 14:25:54 +0530
commit244e70272e52281a75672466b3d8ddfd4417e154 (patch)
tree22261639bf1913dd743c0dc729674f6d852c1a61 /tests
parentcc7662e24b3afc942e19ed771f6947e5d6f1050b (diff)
downloadgnome-control-center-244e70272e52281a75672466b3d8ddfd4417e154.tar.gz
Add tests for text escape
Diffstat (limited to 'tests')
-rw-r--r--tests/network/meson.build16
-rw-r--r--tests/network/test-wifi-text.c74
2 files changed, 90 insertions, 0 deletions
diff --git a/tests/network/meson.build b/tests/network/meson.build
index 75cc25c19..34f7c7405 100644
--- a/tests/network/meson.build
+++ b/tests/network/meson.build
@@ -31,3 +31,19 @@ test(
env : envs,
timeout : 60
)
+
+exe = executable(
+ 'test-wifi-panel-text',
+ ['test-wifi-text.c'],
+ include_directories : includes + [common_inc],
+ dependencies : common_deps + network_manager_deps + [libtestshell_dep],
+ link_with : [network_panel_lib],
+ c_args : cflags,
+)
+
+test(
+ 'test-wif-panel-text',
+ exe,
+ env : envs,
+ timeout : 60
+)
diff --git a/tests/network/test-wifi-text.c b/tests/network/test-wifi-text.c
new file mode 100644
index 000000000..39c79cbcf
--- /dev/null
+++ b/tests/network/test-wifi-text.c
@@ -0,0 +1,74 @@
+/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
+/* utils.c
+ *
+ * Copyright 2019 Purism SPC
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author(s):
+ * Mohammed Sadiq <sadiq@sadiqpk.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#undef NDEBUG
+#undef G_DISABLE_ASSERT
+#undef G_DISABLE_CHECKS
+#undef G_DISABLE_CAST_CHECKS
+#undef G_LOG_DOMAIN
+
+#include <glib.h>
+
+/* Including ‘.c’ file to test static functions */
+#include "cc-wifi-panel.c"
+
+static void
+test_escape_qr_string (void)
+{
+ char *str;
+
+ str = escape_string (NULL, TRUE);
+ g_assert_null (str);
+
+ str = escape_string ("Wifi's password:empty", TRUE);
+ g_assert_cmpstr (str, ==, "\"Wifi\'s password\\:empty\"");
+ g_free (str);
+
+ str = escape_string ("random;string:;\\", TRUE);
+ g_assert_cmpstr (str, ==, "\"random\\;string\\:\\;\\\\\"");
+ g_free (str);
+
+ str = escape_string ("random-string", TRUE);
+ g_assert_cmpstr (str, ==, "\"random-string\"");
+ g_free (str);
+
+ str = escape_string ("random-string", FALSE);
+ g_assert_cmpstr (str, ==, "random-string");
+ g_free (str);
+
+ str = escape_string ("വൈഫൈ", TRUE);
+ g_assert_cmpstr (str, ==, "\"വൈഫൈ\"");
+ g_free (str);
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/wifi/escape-qr-string", test_escape_qr_string);
+
+ return g_test_run ();
+}