2
/* NOTE: this code was never being run. The same tests have been
3
migrated to standalone/test-gh.c */
5
/* strings.c --- test the Guile C API's string handling functions
6
Jim Blandy <jimb@red-bean.com> --- August 1999 */
13
string_equal (SCM str, char *lit)
15
int len = strlen (lit);
17
return (SCM_LENGTH (str) == len
18
&& ! memcmp (SCM_ROCHARS (str), lit, len));
24
test_context_t cx = test_enter_context ("gh_set_substr");
27
string = gh_str02scm ("Free, darnit!");
28
test_pass_if ("make a string", gh_string_p (string));
30
gh_set_substr ("dammit", string, 6, 6);
31
test_pass_if ("gh_set_substr from literal",
32
string_equal (string, "Free, dammit!"));
34
/* Make sure that we can use the string itself as a source.
36
I guess this behavior isn't really visible, since the GH API
37
doesn't provide any direct access to the string contents. But I
38
think it should, eventually. You can't write efficient string
39
code if you have to copy the string just to look at it. */
41
/* Copy a substring to an overlapping region to its right. */
42
gh_set_substr (SCM_CHARS (string), string, 4, 6);
43
test_pass_if ("gh_set_substr shifting right",
44
string_equal (string, "FreeFree, it!"));
46
string = gh_str02scm ("Free, darnit!");
47
test_pass_if ("make another string", gh_string_p (string));
49
/* Copy a substring to an overlapping region to its left. */
50
gh_set_substr (SCM_CHARS (string) + 6, string, 2, 6);
51
test_pass_if ("gh_set_substr shifting right",
52
string_equal (string, "Frdarnitrnit!"));
54
test_restore_context (cx);
58
main_prog (int argc, char *argv[])
60
test_context_t strings = test_enter_context ("strings.c");
62
test_gh_set_substr ();
64
test_restore_context (strings);
66
exit (test_summarize ());
70
main (int argc, char *argv[])
72
gh_enter (argc, argv, main_prog);