summaryrefslogtreecommitdiff
path: root/source4/lib/util/tests
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-09-24 16:43:16 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:07:12 -0500
commit6b1c7d36f88b0c7cfdf16628d33512d4bacced88 (patch)
treea15f21185e7654045312978d9001fece25d1b9ed /source4/lib/util/tests
parentf2d64e1c45994e4b519454c071e90e0cd8240c8a (diff)
downloadsamba-6b1c7d36f88b0c7cfdf16628d33512d4bacced88.tar.gz
samba-6b1c7d36f88b0c7cfdf16628d33512d4bacced88.tar.bz2
samba-6b1c7d36f88b0c7cfdf16628d33512d4bacced88.zip
r25307: add string_sub_talloc.
(This used to be commit 96c1a24874289fdeddcac43d23c2d1214b9b6225)
Diffstat (limited to 'source4/lib/util/tests')
-rw-r--r--source4/lib/util/tests/str.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/source4/lib/util/tests/str.c b/source4/lib/util/tests/str.c
index 4a964af0ee..a219ef0891 100644
--- a/source4/lib/util/tests/str.c
+++ b/source4/lib/util/tests/str.c
@@ -58,6 +58,40 @@ static bool test_string_sub_shorter(struct torture_context *tctx)
return true;
}
+static bool test_string_sub_special_char(struct torture_context *tctx)
+{
+ char tmp[100];
+ safe_strcpy(tmp, "foobla", sizeof(tmp));
+ string_sub(tmp, "foo", "%b;l", sizeof(tmp));
+ torture_assert_str_equal(tctx, tmp, "_b_lbla", "invalid sub");
+ return true;
+}
+
+static bool test_string_sub_talloc_simple(struct torture_context *tctx)
+{
+ char *t;
+
+ t = string_sub_talloc(tctx, "foobla", "foo", "bl");
+
+ torture_assert_str_equal(tctx, t, "blbla", "invalid sub");
+
+ return true;
+}
+
+static bool test_string_sub_talloc_multiple(struct torture_context *tctx)
+{
+ char *t;
+
+ t = string_sub_talloc(tctx, "fooblafoo", "foo", "aapnootmies");
+
+ torture_assert_str_equal(tctx, t, "aapnootmiesblaaapnootmies",
+ "invalid sub");
+
+ return true;
+}
+
+
+
struct torture_suite *torture_local_util_str(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "STR");
@@ -74,5 +108,14 @@ struct torture_suite *torture_local_util_str(TALLOC_CTX *mem_ctx)
torture_suite_add_simple_test(suite, "string_sub_longer",
test_string_sub_longer);
+ torture_suite_add_simple_test(suite, "string_sub_special_chars",
+ test_string_sub_special_char);
+
+ torture_suite_add_simple_test(suite, "string_sub_talloc_simple",
+ test_string_sub_talloc_simple);
+
+ torture_suite_add_simple_test(suite, "string_sub_talloc_multiple",
+ test_string_sub_talloc_multiple);
+
return suite;
}