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
91014f01
Commit
91014f01
authored
Oct 22, 2017
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Naming conventions
parent
932ab2bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
30 deletions
+30
-30
test/format-test.cc
test/format-test.cc
+30
-30
No files found.
test/format-test.cc
View file @
91014f01
...
...
@@ -1582,46 +1582,46 @@ TEST(FormatTest, DynamicFormatter) {
format_error
,
"precision not allowed in integer format specifier"
);
}
struct
TestArgIDH
andler
{
enum
R
esult
{
NONE
,
EMPTY
,
INDEX
,
NAME
,
ERROR
};
Result
result
=
NONE
;
struct
test_arg_id_h
andler
{
enum
r
esult
{
NONE
,
EMPTY
,
INDEX
,
NAME
,
ERROR
};
result
res
=
NONE
;
unsigned
index
=
0
;
string_view
name
;
constexpr
void
operator
()()
{
res
ult
=
EMPTY
;
}
constexpr
void
operator
()()
{
res
=
EMPTY
;
}
constexpr
void
operator
()(
unsigned
index
)
{
res
ult
=
INDEX
;
res
=
INDEX
;
this
->
index
=
index
;
}
constexpr
void
operator
()(
string_view
name
)
{
res
ult
=
NAME
;
res
=
NAME
;
this
->
name
=
name
;
}
constexpr
void
on_error
(
const
char
*
)
{
res
ult
=
ERROR
;
}
constexpr
void
on_error
(
const
char
*
)
{
res
=
ERROR
;
}
};
constexpr
TestArgIDH
andler
parse_arg_id
(
const
char
*
s
)
{
TestArgIDH
andler
h
;
constexpr
test_arg_id_h
andler
parse_arg_id
(
const
char
*
s
)
{
test_arg_id_h
andler
h
;
fmt
::
internal
::
parse_arg_id
(
s
,
h
);
return
h
;
}
TEST
(
FormatTest
,
ConstexprParseArgID
)
{
static_assert
(
parse_arg_id
(
":"
).
res
ult
==
TestArgIDH
andler
::
EMPTY
,
""
);
static_assert
(
parse_arg_id
(
"}"
).
res
ult
==
TestArgIDH
andler
::
EMPTY
,
""
);
static_assert
(
parse_arg_id
(
"42:"
).
res
ult
==
TestArgIDH
andler
::
INDEX
,
""
);
static_assert
(
parse_arg_id
(
":"
).
res
==
test_arg_id_h
andler
::
EMPTY
,
""
);
static_assert
(
parse_arg_id
(
"}"
).
res
==
test_arg_id_h
andler
::
EMPTY
,
""
);
static_assert
(
parse_arg_id
(
"42:"
).
res
==
test_arg_id_h
andler
::
INDEX
,
""
);
static_assert
(
parse_arg_id
(
"42:"
).
index
==
42
,
""
);
static_assert
(
parse_arg_id
(
"foo:"
).
res
ult
==
TestArgIDH
andler
::
NAME
,
""
);
static_assert
(
parse_arg_id
(
"foo:"
).
res
==
test_arg_id_h
andler
::
NAME
,
""
);
static_assert
(
parse_arg_id
(
"foo:"
).
name
.
size
()
==
3
,
""
);
static_assert
(
parse_arg_id
(
"!"
).
res
ult
==
TestArgIDH
andler
::
ERROR
,
""
);
static_assert
(
parse_arg_id
(
"!"
).
res
==
test_arg_id_h
andler
::
ERROR
,
""
);
}
struct
TestFormatSpecsHandler
{
struct
test_format_specs_handlers
{
enum
Result
{
NONE
,
PLUS
,
MINUS
,
SPACE
,
HASH
,
ZERO
,
ERROR
};
Result
res
ult
=
NONE
;
Result
res
=
NONE
;
fmt
::
alignment
align
=
fmt
::
ALIGN_DEFAULT
;
char
fill
=
0
;
...
...
@@ -1633,11 +1633,11 @@ struct TestFormatSpecsHandler {
constexpr
void
on_align
(
fmt
::
alignment
align
)
{
this
->
align
=
align
;
}
constexpr
void
on_fill
(
char
fill
)
{
this
->
fill
=
fill
;
}
constexpr
void
on_plus
()
{
res
ult
=
PLUS
;
}
constexpr
void
on_minus
()
{
res
ult
=
MINUS
;
}
constexpr
void
on_space
()
{
res
ult
=
SPACE
;
}
constexpr
void
on_hash
()
{
res
ult
=
HASH
;
}
constexpr
void
on_zero
()
{
res
ult
=
ZERO
;
}
constexpr
void
on_plus
()
{
res
=
PLUS
;
}
constexpr
void
on_minus
()
{
res
=
MINUS
;
}
constexpr
void
on_space
()
{
res
=
SPACE
;
}
constexpr
void
on_hash
()
{
res
=
HASH
;
}
constexpr
void
on_zero
()
{
res
=
ZERO
;
}
constexpr
void
on_width
(
unsigned
width
)
{
this
->
width
=
width
;
}
constexpr
void
on_dynamic_width
(
fmt
::
internal
::
auto_id
)
{}
...
...
@@ -1653,11 +1653,11 @@ struct TestFormatSpecsHandler {
constexpr
void
end_precision
()
{}
constexpr
void
on_type
(
char
type
)
{
this
->
type
=
type
;
}
constexpr
void
on_error
(
const
char
*
)
{
res
ult
=
ERROR
;
}
constexpr
void
on_error
(
const
char
*
)
{
res
=
ERROR
;
}
};
constexpr
TestFormatSpecsHandler
parse_specs
(
const
char
*
s
)
{
TestFormatSpecsHandler
h
;
constexpr
test_format_specs_handlers
parse_specs
(
const
char
*
s
)
{
test_format_specs_handlers
h
;
fmt
::
internal
::
parse_format_specs
(
s
,
h
);
return
h
;
}
...
...
@@ -1665,15 +1665,15 @@ constexpr TestFormatSpecsHandler parse_specs(const char *s) {
TEST
(
FormatTest
,
ConstexprParseFormatSpecs
)
{
static_assert
(
parse_specs
(
"<"
).
align
==
fmt
::
ALIGN_LEFT
,
""
);
static_assert
(
parse_specs
(
"*^"
).
fill
==
'*'
,
""
);
static_assert
(
parse_specs
(
"+"
).
res
ult
==
TestFormatSpecsHandler
::
PLUS
,
""
);
static_assert
(
parse_specs
(
"-"
).
res
ult
==
TestFormatSpecsHandler
::
MINUS
,
""
);
static_assert
(
parse_specs
(
" "
).
res
ult
==
TestFormatSpecsHandler
::
SPACE
,
""
);
static_assert
(
parse_specs
(
"#"
).
res
ult
==
TestFormatSpecsHandler
::
HASH
,
""
);
static_assert
(
parse_specs
(
"0"
).
res
ult
==
TestFormatSpecsHandler
::
ZERO
,
""
);
static_assert
(
parse_specs
(
"+"
).
res
==
test_format_specs_handlers
::
PLUS
,
""
);
static_assert
(
parse_specs
(
"-"
).
res
==
test_format_specs_handlers
::
MINUS
,
""
);
static_assert
(
parse_specs
(
" "
).
res
==
test_format_specs_handlers
::
SPACE
,
""
);
static_assert
(
parse_specs
(
"#"
).
res
==
test_format_specs_handlers
::
HASH
,
""
);
static_assert
(
parse_specs
(
"0"
).
res
==
test_format_specs_handlers
::
ZERO
,
""
);
static_assert
(
parse_specs
(
"42"
).
width
==
42
,
""
);
static_assert
(
parse_specs
(
"{42}"
).
width_ref
.
index
==
42
,
""
);
static_assert
(
parse_specs
(
".42"
).
precision
==
42
,
""
);
static_assert
(
parse_specs
(
".{42}"
).
precision_ref
.
index
==
42
,
""
);
static_assert
(
parse_specs
(
"d"
).
type
==
'd'
,
""
);
static_assert
(
parse_specs
(
"{<"
).
res
ult
==
TestFormatSpecsHandler
::
ERROR
,
""
);
static_assert
(
parse_specs
(
"{<"
).
res
==
test_format_specs_handlers
::
ERROR
,
""
);
}
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