diff options
Diffstat (limited to 'libtransport/src/test/test_interest.cc')
-rw-r--r-- | libtransport/src/test/test_interest.cc | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/libtransport/src/test/test_interest.cc b/libtransport/src/test/test_interest.cc index e36ca0f93..8d00a9c6d 100644 --- a/libtransport/src/test/test_interest.cc +++ b/libtransport/src/test/test_interest.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -30,7 +30,8 @@ namespace { // The fixture for testing class Foo. class InterestTest : public ::testing::Test { protected: - InterestTest() : name_("b001::123|321"), interest_(HF_INET6_TCP) { + InterestTest() + : name_("b001::123|321"), interest_(HICN_PACKET_FORMAT_IPV6_TCP) { // You can do set-up work for each test here. } @@ -63,15 +64,18 @@ class InterestTest : public ::testing::Test { PAYLOAD}; }; -void testFormatConstructor(Packet::Format format = HF_UNSPEC) { +void testFormatConstructor( + hicn_packet_format_t format = HICN_PACKET_FORMAT_NONE) { try { Interest interest(format, 0); } catch (...) { - FAIL() << "ERROR: Unexpected exception thrown for " << format; + char buf[MAXSZ_HICN_PACKET_FORMAT]; + FAIL() << "ERROR: Unexpected exception thrown for " << buf; } } -void testFormatConstructorException(Packet::Format format = HF_UNSPEC) { +void testFormatConstructorException( + Packet::Format format = HICN_PACKET_FORMAT_NONE) { try { Interest interest(format, 0); FAIL() << "We expected an exception here"; @@ -86,29 +90,29 @@ void testFormatConstructorException(Packet::Format format = HF_UNSPEC) { TEST_F(InterestTest, ConstructorWithFormat) { /** - * Without arguments it should be format = HF_UNSPEC. + * Without arguments it should be format = HICN_PACKET_FORMAT_NONE. * We expect a crash. */ - testFormatConstructor(Packet::Format::HF_INET_TCP); - testFormatConstructor(Packet::Format::HF_INET6_TCP); - testFormatConstructorException(Packet::Format::HF_INET_ICMP); - testFormatConstructorException(Packet::Format::HF_INET6_ICMP); - testFormatConstructor(Packet::Format::HF_INET_TCP_AH); - testFormatConstructor(Packet::Format::HF_INET6_TCP_AH); - testFormatConstructorException(Packet::Format::HF_INET_ICMP_AH); - testFormatConstructorException(Packet::Format::HF_INET6_ICMP_AH); + testFormatConstructor(HICN_PACKET_FORMAT_IPV4_TCP); + testFormatConstructor(HICN_PACKET_FORMAT_IPV6_TCP); + testFormatConstructorException(HICN_PACKET_FORMAT_IPV4_ICMP); + testFormatConstructorException(HICN_PACKET_FORMAT_IPV6_ICMP); + testFormatConstructor(HICN_PACKET_FORMAT_IPV4_TCP_AH); + testFormatConstructor(HICN_PACKET_FORMAT_IPV6_TCP_AH); + testFormatConstructorException(HICN_PACKET_FORMAT_IPV4_ICMP_AH); + testFormatConstructorException(HICN_PACKET_FORMAT_IPV6_ICMP_AH); } TEST_F(InterestTest, ConstructorWithName) { /** - * Without arguments it should be format = HF_UNSPEC. + * Without arguments it should be format = HICN_PACKET_FORMAT_NONE. * We expect a crash. */ Name n("b001::1|123"); try { - Interest interest(HF_INET6_TCP, n); + Interest interest(HICN_PACKET_FORMAT_IPV6_TCP, n); } catch (...) { FAIL() << "ERROR: Unexpected exception thrown"; } @@ -116,8 +120,10 @@ TEST_F(InterestTest, ConstructorWithName) { TEST_F(InterestTest, ConstructorWithBuffer) { // Ensure buffer is interest +#if 0 auto ret = Interest::isInterest(&buffer_[0]); EXPECT_TRUE(ret); +#endif // Create interest from buffer try { @@ -175,9 +181,9 @@ TEST_F(InterestTest, SetGetLocator) { // Get locator auto l = interest.getLocator(); - ip_address_t address; + hicn_ip_address_t address; inet_pton(AF_INET6, "b006::ab:cdab:cdef", &address); - auto ret = !ip_address_cmp(&l, &address, AF_INET6); + auto ret = !hicn_ip_address_cmp(&l, &address); EXPECT_TRUE(ret); @@ -189,14 +195,14 @@ TEST_F(InterestTest, SetGetLocator) { // Check it was set l = interest.getLocator(); - ret = !ip_address_cmp(&l, &address, AF_INET6); + ret = !hicn_ip_address_cmp(&l, &address); EXPECT_TRUE(ret); } TEST_F(InterestTest, SetGetLifetime) { // Create interest from buffer - Interest interest(HF_INET6_TCP); + Interest interest(HICN_PACKET_FORMAT_IPV6_TCP); const constexpr uint32_t lifetime = 10000; // Set lifetime @@ -211,7 +217,7 @@ TEST_F(InterestTest, SetGetLifetime) { TEST_F(InterestTest, HasManifest) { // Create interest from buffer - Interest interest(HF_INET6_TCP); + Interest interest(HICN_PACKET_FORMAT_IPV6_TCP); // Let's expect anexception here try { @@ -232,7 +238,7 @@ TEST_F(InterestTest, HasManifest) { TEST_F(InterestTest, AppendSuffixesEncodeAndIterate) { // Create interest from buffer - Interest interest(HF_INET6_TCP); + Interest interest(HICN_PACKET_FORMAT_IPV6_TCP); // Appenad some suffixes, with some duplicates interest.appendSuffix(1); @@ -260,7 +266,7 @@ TEST_F(InterestTest, AppendSuffixesEncodeAndIterate) { TEST_F(InterestTest, AppendSuffixesWithGaps) { // Create interest from buffer - Interest interest(HF_INET6_TCP); + Interest interest(HICN_PACKET_FORMAT_IPV6_TCP); // Appenad some suffixes, out of order and with gaps interest.appendSuffix(6); @@ -289,7 +295,7 @@ TEST_F(InterestTest, AppendSuffixesWithGaps) { TEST_F(InterestTest, InterestWithoutManifest) { // Create interest without manifest - Interest interest(HF_INET6_TCP); + Interest interest(HICN_PACKET_FORMAT_IPV6_TCP); auto suffix = interest.firstSuffix(); EXPECT_FALSE(interest.hasManifest()); |