Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F4511785
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/common/tests/strings/Makefile.am b/lib/common/tests/strings/Makefile.am
index 1d6c7aabbe..abfa03eb6b 100644
--- a/lib/common/tests/strings/Makefile.am
+++ b/lib/common/tests/strings/Makefile.am
@@ -1,39 +1,40 @@
#
# Copyright 2020-2021 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include
LDADD = $(top_builddir)/lib/common/libcrmcommon.la
include $(top_srcdir)/mk/glib-tap.mk
# Add each test program here. Each test should be written as a little standalone
# program using the glib unit testing functions. See the documentation for more
# information.
#
# https://developer.gnome.org/glib/unstable/glib-Testing.html
#
# Add "_test" to the end of all test program names to simplify .gitignore.
test_programs = crm_is_true_test \
crm_str_to_boolean_test \
pcmk__add_word_test \
pcmk__btoa_test \
pcmk__char_in_any_str_test \
pcmk__parse_ll_range_test \
pcmk__scan_double_test \
+ pcmk__starts_with_test \
pcmk__str_any_of_test \
pcmk__str_in_list_test \
pcmk__strcmp_test
# If any extra data needs to be added to the source distribution, add it to the
# following list.
dist_test_data =
# If any extra data needs to be used by tests but should not be added to the
# source distribution, add it to the following list.
test_data =
diff --git a/lib/common/tests/strings/pcmk__starts_with_test.c b/lib/common/tests/strings/pcmk__starts_with_test.c
new file mode 100644
index 0000000000..01b17aa3db
--- /dev/null
+++ b/lib/common/tests/strings/pcmk__starts_with_test.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2021 the Pacemaker project contributors
+ *
+ * The version control history for this file may have further details.
+ *
+ * This source code is licensed under the GNU Lesser General Public License
+ * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
+ */
+
+#include <crm_internal.h>
+
+static void
+bad_input(void) {
+ g_assert_false(pcmk__starts_with(NULL, "x"));
+ g_assert_false(pcmk__starts_with("abc", NULL));
+}
+
+static void
+starts_with(void) {
+ g_assert_true(pcmk__starts_with("abc", "a"));
+ g_assert_true(pcmk__starts_with("abc", "ab"));
+ g_assert_true(pcmk__starts_with("abc", "abc"));
+
+ g_assert_false(pcmk__starts_with("abc", "A"));
+ g_assert_false(pcmk__starts_with("abc", "bc"));
+
+ g_assert_false(pcmk__starts_with("", "x"));
+ g_assert_true(pcmk__starts_with("xyz", ""));
+}
+
+int
+main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/common/strings/starts_with/bad_input", bad_input);
+ g_test_add_func("/common/strings/starts_with/starts_with", starts_with);
+ return g_test_run();
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Jun 25, 2:27 AM (14 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1951881
Default Alt Text
(2 KB)
Attached To
Mode
rP Pacemaker
Attached
Detach File
Event Timeline
Log In to Comment