-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration completed of testing unit from GTest to Catch2. #3
Open
nicolas-slusarenko
wants to merge
14
commits into
main
Choose a base branch
from
migrating_from_gtest_to_catch2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e181899
Migration completed of testing unit from GTest to Catch2.
70773ee
WIP Migration of testing unit from GTest to Catch2.
fc7102f
WIP Migration of testing unit from GTest to Catch2.
21fa3d6
WIP Migration of testing unit from GTest to Catch2.
2d8f47c
WIP Migration of testing unit from GTest to Catch2.
b7dce48
WIP Migration of testing unit from GTest to Catch2.
9614f88
WIP Migration of testing unit from GTest to Catch2.
09c415a
Use sections, remove commented lines and improved indentation.
b0dcf41
WIP just to verify buildbot.
8e12395
Another verification in buildbot.
d00eda4
Yet another verification in buildbot.
e57ecff
More verification in buildbot.
6c79b68
WIP an experiment in BuildBot.
303d849
Commented the failure in testing-unit.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
#include <string> | ||
|
||
namespace dr { | ||
|
||
/// Convert a ROS package URL or a regular file URL to a file path. | ||
/** | ||
* If the input does not contain an URI scheme it is treated as a relative file path and returned without modification. | ||
* | ||
* \throws if an unsupported URI scheme is encountered. | ||
*/ | ||
std::string resolveResourceUrl(std::string const & url); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
find_package(Catch2 REQUIRED) | ||
include_directories(${Catch2_INCLUDE_DIRS}) | ||
|
||
add_library(${PROJECT_NAME}_test_main EXCLUDE_FROM_ALL main.cpp) | ||
target_link_libraries(${PROJECT_NAME}_test_main ${PROJECT_NAME}) | ||
|
||
define_property(GLOBAL PROPERTY CHECK_TARGET BRIEF_DOCS "." FULL_DOCS ".") | ||
set_property(GLOBAL PROPERTY CHECK_TARGET "check") | ||
|
||
if (NOT TARGET tests) | ||
add_custom_target(tests) | ||
endif() | ||
|
||
function(declare_test name) | ||
add_executable(${name} EXCLUDE_FROM_ALL ${ARGN}) | ||
target_link_libraries(${name} PRIVATE ${PROJECT_NAME}_test_main) | ||
add_custom_target(check_${name} COMMAND ${name}) | ||
add_dependencies(tests ${name}) | ||
|
||
get_property(check_target GLOBAL PROPERTY CHECK_TARGET) | ||
list(APPEND check_target COMMAND cmake -E cmake_echo_color --white --bold ${name} COMMAND ${name} DEPENDS ${name}) | ||
set_property(GLOBAL PROPERTY CHECK_TARGET "${check_target}") | ||
|
||
add_test(NAME ${name} COMMAND ${name}) | ||
endfunction() | ||
|
||
function(declare_tests prefix) | ||
foreach(test ${ARGN}) | ||
declare_test(${prefix}${test} ${test}.cpp) | ||
endforeach() | ||
endfunction() | ||
|
||
declare_tests(dr_util_ | ||
"bitwise" | ||
"button_filter" | ||
"environment" | ||
"expand" | ||
"functional" | ||
"geometry" | ||
"integer_sequence" | ||
"polynomial" | ||
"resource" | ||
"timestamp" | ||
"tuple" | ||
"void_t" | ||
) | ||
|
||
get_property(check_target GLOBAL PROPERTY CHECK_TARGET) | ||
add_custom_target(${check_target} USES_TERMINAL) | ||
|
||
if (TARGET run_tests) | ||
add_dependencies(run_tests check) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,82 @@ | ||
// This repository | ||
#include "bitwise.hpp" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
int main(int argc, char ** argv) { | ||
testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} | ||
// Catch | ||
#include <catch2/catch.hpp> | ||
|
||
namespace dr { | ||
|
||
TEST(BitwiseTest, makeBitMask) { | ||
// least significant bit | ||
EXPECT_EQ(0x1u, bitMask(0)); | ||
// some middle bit | ||
EXPECT_EQ(0x4000u, bitMask(14)); | ||
// most significant bit | ||
EXPECT_EQ(0x80000000u, bitMask(31)); | ||
} | ||
|
||
TEST(BitwiseTest, testTestBit) { | ||
// least significant bit | ||
EXPECT_TRUE(testBit(0x1, 0)); | ||
EXPECT_FALSE(testBit(0x1, 14)); | ||
EXPECT_FALSE(testBit(0x1, 31)); | ||
|
||
// some middle bit | ||
EXPECT_FALSE(testBit(0x4000, 0)); | ||
EXPECT_TRUE(testBit(0x4000, 14)); | ||
EXPECT_FALSE(testBit(0x4000, 31)); | ||
|
||
// most significant bit | ||
EXPECT_FALSE(testBit(0x80000000, 0)); | ||
EXPECT_FALSE(testBit(0x80000000, 14)); | ||
EXPECT_TRUE(testBit(0x80000000, 31)); | ||
|
||
// no value | ||
EXPECT_FALSE(testBit(0, 0)); | ||
EXPECT_FALSE(testBit(0, 14)); | ||
EXPECT_FALSE(testBit(0, 31)); | ||
|
||
// all bits set to true | ||
EXPECT_TRUE(testBit(0xFFFFFFFF, 0)); | ||
EXPECT_TRUE(testBit(0xFFFFFFFF, 14)); | ||
EXPECT_TRUE(testBit(0xFFFFFFFF, 31)); | ||
} | ||
|
||
TEST(BitwiseTest, testTestRising) { | ||
// no change for all bits set to 1 | ||
EXPECT_FALSE(testRising(0xFFFFFFFF, 0xFFFFFFFF, 0)); | ||
EXPECT_FALSE(testRising(0xFFFFFFFF, 0xFFFFFFFF, 14)); | ||
EXPECT_FALSE(testRising(0xFFFFFFFF, 0xFFFFFFFF, 31)); | ||
|
||
// no change for all bits set to 0 | ||
EXPECT_FALSE(testRising(0, 0, 0)); | ||
EXPECT_FALSE(testRising(0, 0, 14)); | ||
EXPECT_FALSE(testRising(0, 0, 31)); | ||
|
||
// ignore falling value | ||
EXPECT_TRUE(testRising(0xFFFFFFFF, 0, 0)); | ||
EXPECT_TRUE(testRising(0xFFFFFFFF, 0, 14)); | ||
EXPECT_TRUE(testRising(0xFFFFFFFF, 0, 31)); | ||
|
||
// test rising edge | ||
EXPECT_FALSE(testRising(0, 0xFFFFFFFF, 0)); | ||
EXPECT_FALSE(testRising(0, 0xFFFFFFFF, 14)); | ||
EXPECT_FALSE(testRising(0, 0xFFFFFFFF, 31)); | ||
|
||
// test specific rising edge | ||
EXPECT_TRUE(testRising(0x1, 0, 0)); | ||
EXPECT_TRUE(testRising(0x4000, 0, 14)); | ||
EXPECT_TRUE(testRising(0x80000000, 0, 31)); | ||
|
||
// test wrong rising edge | ||
EXPECT_FALSE(testRising(0x2, 0, 0)); | ||
EXPECT_FALSE(testRising(0x8000, 0, 14)); | ||
EXPECT_FALSE(testRising(0x40000000, 0, 31)); | ||
TEST_CASE("BitwiseTest") { | ||
|
||
SECTION("makeBitMask") { | ||
// least significant bit | ||
REQUIRE( 0x1u == bitMask(0)); | ||
|
||
// some middle bit | ||
REQUIRE( 0x4000u == bitMask(14)); | ||
|
||
// most significant bit | ||
REQUIRE(0x80000000u == bitMask(31)); | ||
} | ||
|
||
SECTION("testTestBit") { | ||
// least significant bit | ||
REQUIRE(testBit(0x1, 0) == true); | ||
REQUIRE(testBit(0x1, 14) == false); | ||
REQUIRE(testBit(0x1, 31) == false); | ||
|
||
// some middle bit | ||
REQUIRE(testBit(0x4000, 0) == false); | ||
REQUIRE(testBit(0x4000, 14) == true); | ||
REQUIRE(testBit(0x4000, 31) == false); | ||
|
||
// most significant bit | ||
REQUIRE(testBit(0x80000000, 0) == false); | ||
REQUIRE(testBit(0x80000000, 14) == false); | ||
REQUIRE(testBit(0x80000000, 31) == true); | ||
|
||
// no value | ||
REQUIRE(testBit(0, 0) == false); | ||
REQUIRE(testBit(0, 14) == false); | ||
REQUIRE(testBit(0, 31) == false); | ||
|
||
// all bits set to true | ||
REQUIRE(testBit(0xFFFFFFFF, 0) == true); | ||
REQUIRE(testBit(0xFFFFFFFF, 14) == true); | ||
REQUIRE(testBit(0xFFFFFFFF, 31) == true); | ||
} | ||
|
||
SECTION("testTestRising") { | ||
// no change for all bits set to 1 | ||
REQUIRE(testRising(0xFFFFFFFF, 0xFFFFFFFF, 0) == false); | ||
REQUIRE(testRising(0xFFFFFFFF, 0xFFFFFFFF, 14) == false); | ||
REQUIRE(testRising(0xFFFFFFFF, 0xFFFFFFFF, 31) == false); | ||
|
||
// no change for all bits set to 0 | ||
REQUIRE(testRising(0, 0, 0) == false); | ||
REQUIRE(testRising(0, 0, 14) == false); | ||
REQUIRE(testRising(0, 0, 31) == false); | ||
|
||
// ignore falling value | ||
REQUIRE(testRising(0xFFFFFFFF, 0, 0) == true); | ||
REQUIRE(testRising(0xFFFFFFFF, 0, 14) == true); | ||
REQUIRE(testRising(0xFFFFFFFF, 0, 31) == true); | ||
|
||
// test rising edge | ||
REQUIRE(testRising(0, 0xFFFFFFFF, 0) == false); | ||
REQUIRE(testRising(0, 0xFFFFFFFF, 14) == false); | ||
REQUIRE(testRising(0, 0xFFFFFFFF, 31) == false); | ||
|
||
// test specific rising edge | ||
REQUIRE(testRising(0x1, 0, 0) == true); | ||
REQUIRE(testRising(0x4000, 0, 14) == true); | ||
REQUIRE(testRising(0x80000000, 0, 31) == true); | ||
|
||
// test wrong rising edge | ||
REQUIRE(testRising(0x2, 0, 0) == false); | ||
REQUIRE(testRising(0x8000, 0, 14) == false); | ||
REQUIRE(testRising(0x40000000, 0, 31) == false); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these added?