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
08e2dffa
Commit
08e2dffa
authored
Jun 25, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add macro test.
parent
ef34eb6e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
+69
-0
CMakeLists.txt
CMakeLists.txt
+5
-0
test/macro-test.cc
test/macro-test.cc
+64
-0
No files found.
CMakeLists.txt
View file @
08e2dffa
...
...
@@ -113,6 +113,11 @@ foreach (target format-test printf-test)
endforeach
()
cxx_test
(
util-test test-main
)
add_executable
(
macro-test test/macro-test.cc
${
FMT_SOURCES
}
${
TEST_MAIN_SRC
}
)
set_target_properties
(
macro-test
PROPERTIES COMPILE_DEFINITIONS
"FMT_USE_VARIADIC_TEMPLATES=0"
)
target_link_libraries
(
macro-test gtest
)
if
(
HAVE_OPEN
)
add_executable
(
posix-test test/posix-test.cc
${
FMT_SOURCES
}
${
TEST_MAIN_SRC
}
)
set_target_properties
(
posix-test
...
...
test/macro-test.cc
0 → 100644
View file @
08e2dffa
/*
Tests of variadic function emulation macros.
Copyright (c) 2012-2014, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <gtest/gtest.h>
#include "format.h"
#define IDENTITY(x) x
TEST
(
UtilTest
,
Gen
)
{
int
values
[]
=
{
FMT_GEN
(
9
,
IDENTITY
)};
for
(
int
i
=
0
;
i
<
9
;
++
i
)
EXPECT_EQ
(
i
+
1
,
values
[
i
]);
}
int
result
;
#define MAKE_TEST(func) \
void func(const char *format, const fmt::ArgList &args) { \
result = 0; \
for (std::size_t i = 0, n = args.size(); i < n; ++i) \
result += args[i].int_value; \
}
MAKE_TEST
(
TestTemplate
)
FMT_TEMPLATE
(
TestTemplate
,
const
char
*
,
1
)
TEST
(
UtilTest
,
Template
)
{
result
=
0
;
TestTemplate
(
""
,
42
);
EXPECT_EQ
(
42
,
result
);
}
MAKE_TEST
(
TestVariadicVoid
)
FMT_VARIADIC_VOID
(
TestVariadicVoid
,
const
char
*
)
TEST
(
UtilTest
,
VariadicVoid
)
{
result
=
0
;
TestVariadicVoid
(
""
,
10
,
20
,
30
,
40
,
50
,
60
,
70
,
80
,
90
);
EXPECT_EQ
(
450
,
result
);
}
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