Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
727dd466
Unverified
Commit
727dd466
authored
Apr 02, 2018
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
trying to make tests run with MSVC #1031
parent
ab89ae4e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
unit-wstring.cpp
test/src/unit-wstring.cpp
+18
-10
No files found.
test/src/unit-wstring.cpp
View file @
727dd466
...
@@ -32,21 +32,29 @@ SOFTWARE.
...
@@ -32,21 +32,29 @@ SOFTWARE.
using
nlohmann
::
json
;
using
nlohmann
::
json
;
// from https://www.reddit.com/r/cpp/comments/75gohf/i_just_found_a_use_for_the_poop_emoji_in_c/
bool
wstring_is_utf16
();
constexpr
bool
compiler_supports_utf8
();
bool
wstring_is_utf16
()
constexpr
bool
compiler_supports_utf8
()
{
{
return
(
static_cast
<
unsigned
char
>
(
"💩"
[
0
])
==
0xF0
)
and
return
(
std
::
wstring
(
L"💩"
)
==
std
::
wstring
(
L"\U0001F4A9"
));
(
static_cast
<
unsigned
char
>
(
"💩"
[
1
])
==
0x9F
)
and
}
(
static_cast
<
unsigned
char
>
(
"💩"
[
2
])
==
0x92
)
and
(
static_cast
<
unsigned
char
>
(
"💩"
[
3
])
==
0xA9
);
bool
u16string_is_utf16
();
bool
u16string_is_utf16
()
{
return
(
std
::
u16string
(
u"💩"
)
==
std
::
u16string
(
u"\U0001F4A9"
));
}
bool
u32string_is_utf32
();
bool
u32string_is_utf32
()
{
return
(
std
::
u32string
(
U"💩"
)
==
std
::
u32string
(
U"\U0001F4A9"
));
}
}
TEST_CASE
(
"wide strings"
)
TEST_CASE
(
"wide strings"
)
{
{
SECTION
(
"std::wstring"
)
SECTION
(
"std::wstring"
)
{
{
if
(
compiler_supports_utf8
())
if
(
wstring_is_utf16
())
{
{
std
::
wstring
w
=
L"[12.2,
\"
Ⴥaäö💤🧢
\"
]"
;
std
::
wstring
w
=
L"[12.2,
\"
Ⴥaäö💤🧢
\"
]"
;
json
j
=
json
::
parse
(
w
);
json
j
=
json
::
parse
(
w
);
...
@@ -56,7 +64,7 @@ TEST_CASE("wide strings")
...
@@ -56,7 +64,7 @@ TEST_CASE("wide strings")
SECTION
(
"std::u16string"
)
SECTION
(
"std::u16string"
)
{
{
if
(
compiler_supports_utf8
())
if
(
u16string_is_utf16
())
{
{
std
::
u16string
w
=
u"[12.2,
\"
Ⴥaäö💤🧢
\"
]"
;
std
::
u16string
w
=
u"[12.2,
\"
Ⴥaäö💤🧢
\"
]"
;
json
j
=
json
::
parse
(
w
);
json
j
=
json
::
parse
(
w
);
...
@@ -66,7 +74,7 @@ TEST_CASE("wide strings")
...
@@ -66,7 +74,7 @@ TEST_CASE("wide strings")
SECTION
(
"std::u32string"
)
SECTION
(
"std::u32string"
)
{
{
if
(
compiler_supports_utf8
())
if
(
u32string_is_utf32
())
{
{
std
::
u32string
w
=
U"[12.2,
\"
Ⴥaäö💤🧢
\"
]"
;
std
::
u32string
w
=
U"[12.2,
\"
Ⴥaäö💤🧢
\"
]"
;
json
j
=
json
::
parse
(
w
);
json
j
=
json
::
parse
(
w
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment