test_buffer: add kmscon_symbol_t test
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 1 Jan 2012 15:52:30 +0000 (16:52 +0100)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 1 Jan 2012 15:52:30 +0000 (16:52 +0100)
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
tests/test_buffer.c

index 82ff24c..c6b75c5 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "console.h"
 #include "log.h"
+#include "unicode.h"
 
 /* print buffer with boundary */
 static void print_buf(struct kmscon_buffer *buf)
@@ -112,6 +113,38 @@ static void test1(struct kmscon_buffer *buf)
        kmscon_char_free(ch);
 }
 
+static void test2()
+{
+       struct kmscon_symbol_table *st;
+       int ret;
+       kmscon_symbol_t sym, sym2, sym3, sym4;
+       const uint32_t *str;
+       size_t len, i;
+
+       log_info("Test2:\n");
+
+       ret = kmscon_symbol_table_new(&st);
+       if (ret)
+               return;
+
+       sym = kmscon_symbol_make('a');
+       sym2 = kmscon_symbol_append(st, sym, '^');
+       sym3 = kmscon_symbol_append(st, sym2, '^');
+       sym4 = kmscon_symbol_append(st, sym, '^');
+
+       log_info("equality: %i %i %i\n", sym == sym2, sym2 == sym4,
+                                                               sym3 == sym2);
+
+       str = kmscon_symbol_get(st, &sym3, &len);
+
+       printf("sym3: ");
+       for (i = 0; i < len; ++i)
+               printf("%c", str[i]);
+       printf("\n");
+
+       kmscon_symbol_table_unref(st);
+}
+
 int main(int argc, char **argv)
 {
        struct kmscon_buffer *buf;
@@ -124,6 +157,7 @@ int main(int argc, char **argv)
        }
 
        test1(buf);
+       test2();
 
        kmscon_buffer_unref(buf);
 err_out: