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
cb999199
Commit
cb999199
authored
Dec 07, 2012
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests.
parent
15755cfa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
0 deletions
+57
-0
.gitmodules
.gitmodules
+3
-0
CMakeLists.txt
CMakeLists.txt
+11
-0
format_test.cc
format_test.cc
+42
-0
gtest
gtest
+1
-0
No files found.
.gitmodules
0 → 100644
View file @
cb999199
[submodule "gtest"]
path = gtest
url = git@github.com:vitaut/gtest.git
CMakeLists.txt
View file @
cb999199
cmake_minimum_required
(
VERSION 2.6
)
project
(
FORMAT
)
add_library
(
format format.cc
)
if
(
EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/gtest/CMakeLists.txt
)
add_subdirectory
(
gtest
)
include_directories
(
gtest/include
)
link_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
/gtest
)
enable_testing
()
add_executable
(
format_test format_test.cc gtest/src/gtest_main.cc
)
target_link_libraries
(
format_test format gtest
)
add_test
(
format_test format_test
)
endif
()
format_test.cc
0 → 100644
View file @
cb999199
/*
Formatting library tests.
Author: Victor Zverovich
*/
#include <cfloat>
#include <climits>
#include <cstring>
#include <gtest/gtest.h>
#include "format.h"
using
std
::
size_t
;
using
std
::
sprintf
;
using
fmt
::
Formatter
;
using
fmt
::
Format
;
TEST
(
FormatterTest
,
FormatNoArgs
)
{
Formatter
format
;
format
(
"test"
);
EXPECT_STREQ
(
"test"
,
format
.
c_str
());
}
TEST
(
FormatterTest
,
FormatComplex
)
{
EXPECT_STREQ
(
"1.2340000000:0042:+3.13:str:0x3e8:X:%"
,
c_str
(
Format
(
"{0:0.10f}:{1:04}:{2:+g}:{3}:{4}:{5}:%"
)
<<
1.234
<<
42
<<
3.13
<<
"str"
<<
reinterpret_cast
<
void
*>
(
1000
)
<<
'X'
));
printf
(
"%0.*f:%04d:%+g:%s:%p:%c:%%
\n
"
,
10
,
1.234
,
42
,
3.13
,
"str"
,
(
void
*
)
1000
,
(
int
)
'X'
);
printf
(
"%0.10f:%04d:%+g:%s:%p:%c:%%
\n
"
,
1.234
,
42
,
3.13
,
"str"
,
(
void
*
)
1000
,
(
int
)
'X'
);
}
TEST
(
FormatterTest
,
FormatInt
)
{
EXPECT_STREQ
(
"42"
,
c_str
(
Format
(
"{0}"
)
<<
42
));
EXPECT_STREQ
(
"before 42 after"
,
c_str
(
Format
(
"before {0} after"
)
<<
42
));
printf
(
"%0.10f:%04d:%+g:%s:%p:%c:%%
\n
"
,
1.234
,
42
,
3.13
,
"str"
,
(
void
*
)
1000
,
(
int
)
'X'
);
}
// TODO
gtest
@
2084bf04
Subproject commit 2084bf04aa7b22808bf449cf72dedf7774776feb
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