forked from insomniacslk/dublin-traceroute
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
942a421
commit 9daf083
Showing
7 changed files
with
101 additions
and
1 deletion.
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
Submodule googletest
added at
bfc0ff
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,3 @@ | ||
INCLUDE_DIRECTORIES(${gtest_INCLUDE_DIRS}) | ||
ADD_SUBDIRECTORY(src) | ||
|
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,36 @@ | ||
# This file is shamelessly copied and modified from libtins. | ||
# Use dublintraceroute's include directories + test include directories | ||
INCLUDE_DIRECTORIES( | ||
${PROJECT_SOURCE_DIR}/include/dublintraceroute/ | ||
${GOOGLETEST_INCLUDE} | ||
) | ||
|
||
# Find pthread library | ||
FIND_PACKAGE(Threads REQUIRED) | ||
|
||
LINK_DIRECTORIES( | ||
${GOOGLETEST_LIBRARY} | ||
) | ||
# Link against GoogleTest, libdublintraceroute and pthread. | ||
# Pthread is required by GoogleTest | ||
LINK_LIBRARIES( | ||
gtest | ||
gtest_main | ||
dublintraceroute | ||
${CMAKE_THREAD_LIBS_INIT} | ||
) | ||
|
||
# Add tests target | ||
ADD_CUSTOM_TARGET( | ||
tests DEPENDS | ||
UDPv4Test | ||
${OPTIONAL_TEST_TARGETS} | ||
) | ||
|
||
# Test executables | ||
|
||
ADD_EXECUTABLE(UDPv4Test EXCLUDE_FROM_ALL udpv4.cxx) | ||
|
||
# Tests | ||
|
||
ADD_TEST(UDPv4 UDPv4Test) |
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,26 @@ | ||
#include <dublintraceroute/udpv4probe.h> | ||
#include <gtest/gtest.h> | ||
|
||
|
||
namespace { | ||
|
||
class UDPv4Test: public ::testing::Test { | ||
}; | ||
|
||
TEST_F(UDPv4Test, TestUDPv4Constructor) { | ||
UDPv4Probe p = UDPv4Probe(IPv4Address("8.8.8.8"), 33434, 12345, 64, IPv4Address("127.0.0.2")); | ||
ASSERT_EQ(p.local_port(), 12345); | ||
ASSERT_EQ(p.remote_port(), 33434); | ||
ASSERT_EQ(p.ttl(), 64); | ||
ASSERT_EQ(p.remote_addr().to_string(), std::string("8.8.8.8")); | ||
ASSERT_EQ(p.local_addr().to_string(), std::string("127.0.0.2")); | ||
} | ||
|
||
} | ||
|
||
|
||
int main(int argc, char **argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
std::exit(RUN_ALL_TESTS()); | ||
} | ||
|