diff options
author | Neil <nyamatongwe@gmail.com> | 2014-12-22 11:52:44 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2014-12-22 11:52:44 +1100 |
commit | 56efd859ce5996c60eea2a0099dcb3dde13af072 (patch) | |
tree | 653a09e26797d71d74fd32224c035fb1255d6ad6 /test/unit/testUnicodeFromUTF8.cxx | |
parent | 1a11c0356117fd4e7c5f230b974a9dfd5c8a4dc9 (diff) | |
download | scintilla-mirror-56efd859ce5996c60eea2a0099dcb3dde13af072.tar.gz |
Replace function UnicodeFromBytes with UnicodeFromUTF8 as they are exactly the
same.
Add unit tests for UnicodeFromUTF8.
Diffstat (limited to 'test/unit/testUnicodeFromUTF8.cxx')
-rw-r--r-- | test/unit/testUnicodeFromUTF8.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/unit/testUnicodeFromUTF8.cxx b/test/unit/testUnicodeFromUTF8.cxx new file mode 100644 index 000000000..841a9c68c --- /dev/null +++ b/test/unit/testUnicodeFromUTF8.cxx @@ -0,0 +1,44 @@ +// Unit Tests for Scintilla internal data structures + +#include <string.h> + +#include <algorithm> + +#include "Platform.h" + +#include "UnicodeFromUTF8.h" + +#include "catch.hpp" + +// Test UnicodeFromUTF8. +// Use examples from Wikipedia: +// http://en.wikipedia.org/wiki/UTF-8 + +TEST_CASE("UnicodeFromUTF8") { + + SECTION("ASCII") { + const unsigned char s[]={'a', 0}; + REQUIRE(UnicodeFromUTF8(s) == 'a'); + } + + SECTION("Example1") { + const unsigned char s[]={0x24, 0}; + REQUIRE(UnicodeFromUTF8(s) == 0x24); + } + + SECTION("Example2") { + const unsigned char s[]={0xC2, 0xA2, 0}; + REQUIRE(UnicodeFromUTF8(s) == 0xA2); + } + + SECTION("Example3") { + const unsigned char s[]={0xE2, 0x82, 0xAC, 0}; + REQUIRE(UnicodeFromUTF8(s) == 0x20AC); + } + + SECTION("Example4") { + const unsigned char s[]={0xF0, 0x90, 0x8D, 0x88, 0}; + REQUIRE(UnicodeFromUTF8(s) == 0x10348); + } + +} |