Merge branch 'ZackerySpytz-cpp11_u_U_char_encoding_prefixes'
* ZackerySpytz-cpp11_u_U_char_encoding_prefixes: Document C++11 UCS-2 UCS-4 and C++17 UTF8 character literals support c++17 u8 character literals testcase C++17 u8 character literals fix C++17 u8 character literals testcase Fix the Java tests Add support for the C++11 u and U encoding prefixes for char literals
This commit is contained in:
commit
80b79fc583
8 changed files with 85 additions and 3 deletions
|
|
@ -164,6 +164,7 @@ CPP_TEST_CASES += \
|
|||
cpp_typedef \
|
||||
cpp17_nested_namespaces \
|
||||
cpp17_nspace_nested_namespaces \
|
||||
cpp17_u8_char_literals \
|
||||
curiously_recurring_template_pattern \
|
||||
default_args \
|
||||
default_arg_expressions \
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ wstring aa = L"Wide string";
|
|||
const char *bb = u8"UTF-8 string";
|
||||
const char16_t *cc = u"UTF-16 string";
|
||||
const char32_t *dd = U"UTF-32 string";
|
||||
// New char literals
|
||||
char16_t char16_t_char = u'a';
|
||||
char32_t char32_t_char = U'b';
|
||||
%}
|
||||
|
||||
/* Raw string literals */
|
||||
|
|
|
|||
26
Examples/test-suite/cpp17_u8_char_literals.i
Normal file
26
Examples/test-suite/cpp17_u8_char_literals.i
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
%module cpp17_u8_char_literals
|
||||
|
||||
// Tests are designed so that code compiles with C++98 compilers
|
||||
|
||||
%{
|
||||
#if __cplusplus >= 201703L
|
||||
#define CPP17 1
|
||||
#endif
|
||||
%}
|
||||
|
||||
// UTF-8 character literals will (apparently) have type char8_t in C++20.
|
||||
char a = u8'a';
|
||||
char u = u8'u';
|
||||
char u8 = u8'8';
|
||||
|
||||
%{
|
||||
#if defined(CPP17)
|
||||
char a = u8'a';
|
||||
char u = u8'u';
|
||||
char u8 = u8'8';
|
||||
#else
|
||||
char a = 'a';
|
||||
char u = 'u';
|
||||
char u8 = '8';
|
||||
#endif
|
||||
%}
|
||||
10
Examples/test-suite/python/cpp17_u8_char_literals_runme.py
Normal file
10
Examples/test-suite/python/cpp17_u8_char_literals_runme.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from cpp17_u8_char_literals import *
|
||||
|
||||
if cvar.a != 'a':
|
||||
raise RuntimeError
|
||||
|
||||
if cvar.u != 'u':
|
||||
raise RuntimeError
|
||||
|
||||
if cvar.u8 != '8':
|
||||
raise RuntimeError
|
||||
Loading…
Add table
Add a link
Reference in a new issue