commit 2b0888c8135bcfa41bc6e661a5b69a9c2a9deb72
parent a91b9003c3250f5a929b11e5b8716e226887b7d1
Author: Chris Bracken <chris@bracken.jp>
Date: Sat, 26 Jul 2025 08:48:24 -0700
Add tests for print_gopher_link
Diffstat:
1 file changed, 42 insertions(+), 0 deletions(-)
diff --git a/format_tests.c b/format_tests.c
@@ -335,3 +335,45 @@ UTEST(print_gopher_text_len, EmptyString) {
free(buf);
}
+
+UTEST(print_gopher_link, SpecialChars) {
+ char* buf = NULL;
+ size_t size = 0;
+ FILE* out = open_memstream(&buf, &size);
+ ASSERT_NE(NULL, out);
+
+ print_gopher_link(out, "|\t\r\n");
+ fclose(out);
+
+ EXPECT_STREQ("\\| ", buf);
+
+ free(buf);
+}
+
+UTEST(print_gopher_link, MixedContent) {
+ char* buf = NULL;
+ size_t size = 0;
+ FILE* out = open_memstream(&buf, &size);
+ ASSERT_NE(NULL, out);
+
+ print_gopher_link(out, "hello|world\t");
+ fclose(out);
+
+ EXPECT_STREQ("hello\\|world ", buf);
+
+ free(buf);
+}
+
+UTEST(print_gopher_link, EmptyString) {
+ char* buf = NULL;
+ size_t size = 0;
+ FILE* out = open_memstream(&buf, &size);
+ ASSERT_NE(NULL, out);
+
+ print_gopher_link(out, "");
+ fclose(out);
+
+ EXPECT_STREQ("", buf);
+
+ free(buf);
+}