summaryrefslogtreecommitdiff
path: root/src/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format.c')
-rw-r--r--src/format.c100
1 files changed, 0 insertions, 100 deletions
diff --git a/src/format.c b/src/format.c
index ed1f571..170f88f 100644
--- a/src/format.c
+++ b/src/format.c
@@ -296,103 +296,3 @@ fmt_pid (rp_window_elem *elem, struct sbuf *buf)
else
sbuf_concat (buf, "?");
}
-
-#ifdef RUN_FORMAT_TEST
-
-#include <assert.h>
-#include <locale.h>
-
-void test_sbuf_utf8_nconcat(void);
-
-int main(void)
-{
- /* We need to set up locale information for multibyte functions to work
- correctly. */
- setlocale(LC_ALL, "");
-
- test_sbuf_utf8_nconcat();
- return 0;
-}
-
-void test_sbuf_utf8_nconcat(void)
-{
- struct sbuf *buf = NULL;
-
- /* Zero length string, no limit. */
-
- buf = sbuf_new(0);
- sbuf_utf8_nconcat(buf, "", -1);
- assert(strcmp(sbuf_get(buf), "") == 0);
- sbuf_free(buf);
-
- /* Zero length string, non-zero limit. */
-
- buf = sbuf_new(0);
- sbuf_utf8_nconcat(buf, "", 5);
- assert(strcmp(sbuf_get(buf), "") == 0);
- sbuf_free(buf);
-
- /* ASCII string, no limit. */
-
- buf = sbuf_new(0);
- sbuf_utf8_nconcat(buf, "hi there", -1);
- assert(strcmp(sbuf_get(buf), "hi there") == 0);
- sbuf_utf8_nconcat(buf, " you", -1);
- assert(strcmp(sbuf_get(buf), "hi there you") == 0);
- sbuf_free(buf);
-
- /* ASCII string, non-zero limit, truncated. */
-
- buf = sbuf_new(0);
- sbuf_utf8_nconcat(buf, "hi there", 4);
- assert(strcmp(sbuf_get(buf), "hi t") == 0);
- sbuf_free(buf);
-
- /* ASCII string, non-zero limit, not truncated. */
-
- buf = sbuf_new(0);
- sbuf_utf8_nconcat(buf, "hi", 4);
- assert(strcmp(sbuf_get(buf), "hi") == 0);
- sbuf_free(buf);
-
- /* UTF-8 string, no limit. */
-
- buf = sbuf_new(0);
- /* 0xe2 0x84 0xa2 is U+2122, the trademark symbol. */
- sbuf_utf8_nconcat(buf, "hi \xe2\x84\xa2 there", -1);
- assert(strcmp(sbuf_get(buf), "hi \xe2\x84\xa2 there") == 0);
- sbuf_free(buf);
-
- /* UTF-8 string, non-zero limit, truncated at an okay spot counting either
- by bytes or by characters. */
-
- buf = sbuf_new(0);
- sbuf_utf8_nconcat(buf, "hi \xe2\x84\xa2 there you", 11);
- assert(strcmp(sbuf_get(buf), "hi \xe2\x84\xa2 there ") == 0);
- sbuf_free(buf);
-
- /* UTF-8 string, non-zero limit, truncated such that if the limit were in
- bytes that we would cut in the middle of a character. */
-
- buf = sbuf_new(0);
- sbuf_utf8_nconcat(buf, "hi \xe2\x84\xa2 there you", 5);
- assert(strcmp(sbuf_get(buf), "hi \xe2\x84\xa2 ") == 0);
- sbuf_free(buf);
-
- /* UTF-8 string, non-zero limit, not truncated. */
-
- buf = sbuf_new(0);
- sbuf_utf8_nconcat(buf, "hi \xe2\x84\xa2 there you", 20);
- assert(strcmp(sbuf_get(buf), "hi \xe2\x84\xa2 there you") == 0);
- sbuf_free(buf);
-
- /* Invalid character. */
-
- buf = sbuf_new(0);
- /* This is an invalid UTF-8 sequence. It's missing 0xa2. */
- sbuf_utf8_nconcat(buf, "hi \xe2\x84 there you", 20);
- assert(strcmp(sbuf_get(buf), "hi ") == 0);
- sbuf_free(buf);
-}
-
-#endif