diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2023-12-12 21:27:08 +0100 |
---|---|---|
committer | Rodrigo Arias Mallo <rodrigo.arias@bsc.es> | 2023-12-21 01:05:58 +0100 |
commit | 1da1260af72b20126176e2b8f73f7b7fd5952ce1 (patch) | |
tree | 0fcdb276d30814ce4075f7cc205e357b2b7c1be5 /test/unit/unicode_test.cc | |
parent | 78ad5bfe9644d1217f9d9ad0bf2fcdc388551113 (diff) |
Split tests into unit and dw (graphical)
Graphical tests for the dw (Dillo Widget) are moved to test/dw, while
unit tests are placed into test/unit.
All tests are compiled with "make check" but only the tests that can run
without intervention and without a graphic display are executed.
Diffstat (limited to 'test/unit/unicode_test.cc')
-rw-r--r-- | test/unit/unicode_test.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/unit/unicode_test.cc b/test/unit/unicode_test.cc new file mode 100644 index 00000000..7c079305 --- /dev/null +++ b/test/unit/unicode_test.cc @@ -0,0 +1,39 @@ +#include <string.h> +#include <stdio.h> +#include <FL/fl_utf8.h> +#include "../lout/unicode.hh" + +using namespace lout::unicode; + +int main (int argc, char *argv[]) +{ + // 0-terminated string + const char *t1 = "abcäöüабв−‐"; + + // not 0-terminated; copy from 0-terminated + int t2len = strlen (t1); + char t2[t2len]; + for (int i = 0; i < t2len; i++) + t2[i] = t1[i]; + + puts ("===== misc::unicode, 0-terminated ====="); + for (const char *s = t1; s; s = nextUtf8Char (s)) + printf ("%3d -> U+%04x ('%s')\n", (int)(s - t1), decodeUtf8(s), s); + + puts ("===== Fltk, 0-terminated ====="); + for (const char *s = t1; *s; s = fl_utf8fwd (s + 1, t1, t1 + strlen (t1))) + printf ("%3d -> U+%04x ('%s')\n", (int)(s - t1), decodeUtf8(s), s); + + puts ("===== misc::unicode, not 0-terminated ====="); + for (const char *s = t2; s; s = nextUtf8Char (s, t2len - (s - t2))) + printf ("%3d -> U+%04x\n", (int)(s - t2), + decodeUtf8(s, t2len - (s - t2))); + + puts ("===== Fltk, not 0-terminated ====="); + for (const char *s = t2; *s; + s - t2 < t2len && (s = fl_utf8fwd (s + 1, t2, t2 + t2len))) + printf ("%3d -> U+%04x\n", (int)(s - t2), + decodeUtf8(s, t2len - (s - t2))); + + return 0; +} |