Changeset 34 for trunk/src/cutest_sh_utils.c
- Timestamp:
- May 19, 2006, 8:09:51 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cutest_sh_utils.c
r22 r34 6 6 #include "samhain.h" 7 7 #include "sh_utils.h" 8 9 void Test_sh_util_strdup_ok (CuTest *tc) { 10 char * ret = 0; 11 char inp[] = "foobar"; 12 13 ret = sh_util_strdup(inp); 14 CuAssertPtrNotNull(tc, ret); 15 CuAssert(tc, "expected inp != ret, but inp == ret", (inp != ret)); 16 CuAssertStrEquals(tc, "foobar", ret); 17 return; 18 } 19 20 void Test_sh_util_strconcat_ok (CuTest *tc) { 21 char * ret = 0; 22 23 ret = sh_util_strconcat("foo", NULL); 24 CuAssertPtrNotNull(tc, ret); 25 CuAssertStrEquals(tc, "foo", ret); 26 27 ret = sh_util_strconcat("foo", "bar", NULL); 28 CuAssertPtrNotNull(tc, ret); 29 CuAssertStrEquals(tc, "foobar", ret); 30 31 ret = sh_util_strconcat("/", "foo", "/", "bar", NULL); 32 CuAssertPtrNotNull(tc, ret); 33 CuAssertStrEquals(tc, "/foo/bar", ret); 34 35 return; 36 } 37 38 void Test_sh_util_dirname_ok (CuTest *tc) { 39 char * ret = 0; 40 41 char input0[] = "/foo/bar"; 42 char res0[] = "/foo"; 43 44 char input1[] = "/foo/bar/"; 45 char res1[] = "/foo"; 46 47 char input2[] = "/foo"; 48 char res2[] = "/"; 49 50 char input3[] = "/"; 51 char res3[] = "/"; 52 53 ret = sh_util_dirname(input0); 54 CuAssertPtrNotNull(tc, ret); 55 CuAssertStrEquals(tc, res0, ret); 56 57 ret = sh_util_dirname(input1); 58 CuAssertPtrNotNull(tc, ret); 59 CuAssertStrEquals(tc, res1, ret); 60 61 ret = sh_util_dirname(input2); 62 CuAssertPtrNotNull(tc, ret); 63 CuAssertStrEquals(tc, res2, ret); 64 65 ret = sh_util_dirname(input3); 66 CuAssertPtrNotNull(tc, ret); 67 CuAssertStrEquals(tc, res3, ret); 68 return; 69 } 70 71 void Test_sh_util_basename_ok (CuTest *tc) { 72 char * ret = 0; 73 74 char input0[] = "/foo/bar"; 75 char res0[] = "bar"; 76 77 char input1[] = "/foo/"; 78 char res1[] = "foo"; 79 80 char input2[] = "/foo"; 81 char res2[] = "foo"; 82 83 char input3[] = "/"; 84 char res3[] = "/"; 85 86 char input4[] = "/foo/bar/"; 87 char res4[] = "bar"; 88 89 ret = sh_util_basename(input0); 90 CuAssertPtrNotNull(tc, ret); 91 CuAssertStrEquals(tc, res0, ret); 92 93 ret = sh_util_basename(input1); 94 CuAssertPtrNotNull(tc, ret); 95 CuAssertStrEquals(tc, res1, ret); 96 97 ret = sh_util_basename(input2); 98 CuAssertPtrNotNull(tc, ret); 99 CuAssertStrEquals(tc, res2, ret); 100 101 ret = sh_util_basename(input3); 102 CuAssertPtrNotNull(tc, ret); 103 CuAssertStrEquals(tc, res3, ret); 104 105 ret = sh_util_basename(input4); 106 CuAssertPtrNotNull(tc, ret); 107 CuAssertStrEquals(tc, res4, ret); 108 109 return; 110 } 8 111 9 112 void Test_sh_util_obscure_ok (CuTest *tc) {
Note:
See TracChangeset
for help on using the changeset viewer.