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
8cf4c520
Commit
8cf4c520
authored
Dec 21, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply clang-format
parent
74532c23
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
41 deletions
+45
-41
include/fmt/core.h
include/fmt/core.h
+2
-1
include/fmt/printf.h
include/fmt/printf.h
+5
-4
test/core-test.cc
test/core-test.cc
+6
-5
test/format-impl-test.cc
test/format-impl-test.cc
+4
-4
test/os-test.cc
test/os-test.cc
+7
-7
test/posix-mock-test.cc
test/posix-mock-test.cc
+17
-17
test/printf-test.cc
test/printf-test.cc
+2
-1
test/std-format-test.cc
test/std-format-test.cc
+2
-2
No files found.
include/fmt/core.h
View file @
8cf4c520
...
@@ -725,7 +725,8 @@ struct type_constant : std::integral_constant<type, type::custom_type> {};
...
@@ -725,7 +725,8 @@ struct type_constant : std::integral_constant<type, type::custom_type> {};
#define FMT_TYPE_CONSTANT(Type, constant) \
#define FMT_TYPE_CONSTANT(Type, constant) \
template <typename Char> \
template <typename Char> \
struct type_constant<Type, Char> : std::integral_constant<type, type::constant> {}
struct type_constant<Type, Char> \
: std::integral_constant<type, type::constant> {}
FMT_TYPE_CONSTANT
(
const
named_arg_base
<
Char
>&
,
named_arg_type
);
FMT_TYPE_CONSTANT
(
const
named_arg_base
<
Char
>&
,
named_arg_type
);
FMT_TYPE_CONSTANT
(
int
,
int_type
);
FMT_TYPE_CONSTANT
(
int
,
int_type
);
...
...
include/fmt/printf.h
View file @
8cf4c520
...
@@ -406,8 +406,9 @@ basic_printf_context<OutputIt, Char>::get_arg(int arg_index) {
...
@@ -406,8 +406,9 @@ basic_printf_context<OutputIt, Char>::get_arg(int arg_index) {
}
}
template
<
typename
OutputIt
,
typename
Char
>
template
<
typename
OutputIt
,
typename
Char
>
int
basic_printf_context
<
OutputIt
,
Char
>::
parse_header
(
int
basic_printf_context
<
OutputIt
,
Char
>::
parse_header
(
const
Char
*&
it
,
const
Char
*&
it
,
const
Char
*
end
,
format_specs
&
specs
)
{
const
Char
*
end
,
format_specs
&
specs
)
{
int
arg_index
=
-
1
;
int
arg_index
=
-
1
;
char_type
c
=
*
it
;
char_type
c
=
*
it
;
if
(
c
>=
'0'
&&
c
<=
'9'
)
{
if
(
c
>=
'0'
&&
c
<=
'9'
)
{
...
@@ -476,8 +477,8 @@ OutputIt basic_printf_context<OutputIt, Char>::format() {
...
@@ -476,8 +477,8 @@ OutputIt basic_printf_context<OutputIt, Char>::format() {
specs
.
precision
=
parse_nonnegative_int
(
it
,
end
,
eh
);
specs
.
precision
=
parse_nonnegative_int
(
it
,
end
,
eh
);
}
else
if
(
c
==
'*'
)
{
}
else
if
(
c
==
'*'
)
{
++
it
;
++
it
;
specs
.
precision
=
specs
.
precision
=
static_cast
<
int
>
(
static_cast
<
int
>
(
visit_format_arg
(
internal
::
printf_precision_handler
(),
get_arg
()));
visit_format_arg
(
internal
::
printf_precision_handler
(),
get_arg
()));
}
else
{
}
else
{
specs
.
precision
=
0
;
specs
.
precision
=
0
;
}
}
...
...
test/core-test.cc
View file @
8cf4c520
...
@@ -457,7 +457,8 @@ TEST(CoreTest, HasFormatter) {
...
@@ -457,7 +457,8 @@ TEST(CoreTest, HasFormatter) {
using
context
=
fmt
::
format_context
;
using
context
=
fmt
::
format_context
;
static_assert
(
has_formatter
<
enabled_formatter
,
context
>::
value
,
""
);
static_assert
(
has_formatter
<
enabled_formatter
,
context
>::
value
,
""
);
static_assert
(
!
has_formatter
<
disabled_formatter
,
context
>::
value
,
""
);
static_assert
(
!
has_formatter
<
disabled_formatter
,
context
>::
value
,
""
);
static_assert
(
!
has_formatter
<
disabled_formatter_convertible
,
context
>::
value
,
""
);
static_assert
(
!
has_formatter
<
disabled_formatter_convertible
,
context
>::
value
,
""
);
}
}
struct
convertible_to_int
{
struct
convertible_to_int
{
...
@@ -616,7 +617,7 @@ TEST(FormatterTest, FormatExplicitlyConvertibleToStringView) {
...
@@ -616,7 +617,7 @@ TEST(FormatterTest, FormatExplicitlyConvertibleToStringView) {
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
"{}"
,
explicitly_convertible_to_string_view
()));
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
"{}"
,
explicitly_convertible_to_string_view
()));
}
}
#ifdef FMT_USE_STRING_VIEW
#
ifdef FMT_USE_STRING_VIEW
struct
explicitly_convertible_to_std_string_view
{
struct
explicitly_convertible_to_std_string_view
{
explicit
operator
std
::
string_view
()
const
{
return
"foo"
;
}
explicit
operator
std
::
string_view
()
const
{
return
"foo"
;
}
};
};
...
@@ -625,7 +626,7 @@ TEST(FormatterTest, FormatExplicitlyConvertibleToStdStringView) {
...
@@ -625,7 +626,7 @@ TEST(FormatterTest, FormatExplicitlyConvertibleToStdStringView) {
EXPECT_EQ
(
"foo"
,
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
"{}"
,
explicitly_convertible_to_std_string_view
()));
fmt
::
format
(
"{}"
,
explicitly_convertible_to_std_string_view
()));
}
}
#endif
#
endif
struct
explicitly_convertible_to_wstring_view
{
struct
explicitly_convertible_to_wstring_view
{
explicit
operator
fmt
::
wstring_view
()
const
{
return
L"foo"
;
}
explicit
operator
fmt
::
wstring_view
()
const
{
return
L"foo"
;
}
...
@@ -639,9 +640,9 @@ TEST(FormatterTest, FormatExplicitlyConvertibleToWStringView) {
...
@@ -639,9 +640,9 @@ TEST(FormatterTest, FormatExplicitlyConvertibleToWStringView) {
struct
disabled_rvalue_conversion
{
struct
disabled_rvalue_conversion
{
operator
const
char
*
()
const
&
{
return
"foo"
;
}
operator
const
char
*
()
const
&
{
return
"foo"
;
}
operator
const
char
*
()
&
{
return
"foo"
;
}
operator
const
char
*
()
&
{
return
"foo"
;
}
operator
const
char
*
()
const
&&
=
delete
;
operator
const
char
*
()
const
&&
=
delete
;
operator
const
char
*
()
&&
=
delete
;
operator
const
char
*
()
&&
=
delete
;
};
};
TEST
(
FormatterTest
,
DisabledRValueConversion
)
{
TEST
(
FormatterTest
,
DisabledRValueConversion
)
{
...
...
test/format-impl-test.cc
View file @
8cf4c520
...
@@ -272,8 +272,8 @@ TEST(FPTest, GetCachedPower) {
...
@@ -272,8 +272,8 @@ TEST(FPTest, GetCachedPower) {
}
}
TEST
(
FPTest
,
GetRoundDirection
)
{
TEST
(
FPTest
,
GetRoundDirection
)
{
using
fmt
::
internal
::
round_direction
;
using
fmt
::
internal
::
get_round_direction
;
using
fmt
::
internal
::
get_round_direction
;
using
fmt
::
internal
::
round_direction
;
EXPECT_EQ
(
round_direction
::
down
,
get_round_direction
(
100
,
50
,
0
));
EXPECT_EQ
(
round_direction
::
down
,
get_round_direction
(
100
,
50
,
0
));
EXPECT_EQ
(
round_direction
::
up
,
get_round_direction
(
100
,
51
,
0
));
EXPECT_EQ
(
round_direction
::
up
,
get_round_direction
(
100
,
51
,
0
));
EXPECT_EQ
(
round_direction
::
down
,
get_round_direction
(
100
,
40
,
10
));
EXPECT_EQ
(
round_direction
::
down
,
get_round_direction
(
100
,
40
,
10
));
...
@@ -448,8 +448,8 @@ TEST(UtilTest, CountDigits) {
...
@@ -448,8 +448,8 @@ TEST(UtilTest, CountDigits) {
TEST
(
UtilTest
,
WriteUIntPtr
)
{
TEST
(
UtilTest
,
WriteUIntPtr
)
{
fmt
::
memory_buffer
buf
;
fmt
::
memory_buffer
buf
;
fmt
::
internal
::
writer
writer
(
buf
);
fmt
::
internal
::
writer
writer
(
buf
);
writer
.
write_pointer
(
fmt
::
internal
::
fallback_uintptr
(
writer
.
write_pointer
(
reinterpret_cast
<
void
*>
(
0xface
)),
fmt
::
internal
::
fallback_uintptr
(
reinterpret_cast
<
void
*>
(
0xface
)),
nullptr
);
nullptr
);
EXPECT_EQ
(
"0xface"
,
to_string
(
buf
));
EXPECT_EQ
(
"0xface"
,
to_string
(
buf
));
}
}
test/os-test.cc
View file @
8cf4c520
...
@@ -22,7 +22,7 @@ using fmt::error_code;
...
@@ -22,7 +22,7 @@ using fmt::error_code;
#ifdef _WIN32
#ifdef _WIN32
#include <windows.h>
#
include <windows.h>
TEST
(
UtilTest
,
UTF16ToUTF8
)
{
TEST
(
UtilTest
,
UTF16ToUTF8
)
{
std
::
string
s
=
"ёжик"
;
std
::
string
s
=
"ёжик"
;
...
@@ -267,7 +267,7 @@ TEST(BufferedFileTest, CloseError) {
...
@@ -267,7 +267,7 @@ TEST(BufferedFileTest, CloseError) {
TEST
(
BufferedFileTest
,
Fileno
)
{
TEST
(
BufferedFileTest
,
Fileno
)
{
buffered_file
f
;
buffered_file
f
;
#ifndef __COVERITY__
#
ifndef __COVERITY__
// fileno on a null FILE pointer either crashes or returns an error.
// fileno on a null FILE pointer either crashes or returns an error.
// Disable Coverity because this is intentional.
// Disable Coverity because this is intentional.
EXPECT_DEATH_IF_SUPPORTED
(
EXPECT_DEATH_IF_SUPPORTED
(
...
@@ -279,7 +279,7 @@ TEST(BufferedFileTest, Fileno) {
...
@@ -279,7 +279,7 @@ TEST(BufferedFileTest, Fileno) {
}
}
},
},
""
);
""
);
#endif
#
endif
f
=
open_buffered_file
();
f
=
open_buffered_file
();
EXPECT_TRUE
(
f
.
fileno
()
!=
-
1
);
EXPECT_TRUE
(
f
.
fileno
()
!=
-
1
);
file
copy
=
file
::
dup
(
f
.
fileno
());
file
copy
=
file
::
dup
(
f
.
fileno
());
...
@@ -431,13 +431,13 @@ TEST(FileTest, Dup) {
...
@@ -431,13 +431,13 @@ TEST(FileTest, Dup) {
EXPECT_EQ
(
FILE_CONTENT
,
read
(
copy
,
std
::
strlen
(
FILE_CONTENT
)));
EXPECT_EQ
(
FILE_CONTENT
,
read
(
copy
,
std
::
strlen
(
FILE_CONTENT
)));
}
}
#ifndef __COVERITY__
#
ifndef __COVERITY__
TEST
(
FileTest
,
DupError
)
{
TEST
(
FileTest
,
DupError
)
{
int
value
=
-
1
;
int
value
=
-
1
;
EXPECT_SYSTEM_ERROR_NOASSERT
(
file
::
dup
(
value
),
EBADF
,
EXPECT_SYSTEM_ERROR_NOASSERT
(
file
::
dup
(
value
),
EBADF
,
"cannot duplicate file descriptor -1"
);
"cannot duplicate file descriptor -1"
);
}
}
#endif
#
endif
TEST
(
FileTest
,
Dup2
)
{
TEST
(
FileTest
,
Dup2
)
{
file
f
=
open_file
();
file
f
=
open_file
();
...
@@ -487,12 +487,12 @@ TEST(FileTest, Fdopen) {
...
@@ -487,12 +487,12 @@ TEST(FileTest, Fdopen) {
EXPECT_EQ
(
read_fd
,
FMT_POSIX
(
fileno
(
read_end
.
fdopen
(
"r"
).
get
())));
EXPECT_EQ
(
read_fd
,
FMT_POSIX
(
fileno
(
read_end
.
fdopen
(
"r"
).
get
())));
}
}
#ifdef FMT_LOCALE
#
ifdef FMT_LOCALE
TEST
(
LocaleTest
,
Strtod
)
{
TEST
(
LocaleTest
,
Strtod
)
{
fmt
::
Locale
locale
;
fmt
::
Locale
locale
;
const
char
*
start
=
"4.2"
,
*
ptr
=
start
;
const
char
*
start
=
"4.2"
,
*
ptr
=
start
;
EXPECT_EQ
(
4.2
,
locale
.
strtod
(
ptr
));
EXPECT_EQ
(
4.2
,
locale
.
strtod
(
ptr
));
EXPECT_EQ
(
start
+
3
,
ptr
);
EXPECT_EQ
(
start
+
3
,
ptr
);
}
}
#endif
#
endif
#endif // FMT_USE_FCNTL
#endif // FMT_USE_FCNTL
\ No newline at end of file
test/posix-mock-test.cc
View file @
8cf4c520
...
@@ -201,17 +201,17 @@ static void write_file(fmt::cstring_view filename, fmt::string_view content) {
...
@@ -201,17 +201,17 @@ static void write_file(fmt::cstring_view filename, fmt::string_view content) {
using
fmt
::
file
;
using
fmt
::
file
;
TEST
(
UtilTest
,
GetPageSize
)
{
TEST
(
UtilTest
,
GetPageSize
)
{
#ifdef _WIN32
#
ifdef _WIN32
SYSTEM_INFO
si
=
{};
SYSTEM_INFO
si
=
{};
GetSystemInfo
(
&
si
);
GetSystemInfo
(
&
si
);
EXPECT_EQ
(
si
.
dwPageSize
,
fmt
::
getpagesize
());
EXPECT_EQ
(
si
.
dwPageSize
,
fmt
::
getpagesize
());
#else
#
else
EXPECT_EQ
(
sysconf
(
_SC_PAGESIZE
),
fmt
::
getpagesize
());
EXPECT_EQ
(
sysconf
(
_SC_PAGESIZE
),
fmt
::
getpagesize
());
sysconf_error
=
true
;
sysconf_error
=
true
;
EXPECT_SYSTEM_ERROR
(
fmt
::
getpagesize
(),
EINVAL
,
EXPECT_SYSTEM_ERROR
(
fmt
::
getpagesize
(),
EINVAL
,
"cannot get memory page size"
);
"cannot get memory page size"
);
sysconf_error
=
false
;
sysconf_error
=
false
;
#endif
#
endif
}
}
TEST
(
FileTest
,
OpenRetry
)
{
TEST
(
FileTest
,
OpenRetry
)
{
...
@@ -219,10 +219,10 @@ TEST(FileTest, OpenRetry) {
...
@@ -219,10 +219,10 @@ TEST(FileTest, OpenRetry) {
std
::
unique_ptr
<
file
>
f
{
nullptr
};
std
::
unique_ptr
<
file
>
f
{
nullptr
};
EXPECT_RETRY
(
f
.
reset
(
new
file
(
"test"
,
file
::
RDONLY
)),
open
,
EXPECT_RETRY
(
f
.
reset
(
new
file
(
"test"
,
file
::
RDONLY
)),
open
,
"cannot open file test"
);
"cannot open file test"
);
#ifndef _WIN32
#
ifndef _WIN32
char
c
=
0
;
char
c
=
0
;
f
->
read
(
&
c
,
1
);
f
->
read
(
&
c
,
1
);
#endif
#
endif
}
}
TEST
(
FileTest
,
CloseNoRetryInDtor
)
{
TEST
(
FileTest
,
CloseNoRetryInDtor
)
{
...
@@ -256,17 +256,17 @@ TEST(FileTest, Size) {
...
@@ -256,17 +256,17 @@ TEST(FileTest, Size) {
file
f
(
"test"
,
file
::
RDONLY
);
file
f
(
"test"
,
file
::
RDONLY
);
EXPECT_GE
(
f
.
size
(),
0
);
EXPECT_GE
(
f
.
size
(),
0
);
EXPECT_EQ
(
content
.
size
(),
static_cast
<
unsigned
long
long
>
(
f
.
size
()));
EXPECT_EQ
(
content
.
size
(),
static_cast
<
unsigned
long
long
>
(
f
.
size
()));
#ifdef _WIN32
#
ifdef _WIN32
fmt
::
memory_buffer
message
;
fmt
::
memory_buffer
message
;
fmt
::
internal
::
format_windows_error
(
message
,
ERROR_ACCESS_DENIED
,
fmt
::
internal
::
format_windows_error
(
message
,
ERROR_ACCESS_DENIED
,
"cannot get file size"
);
"cannot get file size"
);
fstat_sim
=
ERROR
;
fstat_sim
=
ERROR
;
EXPECT_THROW_MSG
(
f
.
size
(),
fmt
::
windows_error
,
fmt
::
to_string
(
message
));
EXPECT_THROW_MSG
(
f
.
size
(),
fmt
::
windows_error
,
fmt
::
to_string
(
message
));
fstat_sim
=
NONE
;
fstat_sim
=
NONE
;
#else
#
else
f
.
close
();
f
.
close
();
EXPECT_SYSTEM_ERROR
(
f
.
size
(),
EBADF
,
"cannot get file attributes"
);
EXPECT_SYSTEM_ERROR
(
f
.
size
(),
EBADF
,
"cannot get file attributes"
);
#endif
#
endif
}
}
TEST
(
FileTest
,
MaxSize
)
{
TEST
(
FileTest
,
MaxSize
)
{
...
@@ -299,16 +299,16 @@ TEST(FileTest, WriteRetry) {
...
@@ -299,16 +299,16 @@ TEST(FileTest, WriteRetry) {
EXPECT_RETRY
(
count
=
write_end
.
write
(
"test"
,
SIZE
),
write
,
EXPECT_RETRY
(
count
=
write_end
.
write
(
"test"
,
SIZE
),
write
,
"cannot write to file"
);
"cannot write to file"
);
write_end
.
close
();
write_end
.
close
();
#ifndef _WIN32
#
ifndef _WIN32
EXPECT_EQ
(
static_cast
<
std
::
streamsize
>
(
SIZE
),
count
);
EXPECT_EQ
(
static_cast
<
std
::
streamsize
>
(
SIZE
),
count
);
char
buffer
[
SIZE
+
1
];
char
buffer
[
SIZE
+
1
];
read_end
.
read
(
buffer
,
SIZE
);
read_end
.
read
(
buffer
,
SIZE
);
buffer
[
SIZE
]
=
'\0'
;
buffer
[
SIZE
]
=
'\0'
;
EXPECT_STREQ
(
"test"
,
buffer
);
EXPECT_STREQ
(
"test"
,
buffer
);
#endif
#
endif
}
}
#ifdef _WIN32
#
ifdef _WIN32
TEST
(
FileTest
,
ConvertReadCount
)
{
TEST
(
FileTest
,
ConvertReadCount
)
{
file
read_end
,
write_end
;
file
read_end
,
write_end
;
file
::
pipe
(
read_end
,
write_end
);
file
::
pipe
(
read_end
,
write_end
);
...
@@ -334,7 +334,7 @@ TEST(FileTest, ConvertWriteCount) {
...
@@ -334,7 +334,7 @@ TEST(FileTest, ConvertWriteCount) {
write_count
=
0
;
write_count
=
0
;
EXPECT_EQ
(
UINT_MAX
,
write_nbyte
);
EXPECT_EQ
(
UINT_MAX
,
write_nbyte
);
}
}
#endif
#
endif
TEST
(
FileTest
,
DupNoRetry
)
{
TEST
(
FileTest
,
DupNoRetry
)
{
int
stdout_fd
=
FMT_POSIX
(
fileno
(
stdout
));
int
stdout_fd
=
FMT_POSIX
(
fileno
(
stdout
));
...
@@ -359,11 +359,11 @@ TEST(FileTest, Dup2NoExceptRetry) {
...
@@ -359,11 +359,11 @@ TEST(FileTest, Dup2NoExceptRetry) {
error_code
ec
;
error_code
ec
;
dup2_count
=
1
;
dup2_count
=
1
;
f1
.
dup2
(
f2
.
descriptor
(),
ec
);
f1
.
dup2
(
f2
.
descriptor
(),
ec
);
#ifndef _WIN32
#
ifndef _WIN32
EXPECT_EQ
(
4
,
dup2_count
);
EXPECT_EQ
(
4
,
dup2_count
);
#else
#
else
EXPECT_EQ
(
EINTR
,
ec
.
get
());
EXPECT_EQ
(
EINTR
,
ec
.
get
());
#endif
#
endif
dup2_count
=
0
;
dup2_count
=
0
;
}
}
...
@@ -389,11 +389,11 @@ TEST(BufferedFileTest, OpenRetry) {
...
@@ -389,11 +389,11 @@ TEST(BufferedFileTest, OpenRetry) {
std
::
unique_ptr
<
buffered_file
>
f
{
nullptr
};
std
::
unique_ptr
<
buffered_file
>
f
{
nullptr
};
EXPECT_RETRY
(
f
.
reset
(
new
buffered_file
(
"test"
,
"r"
)),
fopen
,
EXPECT_RETRY
(
f
.
reset
(
new
buffered_file
(
"test"
,
"r"
)),
fopen
,
"cannot open file test"
);
"cannot open file test"
);
#ifndef _WIN32
#
ifndef _WIN32
char
c
=
0
;
char
c
=
0
;
if
(
fread
(
&
c
,
1
,
1
,
f
->
get
())
<
1
)
if
(
fread
(
&
c
,
1
,
1
,
f
->
get
())
<
1
)
throw
fmt
::
system_error
(
errno
,
"fread failed"
);
throw
fmt
::
system_error
(
errno
,
"fread failed"
);
#endif
#
endif
}
}
TEST
(
BufferedFileTest
,
CloseNoRetryInDtor
)
{
TEST
(
BufferedFileTest
,
CloseNoRetryInDtor
)
{
...
...
test/printf-test.cc
View file @
8cf4c520
...
@@ -590,7 +590,8 @@ class custom_printf_arg_formatter : public formatter_t {
...
@@ -590,7 +590,8 @@ class custom_printf_arg_formatter : public formatter_t {
if
(
round
(
value
*
pow
(
10
,
specs
()
->
precision
))
==
0.0
)
value
=
0
;
if
(
round
(
value
*
pow
(
10
,
specs
()
->
precision
))
==
0.0
)
value
=
0
;
return
formatter_t
::
operator
()(
value
);
return
formatter_t
::
operator
()(
value
);
}
}
};
}
;
typedef
fmt
::
basic_format_args
<
context_t
>
format_args_t
;
typedef
fmt
::
basic_format_args
<
context_t
>
format_args_t
;
...
...
test/std-format-test.cc
View file @
8cf4c520
...
@@ -29,8 +29,8 @@ TEST(StdFormatTest, Alignment) {
...
@@ -29,8 +29,8 @@ TEST(StdFormatTest, Alignment) {
string
s4
=
format
(
"{:*^6}"
,
'x'
);
// s4 == "**x***"
string
s4
=
format
(
"{:*^6}"
,
'x'
);
// s4 == "**x***"
// Error: '=' with charT and no integer presentation type
// Error: '=' with charT and no integer presentation type
EXPECT_THROW
(
string
s5
=
format
(
"{:=6}"
,
'x'
),
std
::
format_error
);
EXPECT_THROW
(
string
s5
=
format
(
"{:=6}"
,
'x'
),
std
::
format_error
);
string
s6
=
format
(
"{:6d}"
,
c
);
// s6 == " 120"
string
s6
=
format
(
"{:6d}"
,
c
);
// s6 == " 120"
string
s7
=
format
(
"{:6}"
,
true
);
// s9 == "true "
string
s7
=
format
(
"{:6}"
,
true
);
// s9 == "true "
EXPECT_EQ
(
s0
,
" 42"
);
EXPECT_EQ
(
s0
,
" 42"
);
EXPECT_EQ
(
s1
,
"x "
);
EXPECT_EQ
(
s1
,
"x "
);
EXPECT_EQ
(
s2
,
"x*****"
);
EXPECT_EQ
(
s2
,
"x*****"
);
...
...
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