projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Build fix: build without lttng-ust
[lttng-tools.git]
/
tests
/
unit
/
test_string_utils.c
diff --git
a/tests/unit/test_string_utils.c
b/tests/unit/test_string_utils.c
index b11091637298b4b549ab2888077c47a5c2e78ed8..1d61bc41fbfc8e4c3dae3a2d0c52dca054fe4560 100644
(file)
--- a/
tests/unit/test_string_utils.c
+++ b/
tests/unit/test_string_utils.c
@@
-16,38
+16,49
@@
/* Number of TAP tests in this file */
#define NUM_TESTS 69
/* Number of TAP tests in this file */
#define NUM_TESTS 69
+/* For error.h */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose;
+int lttng_opt_mi;
+
static void test_one_split(const char *input, char delim, int escape_delim,
...)
{
va_list vl;
static void test_one_split(const char *input, char delim, int escape_delim,
...)
{
va_list vl;
- char **substrings;
- char * const *substring;
bool all_ok = true;
bool all_ok = true;
+ struct lttng_dynamic_pointer_array strings;
+ int split_ret;
+ size_t i, string_count;
- s
ubstrings = strutils_split(input, delim, escape_delim
);
- assert(s
ubstrings
);
+ s
plit_ret = strutils_split(input, delim, escape_delim, &strings
);
+ assert(s
plit_ret == 0
);
va_start(vl, escape_delim);
va_start(vl, escape_delim);
- for (substring = substrings; *substring; substring++) {
+ string_count = lttng_dynamic_pointer_array_get_count(&strings);
+
+ for (i = 0; i < string_count; i++) {
const char *expected_substring = va_arg(vl, const char *);
const char *expected_substring = va_arg(vl, const char *);
+ const char *substring =
+ lttng_dynamic_pointer_array_get_pointer(
+ &strings, i);
- diag(" got `%s`, expecting `%s`",
*
substring, expected_substring);
+ diag(" got `%s`, expecting `%s`", substring, expected_substring);
if (!expected_substring) {
all_ok = false;
break;
}
if (!expected_substring) {
all_ok = false;
break;
}
- if (strcmp(
*
substring, expected_substring) != 0) {
+ if (strcmp(substring, expected_substring) != 0) {
all_ok = false;
break;
}
}
all_ok = false;
break;
}
}
-
strutils_free_null_terminated_array_of_strings(sub
strings);
+
lttng_dynamic_pointer_array_reset(&
strings);
va_end(vl);
ok(all_ok, "strutils_split() produces the expected substrings: `%s` (delim. `%c`, escape `%d`)",
va_end(vl);
ok(all_ok, "strutils_split() produces the expected substrings: `%s` (delim. `%c`, escape `%d`)",
- input, delim, escape_delim);
+
input, delim, escape_delim);
}
static void test_split(void)
}
static void test_split(void)
This page took
0.025463 seconds
and
4
git commands to generate.