summaryrefslogtreecommitdiff
path: root/src/test/test-util.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-09-22 11:27:22 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2014-09-22 14:27:02 +0200
commiteee846339d2f76f568c62b3725bf75bcee728115 (patch)
tree385d41182662c1a8a150676024266a9120d2e15f /src/test/test-util.c
parentf6e3ee1493f20823b2c33465458b92f3581af88d (diff)
test-util: make valgrind happy
Properly free all temporary resources to make valgrind not complain about lost records.
Diffstat (limited to 'src/test/test-util.c')
-rw-r--r--src/test/test-util.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 80425ca61a..f8e42f3a55 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -843,11 +843,27 @@ static void test_is_valid_documentation_url(void) {
}
static void test_file_in_same_dir(void) {
- assert_se(streq(file_in_same_dir("/", "a"), "/a"));
- assert_se(streq(file_in_same_dir("/", "/a"), "/a"));
- assert_se(streq(file_in_same_dir("", "a"), "a"));
- assert_se(streq(file_in_same_dir("a/", "a"), "a/a"));
- assert_se(streq(file_in_same_dir("bar/foo", "bar"), "bar/bar"));
+ char *t;
+
+ t = file_in_same_dir("/", "a");
+ assert_se(streq(t, "/a"));
+ free(t);
+
+ t = file_in_same_dir("/", "/a");
+ assert_se(streq(t, "/a"));
+ free(t);
+
+ t = file_in_same_dir("", "a");
+ assert_se(streq(t, "a"));
+ free(t);
+
+ t = file_in_same_dir("a/", "a");
+ assert_se(streq(t, "a/a"));
+ free(t);
+
+ t = file_in_same_dir("bar/foo", "bar");
+ assert_se(streq(t, "bar/bar"));
+ free(t);
}
static void test_endswith(void) {
@@ -1239,11 +1255,13 @@ static void test_unquote_many_words(void) {
assert_se(unquote_many_words(&p, &a, NULL) == 1);
assert_se(p == original+7);
assert_se(streq_ptr(a, "foobar"));
+ free(a);
p = original = " foobar ";
assert_se(unquote_many_words(&p, &a, NULL) == 1);
assert_se(p == original+15);
assert_se(streq_ptr(a, "foobar"));
+ free(a);
}
int main(int argc, char *argv[]) {