Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
16c3514d
Commit
16c3514d
authored
Jun 06, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wchar-test -> xchar-test
parent
206000a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
17 deletions
+18
-17
test/CMakeLists.txt
test/CMakeLists.txt
+1
-1
test/xchar-test.cc
test/xchar-test.cc
+17
-16
No files found.
test/CMakeLists.txt
View file @
16c3514d
...
...
@@ -81,7 +81,7 @@ add_fmt_test(unicode-test HEADER_ONLY)
if
(
MSVC
)
target_compile_options
(
unicode-test PRIVATE /utf-8
)
endif
()
add_fmt_test
(
w
char-test
)
add_fmt_test
(
x
char-test
)
if
(
FMT_CAN_MODULE
)
# The tests need {fmt} to be compiled as traditional library
...
...
test/
w
char-test.cc
→
test/
x
char-test.cc
View file @
16c3514d
...
...
@@ -5,12 +5,13 @@
//
// For the license information refer to format.h.
#include "fmt/xchar.h"
#include <complex>
#include "fmt/chrono.h"
#include "fmt/ostream.h"
#include "fmt/ranges.h"
#include "fmt/xchar.h"
#include "gtest/gtest.h"
using
fmt
::
detail
::
max_value
;
...
...
@@ -21,13 +22,13 @@ struct explicitly_convertible_to_wstring_view {
explicit
operator
fmt
::
wstring_view
()
const
{
return
L"foo"
;
}
};
TEST
(
w
char_test
,
format_explicitly_convertible_to_wstring_view
)
{
TEST
(
x
char_test
,
format_explicitly_convertible_to_wstring_view
)
{
EXPECT_EQ
(
L"foo"
,
fmt
::
format
(
L"{}"
,
explicitly_convertible_to_wstring_view
()));
}
#endif
TEST
(
w
char_test
,
format
)
{
TEST
(
x
char_test
,
format
)
{
EXPECT_EQ
(
L"42"
,
fmt
::
format
(
L"{}"
,
42
));
EXPECT_EQ
(
L"4.2"
,
fmt
::
format
(
L"{}"
,
4.2
));
EXPECT_EQ
(
L"abc"
,
fmt
::
format
(
L"{}"
,
L"abc"
));
...
...
@@ -41,7 +42,7 @@ TEST(wchar_test, format) {
EXPECT_EQ
(
L"abc1"
,
fmt
::
format
(
L"{}c{}"
,
L"ab"
,
1
));
}
TEST
(
w
char_test
,
compile_time_string
)
{
TEST
(
x
char_test
,
compile_time_string
)
{
#if defined(FMT_USE_STRING_VIEW) && __cplusplus >= 201703L
EXPECT_EQ
(
L"42"
,
fmt
::
format
(
FMT_STRING
(
std
::
wstring_view
(
L"{}"
)),
42
));
#endif
...
...
@@ -64,7 +65,7 @@ FMT_BEGIN_NAMESPACE
template
<
>
struct
is_char
<
custom_char
>
:
std
::
true_type
{};
FMT_END_NAMESPACE
TEST
(
w
char_test
,
format_custom_char
)
{
TEST
(
x
char_test
,
format_custom_char
)
{
const
custom_char
format
[]
=
{
'{'
,
'}'
,
0
};
auto
result
=
fmt
::
format
(
format
,
custom_char
(
'x'
));
EXPECT_EQ
(
result
.
size
(),
1
);
...
...
@@ -78,7 +79,7 @@ template <typename S> std::string from_u8str(const S& str) {
return
std
::
string
(
str
.
begin
(),
str
.
end
());
}
TEST
(
w
char_test
,
format_utf8_precision
)
{
TEST
(
x
char_test
,
format_utf8_precision
)
{
using
str_type
=
std
::
basic_string
<
fmt
::
detail
::
char8_type
>
;
auto
format
=
str_type
(
reinterpret_cast
<
const
fmt
::
detail
::
char8_type
*>
(
u8"{:.4}"
));
...
...
@@ -90,13 +91,13 @@ TEST(wchar_test, format_utf8_precision) {
EXPECT_EQ
(
from_u8str
(
result
),
from_u8str
(
str
.
substr
(
0
,
5
)));
}
TEST
(
w
char_test
,
format_to
)
{
TEST
(
x
char_test
,
format_to
)
{
auto
buf
=
std
::
vector
<
wchar_t
>
();
fmt
::
format_to
(
std
::
back_inserter
(
buf
),
L"{}{}"
,
42
,
L'\0'
);
EXPECT_STREQ
(
buf
.
data
(),
L"42"
);
}
TEST
(
w
char_test
,
vformat_to
)
{
TEST
(
x
char_test
,
vformat_to
)
{
using
wcontext
=
fmt
::
wformat_context
;
fmt
::
basic_format_arg
<
wcontext
>
warg
=
fmt
::
detail
::
make_arg
<
wcontext
>
(
42
);
auto
wargs
=
fmt
::
basic_format_args
<
wcontext
>
(
&
warg
,
1
);
...
...
@@ -129,12 +130,12 @@ TEST(format_test, wide_format_to_n) {
}
#if FMT_USE_USER_DEFINED_LITERALS
TEST
(
w
char_test
,
format_udl
)
{
TEST
(
x
char_test
,
format_udl
)
{
using
namespace
fmt
::
literals
;
EXPECT_EQ
(
L"{}c{}"
_format
(
L"ab"
,
1
),
fmt
::
format
(
L"{}c{}"
,
L"ab"
,
1
));
}
TEST
(
w
char_test
,
named_arg_udl
)
{
TEST
(
x
char_test
,
named_arg_udl
)
{
using
namespace
fmt
::
literals
;
auto
udl_a
=
fmt
::
format
(
L"{first}{second}{first}{third}"
,
L"first"
_a
=
L"abra"
,
...
...
@@ -146,12 +147,12 @@ TEST(wchar_test, named_arg_udl) {
}
#endif // FMT_USE_USER_DEFINED_LITERALS
TEST
(
w
char_test
,
print
)
{
TEST
(
x
char_test
,
print
)
{
// Check that the wide print overload compiles.
if
(
fmt
::
detail
::
const_check
(
false
))
fmt
::
print
(
L"test"
);
}
TEST
(
w
char_test
,
join
)
{
TEST
(
x
char_test
,
join
)
{
int
v
[
3
]
=
{
1
,
2
,
3
};
EXPECT_EQ
(
fmt
::
format
(
L"({})"
,
fmt
::
join
(
v
,
v
+
3
,
L", "
)),
L"(1, 2, 3)"
);
auto
t
=
std
::
tuple
<
wchar_t
,
int
,
float
>
(
'a'
,
1
,
2.0
f
);
...
...
@@ -166,12 +167,12 @@ std::wostream& operator<<(std::wostream& os, streamable_enum) {
enum
unstreamable_enum
{};
TEST
(
w
char_test
,
enum
)
{
TEST
(
x
char_test
,
enum
)
{
EXPECT_EQ
(
L"streamable_enum"
,
fmt
::
format
(
L"{}"
,
streamable_enum
()));
EXPECT_EQ
(
L"0"
,
fmt
::
format
(
L"{}"
,
unstreamable_enum
()));
}
TEST
(
w
char_test
,
sign_not_truncated
)
{
TEST
(
x
char_test
,
sign_not_truncated
)
{
wchar_t
format_str
[]
=
{
L'{'
,
L':'
,
'+'
|
static_cast
<
wchar_t
>
(
1
<<
fmt
::
detail
::
num_bits
<
char
>
()),
L'}'
,
0
};
...
...
@@ -200,7 +201,7 @@ TEST(format_test, format_foreign_strings) {
EXPECT_EQ
(
fmt
::
format
(
QString
(
L"{}"
),
QString
(
L"42"
)),
L"42"
);
}
TEST
(
w
char_test
,
chrono
)
{
TEST
(
x
char_test
,
chrono
)
{
auto
tm
=
std
::
tm
();
tm
.
tm_year
=
116
;
tm
.
tm_mon
=
3
;
...
...
@@ -213,7 +214,7 @@ TEST(wchar_test, chrono) {
EXPECT_EQ
(
L"42s"
,
fmt
::
format
(
L"{}"
,
std
::
chrono
::
seconds
(
42
)));
}
TEST
(
w
char_test
,
to_wstring
)
{
EXPECT_EQ
(
L"42"
,
fmt
::
to_wstring
(
42
));
}
TEST
(
x
char_test
,
to_wstring
)
{
EXPECT_EQ
(
L"42"
,
fmt
::
to_wstring
(
42
));
}
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
template
<
typename
Char
>
struct
numpunct
:
std
::
numpunct
<
Char
>
{
...
...
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