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
9cf6c8fd
Commit
9cf6c8fd
authored
Nov 26, 2016
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of fmt::internal::Arg
parent
5f022ae0
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
153 additions
and
138 deletions
+153
-138
fmt/format.cc
fmt/format.cc
+0
-2
fmt/format.h
fmt/format.h
+106
-87
fmt/printf.h
fmt/printf.h
+17
-19
test/format-impl-test.cc
test/format-impl-test.cc
+4
-4
test/util-test.cc
test/util-test.cc
+26
-26
No files found.
fmt/format.cc
View file @
9cf6c8fd
...
@@ -51,8 +51,6 @@
...
@@ -51,8 +51,6 @@
# endif
# endif
#endif
#endif
using
fmt
::
internal
::
Arg
;
#if FMT_EXCEPTIONS
#if FMT_EXCEPTIONS
# define FMT_TRY try
# define FMT_TRY try
# define FMT_CATCH(x) catch (x)
# define FMT_CATCH(x) catch (x)
...
...
fmt/format.h
View file @
9cf6c8fd
This diff is collapsed.
Click to expand it.
fmt/printf.h
View file @
9cf6c8fd
...
@@ -83,11 +83,11 @@ struct is_same<T, T> {
...
@@ -83,11 +83,11 @@ struct is_same<T, T> {
template
<
typename
T
>
template
<
typename
T
>
class
ArgConverter
{
class
ArgConverter
{
private:
private:
internal
::
A
rg
&
arg_
;
format_a
rg
&
arg_
;
wchar_t
type_
;
wchar_t
type_
;
public:
public:
ArgConverter
(
internal
::
A
rg
&
arg
,
wchar_t
type
)
ArgConverter
(
format_a
rg
&
arg
,
wchar_t
type
)
:
arg_
(
arg
),
type_
(
type
)
{}
:
arg_
(
arg
),
type_
(
type
)
{}
void
operator
()(
bool
value
)
{
void
operator
()(
bool
value
)
{
...
@@ -99,28 +99,27 @@ class ArgConverter {
...
@@ -99,28 +99,27 @@ class ArgConverter {
typename
std
::
enable_if
<
std
::
is_integral
<
U
>::
value
>::
type
typename
std
::
enable_if
<
std
::
is_integral
<
U
>::
value
>::
type
operator
()(
U
value
)
{
operator
()(
U
value
)
{
bool
is_signed
=
type_
==
'd'
||
type_
==
'i'
;
bool
is_signed
=
type_
==
'd'
||
type_
==
'i'
;
using
internal
::
Arg
;
typedef
typename
internal
::
Conditional
<
typedef
typename
internal
::
Conditional
<
is_same
<
T
,
void
>::
value
,
U
,
T
>::
type
TargetType
;
is_same
<
T
,
void
>::
value
,
U
,
T
>::
type
TargetType
;
if
(
sizeof
(
TargetType
)
<=
sizeof
(
int
))
{
if
(
sizeof
(
TargetType
)
<=
sizeof
(
int
))
{
// Extra casts are used to silence warnings.
// Extra casts are used to silence warnings.
if
(
is_signed
)
{
if
(
is_signed
)
{
arg_
.
type
=
A
rg
::
INT
;
arg_
.
type
=
format_a
rg
::
INT
;
arg_
.
int_value
=
static_cast
<
int
>
(
static_cast
<
TargetType
>
(
value
));
arg_
.
int_value
=
static_cast
<
int
>
(
static_cast
<
TargetType
>
(
value
));
}
else
{
}
else
{
arg_
.
type
=
A
rg
::
UINT
;
arg_
.
type
=
format_a
rg
::
UINT
;
typedef
typename
internal
::
MakeUnsigned
<
TargetType
>::
Type
Unsigned
;
typedef
typename
internal
::
MakeUnsigned
<
TargetType
>::
Type
Unsigned
;
arg_
.
uint_value
=
static_cast
<
unsigned
>
(
static_cast
<
Unsigned
>
(
value
));
arg_
.
uint_value
=
static_cast
<
unsigned
>
(
static_cast
<
Unsigned
>
(
value
));
}
}
}
else
{
}
else
{
if
(
is_signed
)
{
if
(
is_signed
)
{
arg_
.
type
=
A
rg
::
LONG_LONG
;
arg_
.
type
=
format_a
rg
::
LONG_LONG
;
// glibc's printf doesn't sign extend arguments of smaller types:
// glibc's printf doesn't sign extend arguments of smaller types:
// std::printf("%lld", -42); // prints "4294967254"
// std::printf("%lld", -42); // prints "4294967254"
// but we don't have to do the same because it's a UB.
// but we don't have to do the same because it's a UB.
arg_
.
long_long_value
=
static_cast
<
LongLong
>
(
value
);
arg_
.
long_long_value
=
static_cast
<
LongLong
>
(
value
);
}
else
{
}
else
{
arg_
.
type
=
A
rg
::
ULONG_LONG
;
arg_
.
type
=
format_a
rg
::
ULONG_LONG
;
arg_
.
ulong_long_value
=
arg_
.
ulong_long_value
=
static_cast
<
typename
internal
::
MakeUnsigned
<
U
>::
Type
>
(
value
);
static_cast
<
typename
internal
::
MakeUnsigned
<
U
>::
Type
>
(
value
);
}
}
...
@@ -146,17 +145,17 @@ void convert_arg(format_arg &arg, wchar_t type) {
...
@@ -146,17 +145,17 @@ void convert_arg(format_arg &arg, wchar_t type) {
// Converts an integer argument to char for printf.
// Converts an integer argument to char for printf.
class
CharConverter
{
class
CharConverter
{
private:
private:
internal
::
A
rg
&
arg_
;
format_a
rg
&
arg_
;
FMT_DISALLOW_COPY_AND_ASSIGN
(
CharConverter
);
FMT_DISALLOW_COPY_AND_ASSIGN
(
CharConverter
);
public:
public:
explicit
CharConverter
(
internal
::
A
rg
&
arg
)
:
arg_
(
arg
)
{}
explicit
CharConverter
(
format_a
rg
&
arg
)
:
arg_
(
arg
)
{}
template
<
typename
T
>
template
<
typename
T
>
typename
std
::
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
typename
std
::
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
operator
()(
T
value
)
{
operator
()(
T
value
)
{
arg_
.
type
=
internal
::
A
rg
::
CHAR
;
arg_
.
type
=
format_a
rg
::
CHAR
;
arg_
.
int_value
=
static_cast
<
char
>
(
value
);
arg_
.
int_value
=
static_cast
<
char
>
(
value
);
}
}
...
@@ -281,7 +280,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
...
@@ -281,7 +280,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
}
}
/** Formats an argument of a custom (user-defined) type. */
/** Formats an argument of a custom (user-defined) type. */
void
operator
()(
internal
::
A
rg
::
CustomValue
c
)
{
void
operator
()(
format_a
rg
::
CustomValue
c
)
{
const
Char
format_str
[]
=
{
'}'
,
'\0'
};
const
Char
format_str
[]
=
{
'}'
,
'\0'
};
auto
args
=
basic_format_args
<
basic_format_context
<
Char
>>
();
auto
args
=
basic_format_args
<
basic_format_context
<
Char
>>
();
basic_format_context
<
Char
>
ctx
(
format_str
,
args
);
basic_format_context
<
Char
>
ctx
(
format_str
,
args
);
...
@@ -306,7 +305,7 @@ class printf_context :
...
@@ -306,7 +305,7 @@ class printf_context :
// Returns the argument with specified index or, if arg_index is equal
// Returns the argument with specified index or, if arg_index is equal
// to the maximum unsigned value, the next argument.
// to the maximum unsigned value, the next argument.
internal
::
A
rg
get_arg
(
format_a
rg
get_arg
(
const
Char
*
s
,
const
Char
*
s
,
unsigned
arg_index
=
(
std
::
numeric_limits
<
unsigned
>::
max
)());
unsigned
arg_index
=
(
std
::
numeric_limits
<
unsigned
>::
max
)());
...
@@ -356,11 +355,11 @@ void printf_context<Char, AF>::parse_flags(FormatSpec &spec, const Char *&s) {
...
@@ -356,11 +355,11 @@ void printf_context<Char, AF>::parse_flags(FormatSpec &spec, const Char *&s) {
}
}
template
<
typename
Char
,
typename
AF
>
template
<
typename
Char
,
typename
AF
>
internal
::
A
rg
printf_context
<
Char
,
AF
>::
get_arg
(
const
Char
*
s
,
format_a
rg
printf_context
<
Char
,
AF
>::
get_arg
(
const
Char
*
s
,
unsigned
arg_index
)
{
unsigned
arg_index
)
{
(
void
)
s
;
(
void
)
s
;
const
char
*
error
=
0
;
const
char
*
error
=
0
;
internal
::
A
rg
arg
=
arg_index
==
std
::
numeric_limits
<
unsigned
>::
max
()
?
format_a
rg
arg
=
arg_index
==
std
::
numeric_limits
<
unsigned
>::
max
()
?
this
->
next_arg
(
error
)
:
Base
::
get_arg
(
arg_index
-
1
,
error
);
this
->
next_arg
(
error
)
:
Base
::
get_arg
(
arg_index
-
1
,
error
);
if
(
error
)
if
(
error
)
FMT_THROW
(
format_error
(
!*
s
?
"invalid format string"
:
error
));
FMT_THROW
(
format_error
(
!*
s
?
"invalid format string"
:
error
));
...
@@ -432,12 +431,11 @@ void printf_context<Char, AF>::format(BasicWriter<Char> &writer) {
...
@@ -432,12 +431,11 @@ void printf_context<Char, AF>::format(BasicWriter<Char> &writer) {
}
}
}
}
using
internal
::
Arg
;
format_arg
arg
=
get_arg
(
s
,
arg_index
);
Arg
arg
=
get_arg
(
s
,
arg_index
);
if
(
spec
.
flag
(
HASH_FLAG
)
&&
visit
(
internal
::
IsZeroInt
(),
arg
))
if
(
spec
.
flag
(
HASH_FLAG
)
&&
visit
(
internal
::
IsZeroInt
(),
arg
))
spec
.
flags_
&=
~
internal
::
to_unsigned
<
int
>
(
HASH_FLAG
);
spec
.
flags_
&=
~
internal
::
to_unsigned
<
int
>
(
HASH_FLAG
);
if
(
spec
.
fill_
==
'0'
)
{
if
(
spec
.
fill_
==
'0'
)
{
if
(
arg
.
type
<=
A
rg
::
LAST_NUMERIC_TYPE
)
if
(
arg
.
type
<=
format_a
rg
::
LAST_NUMERIC_TYPE
)
spec
.
align_
=
ALIGN_NUMERIC
;
spec
.
align_
=
ALIGN_NUMERIC
;
else
else
spec
.
fill_
=
' '
;
// Ignore '0' flag for non-numeric types.
spec
.
fill_
=
' '
;
// Ignore '0' flag for non-numeric types.
...
@@ -480,7 +478,7 @@ void printf_context<Char, AF>::format(BasicWriter<Char> &writer) {
...
@@ -480,7 +478,7 @@ void printf_context<Char, AF>::format(BasicWriter<Char> &writer) {
if
(
!*
s
)
if
(
!*
s
)
FMT_THROW
(
format_error
(
"invalid format string"
));
FMT_THROW
(
format_error
(
"invalid format string"
));
spec
.
type_
=
static_cast
<
char
>
(
*
s
++
);
spec
.
type_
=
static_cast
<
char
>
(
*
s
++
);
if
(
arg
.
type
<=
A
rg
::
LAST_INTEGER_TYPE
)
{
if
(
arg
.
type
<=
format_a
rg
::
LAST_INTEGER_TYPE
)
{
// Normalize type.
// Normalize type.
switch
(
spec
.
type_
)
{
switch
(
spec
.
type_
)
{
case
'i'
:
case
'u'
:
case
'i'
:
case
'u'
:
...
...
test/format-impl-test.cc
View file @
9cf6c8fd
...
@@ -42,12 +42,12 @@
...
@@ -42,12 +42,12 @@
#undef max
#undef max
TEST
(
FormatTest
,
ArgConverter
)
{
TEST
(
FormatTest
,
ArgConverter
)
{
using
fmt
::
internal
::
A
rg
;
using
fmt
::
format_a
rg
;
Arg
arg
=
A
rg
();
format_arg
arg
=
format_a
rg
();
arg
.
type
=
A
rg
::
LONG_LONG
;
arg
.
type
=
format_a
rg
::
LONG_LONG
;
arg
.
long_long_value
=
std
::
numeric_limits
<
fmt
::
LongLong
>::
max
();
arg
.
long_long_value
=
std
::
numeric_limits
<
fmt
::
LongLong
>::
max
();
visit
(
fmt
::
internal
::
ArgConverter
<
fmt
::
LongLong
>
(
arg
,
'd'
),
arg
);
visit
(
fmt
::
internal
::
ArgConverter
<
fmt
::
LongLong
>
(
arg
,
'd'
),
arg
);
EXPECT_EQ
(
A
rg
::
LONG_LONG
,
arg
.
type
);
EXPECT_EQ
(
format_a
rg
::
LONG_LONG
,
arg
.
type
);
}
}
TEST
(
FormatTest
,
FormatNegativeNaN
)
{
TEST
(
FormatTest
,
FormatNegativeNaN
)
{
...
...
test/util-test.cc
View file @
9cf6c8fd
...
@@ -51,9 +51,9 @@
...
@@ -51,9 +51,9 @@
#undef max
#undef max
using
fmt
::
StringRef
;
using
fmt
::
format_arg
;
using
fmt
::
internal
::
Arg
;
using
fmt
::
Buffer
;
using
fmt
::
Buffer
;
using
fmt
::
StringRef
;
using
fmt
::
internal
::
MemoryBuffer
;
using
fmt
::
internal
::
MemoryBuffer
;
using
testing
::
Return
;
using
testing
::
Return
;
...
@@ -70,9 +70,9 @@ void format_value(fmt::BasicWriter<Char> &w, Test,
...
@@ -70,9 +70,9 @@ void format_value(fmt::BasicWriter<Char> &w, Test,
}
}
template
<
typename
Char
,
typename
T
>
template
<
typename
Char
,
typename
T
>
A
rg
make_arg
(
const
T
&
value
)
{
format_a
rg
make_arg
(
const
T
&
value
)
{
typedef
fmt
::
internal
::
MakeValue
<
fmt
::
basic_format_context
<
Char
>
>
MakeValue
;
typedef
fmt
::
internal
::
MakeValue
<
fmt
::
basic_format_context
<
Char
>
>
MakeValue
;
A
rg
arg
=
MakeValue
(
value
);
format_a
rg
arg
=
MakeValue
(
value
);
arg
.
type
=
fmt
::
internal
::
type
<
T
>
();
arg
.
type
=
fmt
::
internal
::
type
<
T
>
();
return
arg
;
return
arg
;
}
}
...
@@ -406,13 +406,13 @@ TEST(UtilTest, Increment) {
...
@@ -406,13 +406,13 @@ TEST(UtilTest, Increment) {
EXPECT_STREQ
(
"200"
,
s
);
EXPECT_STREQ
(
"200"
,
s
);
}
}
template
<
A
rg
::
Type
>
template
<
format_a
rg
::
Type
>
struct
ArgInfo
;
struct
ArgInfo
;
#define ARG_INFO(type_code, Type, field) \
#define ARG_INFO(type_code, Type, field) \
template <> \
template <> \
struct ArgInfo<
A
rg::type_code> { \
struct ArgInfo<
format_a
rg::type_code> { \
static Type get(const
A
rg &arg) { return arg.field; } \
static Type get(const
format_a
rg &arg) { return arg.field; } \
}
}
ARG_INFO
(
INT
,
int
,
int_value
);
ARG_INFO
(
INT
,
int
,
int_value
);
...
@@ -427,12 +427,12 @@ ARG_INFO(CSTRING, const char *, string.value);
...
@@ -427,12 +427,12 @@ ARG_INFO(CSTRING, const char *, string.value);
ARG_INFO
(
STRING
,
const
char
*
,
string
.
value
);
ARG_INFO
(
STRING
,
const
char
*
,
string
.
value
);
ARG_INFO
(
WSTRING
,
const
wchar_t
*
,
wstring
.
value
);
ARG_INFO
(
WSTRING
,
const
wchar_t
*
,
wstring
.
value
);
ARG_INFO
(
POINTER
,
const
void
*
,
pointer
);
ARG_INFO
(
POINTER
,
const
void
*
,
pointer
);
ARG_INFO
(
CUSTOM
,
A
rg
::
CustomValue
,
custom
);
ARG_INFO
(
CUSTOM
,
format_a
rg
::
CustomValue
,
custom
);
#define CHECK_ARG_INFO(Type, field, value) { \
#define CHECK_ARG_INFO(Type, field, value) { \
Arg arg = A
rg(); \
format_arg arg = format_a
rg(); \
arg.field = value; \
arg.field = value; \
EXPECT_EQ(value, ArgInfo<
A
rg::Type>::get(arg)); \
EXPECT_EQ(value, ArgInfo<
format_a
rg::Type>::get(arg)); \
}
}
TEST
(
ArgTest
,
ArgInfo
)
{
TEST
(
ArgTest
,
ArgInfo
)
{
...
@@ -449,17 +449,17 @@ TEST(ArgTest, ArgInfo) {
...
@@ -449,17 +449,17 @@ TEST(ArgTest, ArgInfo) {
CHECK_ARG_INFO
(
WSTRING
,
wstring
.
value
,
WSTR
);
CHECK_ARG_INFO
(
WSTRING
,
wstring
.
value
,
WSTR
);
int
p
=
0
;
int
p
=
0
;
CHECK_ARG_INFO
(
POINTER
,
pointer
,
&
p
);
CHECK_ARG_INFO
(
POINTER
,
pointer
,
&
p
);
Arg
arg
=
A
rg
();
format_arg
arg
=
format_a
rg
();
arg
.
custom
.
value
=
&
p
;
arg
.
custom
.
value
=
&
p
;
EXPECT_EQ
(
&
p
,
ArgInfo
<
A
rg
::
CUSTOM
>::
get
(
arg
).
value
);
EXPECT_EQ
(
&
p
,
ArgInfo
<
format_a
rg
::
CUSTOM
>::
get
(
arg
).
value
);
}
}
#define EXPECT_ARG_(Char, type_code, MakeArgType, ExpectedType, value) { \
#define EXPECT_ARG_(Char, type_code, MakeArgType, ExpectedType, value) { \
MakeArgType input = static_cast<MakeArgType>(value); \
MakeArgType input = static_cast<MakeArgType>(value); \
A
rg arg = make_arg<Char>(input); \
format_a
rg arg = make_arg<Char>(input); \
EXPECT_EQ(
A
rg::type_code, arg.type); \
EXPECT_EQ(
format_a
rg::type_code, arg.type); \
ExpectedType expected_value = static_cast<ExpectedType>(value); \
ExpectedType expected_value = static_cast<ExpectedType>(value); \
EXPECT_EQ(expected_value, ArgInfo<
A
rg::type_code>::get(arg)); \
EXPECT_EQ(expected_value, ArgInfo<
format_a
rg::type_code>::get(arg)); \
}
}
#define EXPECT_ARG(type_code, Type, value) \
#define EXPECT_ARG(type_code, Type, value) \
...
@@ -563,8 +563,8 @@ TEST(ArgTest, MakeArg) {
...
@@ -563,8 +563,8 @@ TEST(ArgTest, MakeArg) {
EXPECT_ARG
(
POINTER
,
const
void
*
,
&
n
);
EXPECT_ARG
(
POINTER
,
const
void
*
,
&
n
);
::
Test
t
;
::
Test
t
;
A
rg
arg
=
make_arg
<
char
>
(
t
);
format_a
rg
arg
=
make_arg
<
char
>
(
t
);
EXPECT_EQ
(
f
mt
::
internal
::
A
rg
::
CUSTOM
,
arg
.
type
);
EXPECT_EQ
(
f
ormat_a
rg
::
CUSTOM
,
arg
.
type
);
EXPECT_EQ
(
&
t
,
arg
.
custom
.
value
);
EXPECT_EQ
(
&
t
,
arg
.
custom
.
value
);
fmt
::
MemoryWriter
w
;
fmt
::
MemoryWriter
w
;
fmt
::
format_context
ctx
(
"}"
,
fmt
::
format_args
());
fmt
::
format_context
ctx
(
"}"
,
fmt
::
format_args
());
...
@@ -574,7 +574,7 @@ TEST(ArgTest, MakeArg) {
...
@@ -574,7 +574,7 @@ TEST(ArgTest, MakeArg) {
TEST
(
UtilTest
,
FormatArgs
)
{
TEST
(
UtilTest
,
FormatArgs
)
{
fmt
::
format_args
args
;
fmt
::
format_args
args
;
EXPECT_EQ
(
A
rg
::
NONE
,
args
[
1
].
type
);
EXPECT_EQ
(
format_a
rg
::
NONE
,
args
[
1
].
type
);
}
}
struct
CustomFormatter
{
struct
CustomFormatter
{
...
@@ -588,7 +588,7 @@ void format_value(fmt::Writer &, const Test &, CustomFormatter &ctx) {
...
@@ -588,7 +588,7 @@ void format_value(fmt::Writer &, const Test &, CustomFormatter &ctx) {
TEST
(
UtilTest
,
MakeValueWithCustomFormatter
)
{
TEST
(
UtilTest
,
MakeValueWithCustomFormatter
)
{
::
Test
t
;
::
Test
t
;
A
rg
arg
=
fmt
::
internal
::
MakeValue
<
CustomFormatter
>
(
t
);
format_a
rg
arg
=
fmt
::
internal
::
MakeValue
<
CustomFormatter
>
(
t
);
CustomFormatter
ctx
=
{
false
};
CustomFormatter
ctx
=
{
false
};
fmt
::
MemoryWriter
w
;
fmt
::
MemoryWriter
w
;
arg
.
custom
.
format
(
&
w
,
&
t
,
&
ctx
);
arg
.
custom
.
format
(
&
w
,
&
t
,
&
ctx
);
...
@@ -596,7 +596,7 @@ TEST(UtilTest, MakeValueWithCustomFormatter) {
...
@@ -596,7 +596,7 @@ TEST(UtilTest, MakeValueWithCustomFormatter) {
}
}
struct
Result
{
struct
Result
{
A
rg
arg
;
format_a
rg
arg
;
Result
()
:
arg
(
make_arg
<
char
>
(
0xdeadbeef
))
{}
Result
()
:
arg
(
make_arg
<
char
>
(
0xdeadbeef
))
{}
...
@@ -627,10 +627,10 @@ struct TestVisitor {
...
@@ -627,10 +627,10 @@ struct TestVisitor {
};
};
#define EXPECT_RESULT_(Char, type_code, value) { \
#define EXPECT_RESULT_(Char, type_code, value) { \
A
rg arg = make_arg<Char>(value); \
format_a
rg arg = make_arg<Char>(value); \
Result result = fmt::visit(TestVisitor(), arg); \
Result result = fmt::visit(TestVisitor(), arg); \
EXPECT_EQ(
A
rg::type_code, result.arg.type); \
EXPECT_EQ(
format_a
rg::type_code, result.arg.type); \
EXPECT_EQ(value, ArgInfo<
A
rg::type_code>::get(result.arg)); \
EXPECT_EQ(value, ArgInfo<
format_a
rg::type_code>::get(result.arg)); \
}
}
#define EXPECT_RESULT(type_code, value) \
#define EXPECT_RESULT(type_code, value) \
...
@@ -654,13 +654,13 @@ TEST(ArgVisitorTest, VisitAll) {
...
@@ -654,13 +654,13 @@ TEST(ArgVisitorTest, VisitAll) {
EXPECT_RESULT
(
POINTER
,
p
);
EXPECT_RESULT
(
POINTER
,
p
);
::
Test
t
;
::
Test
t
;
Result
result
=
visit
(
TestVisitor
(),
make_arg
<
char
>
(
t
));
Result
result
=
visit
(
TestVisitor
(),
make_arg
<
char
>
(
t
));
EXPECT_EQ
(
A
rg
::
CUSTOM
,
result
.
arg
.
type
);
EXPECT_EQ
(
format_a
rg
::
CUSTOM
,
result
.
arg
.
type
);
EXPECT_EQ
(
&
t
,
result
.
arg
.
custom
.
value
);
EXPECT_EQ
(
&
t
,
result
.
arg
.
custom
.
value
);
}
}
TEST
(
ArgVisitorTest
,
VisitInvalidArg
)
{
TEST
(
ArgVisitorTest
,
VisitInvalidArg
)
{
Arg
arg
=
A
rg
();
format_arg
arg
=
format_a
rg
();
arg
.
type
=
static_cast
<
Arg
::
Type
>
(
A
rg
::
NONE
);
arg
.
type
=
static_cast
<
format_arg
::
Type
>
(
format_a
rg
::
NONE
);
EXPECT_ASSERT
(
visit
(
TestVisitor
(),
arg
),
"invalid argument type"
);
EXPECT_ASSERT
(
visit
(
TestVisitor
(),
arg
),
"invalid argument type"
);
}
}
...
...
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