Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
408d30a5
Commit
408d30a5
authored
8 years ago
by
Jeremie Deray
Browse files
Options
Downloads
Patches
Plain Diff
add dummy gtest as an example
parent
0916a699
No related branches found
No related tags found
1 merge request
!82
Gtest
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/CMakeLists.txt
+3
-0
3 additions, 0 deletions
test/CMakeLists.txt
test/gtest_example.cpp
+20
-0
20 additions, 0 deletions
test/gtest_example.cpp
test/utils_gtest.h
+82
-0
82 additions, 0 deletions
test/utils_gtest.h
with
105 additions
and
0 deletions
test/CMakeLists.txt
+
3
−
0
View file @
408d30a5
...
@@ -3,3 +3,6 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/test/gtest)
...
@@ -3,3 +3,6 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/test/gtest)
include_directories
(
${
GTEST_INCLUDE_DIRS
}
)
include_directories
(
${
GTEST_INCLUDE_DIRS
}
)
# Create a specific test executable for gtest_example
wolf_add_gtest
(
gtest_example gtest_example.cpp
)
target_link_libraries
(
gtest_example
${
PROJECT_NAME
}
)
This diff is collapsed.
Click to expand it.
test/gtest_example.cpp
0 → 100644
+
20
−
0
View file @
408d30a5
#include
"utils_gtest.h"
TEST
(
TestTest
,
DummyTestExample
)
{
EXPECT_FALSE
(
false
);
ASSERT_TRUE
(
true
);
int
my_int
=
5
;
ASSERT_EQ
(
my_int
,
5
);
PRINTF
(
"All good at TestTest::DummyTestExample !
\n
"
);
}
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
This diff is collapsed.
Click to expand it.
test/utils_gtest.h
0 → 100644
+
82
−
0
View file @
408d30a5
/**
* \file utils_gtest.h
* \brief Some utils for gtest
* \author Jeremie Deray
* Created on: 26/09/2016
*/
#ifndef WOLF_UTILS_GTEST_H
#define WOLF_UTILS_GTEST_H
#include
<gtest/gtest.h>
// Macros for testing equalities and inequalities.
//
// * {ASSERT|EXPECT}_EQ(expected, actual): Tests that expected == actual
// * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2
// * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2
// * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2
// * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2
// * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2
// http://stackoverflow.com/a/29155677
namespace
testing
{
namespace
internal
{
enum
GTestColor
{
COLOR_DEFAULT
,
COLOR_RED
,
COLOR_GREEN
,
COLOR_YELLOW
};
extern
void
ColoredPrintf
(
GTestColor
color
,
const
char
*
fmt
,
...);
#define PRINTF(...) \
do { testing::internal::ColoredPrintf(testing::internal::COLOR_GREEN,\
"[ ] "); \
testing::internal::ColoredPrintf(testing::internal::COLOR_YELLOW, __VA_ARGS__); } \
while(0)
// C++ stream interface
class
TestCout
:
public
std
::
stringstream
{
public:
~
TestCout
()
{
PRINTF
(
"%s
\n
"
,
str
().
c_str
());
}
};
#define TEST_COUT testing::internal::TestCout()
}
// namespace internal
}
// namespace testing
/** Usage :
TEST(Test, Foo)
{
// the following works but prints default stream
EXPECT_TRUE(false) << "Testing Stream.";
// or you can play with AINSI color code
EXPECT_TRUE(false) << "\033[1;31m" << "Testing Stream.";
// or use the above defined macros
PRINTF("Hello world");
// or
TEST_COUT << "Hello world";
}
*/
#endif
/* WOLF_UTILS_GTEST_H */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment