From ecf68362c0c8b34cfd7a9a25083af877f7537374 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 27 Jul 2017 12:38:49 +0000 Subject: [PATCH] .autotest git-svn-id: svn://ultimatepp.org/upp/trunk@11268 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- autotest/JsonEmoticon/JsonEmoticon.cpp | 41 ++++++++++++++++++++++++++ autotest/JsonEmoticon/JsonEmoticon.upp | 11 +++++++ 2 files changed, 52 insertions(+) create mode 100644 autotest/JsonEmoticon/JsonEmoticon.cpp create mode 100644 autotest/JsonEmoticon/JsonEmoticon.upp diff --git a/autotest/JsonEmoticon/JsonEmoticon.cpp b/autotest/JsonEmoticon/JsonEmoticon.cpp new file mode 100644 index 000000000..4a4538c5c --- /dev/null +++ b/autotest/JsonEmoticon/JsonEmoticon.cpp @@ -0,0 +1,41 @@ +#include + +using namespace Upp; + +CONSOLE_APP_MAIN +{ + StdLogSetup(LOG_COUT|LOG_FILE); + + dword emoticon = 0x1f60d; // Smiling Face With Heart-shaped Eyes + + String text = "Český 아침글"; + Vector h = ToUtf32(text); + h.Add('\n'); + h.Add(emoticon); + h.Add(31); + DUMP(h); + + dword ref[] = { 268, 101, 115, 107, 253, 32, 50500, 52840, 44544, 10, 128525, 31 }; + + ASSERT(__countof(ref) == h.GetCount()); + + for(int i = 0; i < h.GetCount(); i++) + ASSERT(h[i] == ref[i]); + + text = ToUtf8(h); + + String json = AsJSON(text); + + DUMP(json); + + ASSERT(json == "\"Český 아침글\\n\\uD83D\\uDE0D\\u001F\""); + + String text2 = ParseJSON(json); + + DUMP(text2); + + ASSERT(text2 == text); + ASSERT(ToUtf32(text2) == h); + + LOG("=================== OK"); +} diff --git a/autotest/JsonEmoticon/JsonEmoticon.upp b/autotest/JsonEmoticon/JsonEmoticon.upp new file mode 100644 index 000000000..049ec8972 --- /dev/null +++ b/autotest/JsonEmoticon/JsonEmoticon.upp @@ -0,0 +1,11 @@ +description "Testing surrogate pairs in JSON\377"; + +uses + Core; + +file + JsonEmoticon.cpp; + +mainconfig + "" = ""; +