1 // test for AddPart(). Test cases are from Guru Book.
7 int test(STRPTR p1
, CONST_STRPTR p2
, CONST_STRPTR expected
)
11 memset(buffer
, 0, sizeof(buffer
));
14 res
= AddPart(buffer
, p2
, sizeof(buffer
));
18 printf("AddPart() returned DOSFALSE for %s %s\n", p1
, p2
);
22 if (strcmp(buffer
, expected
) != 0)
24 printf("AddPart() created string %s; expected was %s\n", buffer
, expected
);
34 error
+= test("foo", "bar", "foo/bar");
35 error
+= test("foo/", "bar", "foo/bar");
36 error
+= test("foo/baz", "bar", "foo/baz/bar");
37 error
+= test("foo", "bar/baz", "foo/bar/baz");
38 error
+= test("foo:", "bar", "foo:bar");
39 error
+= test("foo:", "bar:", "bar:");
40 error
+= test("foo:baz", ":bar", "foo:bar");
41 error
+= test("foo", "/bar", "foo//bar");
42 error
+= test("foo/", "/bar", "foo//bar");
44 return error
? RETURN_ERROR
: RETURN_OK
;