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
59536b15
Commit
59536b15
authored
Dec 11, 2012
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more tests.
parent
a9a4e74f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
8 deletions
+33
-8
format_test.cc
format_test.cc
+33
-8
No files found.
format_test.cc
View file @
59536b15
...
...
@@ -6,6 +6,7 @@
#include <cfloat>
#include <climits>
#include <cstring>
#include <memory>
#include <gtest/gtest.h>
#include "format.h"
...
...
@@ -560,23 +561,47 @@ TEST(FormatterTest, ArgInserter) {
EXPECT_STREQ
(
"12"
,
c_str
(
format
(
"{0}"
)
<<
2
));
}
struct
C
allCheck
{
bool
&
called
;
struct
C
ountCalls
{
int
&
num_calls
;
C
allCheck
(
bool
&
called
)
:
called
(
called
)
{}
C
ountCalls
(
int
&
num_calls
)
:
num_calls
(
num_calls
)
{}
void
operator
()(
const
Formatter
&
)
const
{
called
=
true
;
++
num_calls
;
}
};
TEST
(
ActiveFormatterTest
,
Action
)
{
bool
called
=
false
;
int
num_calls
=
0
;
{
fmt
::
ActiveFormatter
<
C
allCheck
>
af
(
"test"
,
CallCheck
(
called
));
EXPECT_
FALSE
(
called
);
fmt
::
ActiveFormatter
<
C
ountCalls
>
af
(
"test"
,
CountCalls
(
num_calls
));
EXPECT_
EQ
(
0
,
num_calls
);
}
EXPECT_TRUE
(
called
);
EXPECT_EQ
(
1
,
num_calls
);
}
TEST
(
ActiveFormatterTest
,
Copy
)
{
int
num_calls
=
0
;
typedef
fmt
::
ActiveFormatter
<
CountCalls
>
AF
;
std
::
auto_ptr
<
AF
>
af
(
new
AF
(
"test"
,
CountCalls
(
num_calls
)));
EXPECT_EQ
(
0
,
num_calls
);
{
AF
copy
(
*
af
);
EXPECT_EQ
(
0
,
num_calls
);
af
.
reset
();
EXPECT_EQ
(
0
,
num_calls
);
}
EXPECT_EQ
(
1
,
num_calls
);
}
TEST
(
ActiveFormatterTest
,
ActionNotCalledOnError
)
{
int
num_calls
=
0
;
{
EXPECT_THROW
(
fmt
::
ActiveFormatter
<
CountCalls
>
af
(
"{0"
,
CountCalls
(
num_calls
)),
FormatError
);
}
EXPECT_EQ
(
0
,
num_calls
);
}
TEST
(
ActiveFormatterTest
,
ArgLifetime
)
{
...
...
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