File: | home/fedora/workspace/kea-dev/clang-static-analyzer/src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc |
Warning: | line 493, column 10 Value stored to 'start_time' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | // Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC") |
2 | // |
3 | // This Source Code Form is subject to the terms of the Mozilla Public |
4 | // License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. |
6 | |
7 | #include <config.h> |
8 | #include <monitored_duration.h> |
9 | #include <dhcp/dhcp6.h> |
10 | #include <testutils/gtest_utils.h> |
11 | |
12 | #include <gtest/gtest.h> |
13 | #include <sstream> |
14 | #include <unordered_set> |
15 | |
16 | using namespace isc; |
17 | using namespace isc::dhcp; |
18 | using namespace isc::perfmon; |
19 | using namespace boost::posix_time; |
20 | |
21 | namespace { |
22 | |
23 | // Exercises the basic functions of DurationDataInterval. |
24 | TEST(DurationDataInterval, basics)static_assert(sizeof("DurationDataInterval") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("basics") > 1, "test_name must not be empty" ); class DurationDataInterval_basics_Test : public ::testing:: Test { public: DurationDataInterval_basics_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); DurationDataInterval_basics_Test(DurationDataInterval_basics_Test const &) = delete; void operator=(DurationDataInterval_basics_Test const &) = delete; }; ::testing::TestInfo* const DurationDataInterval_basics_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "DurationDataInterval" , "basics", nullptr, nullptr, ::testing::internal::CodeLocation ("monitored_duration_unittests.cc", 24), (::testing::internal ::GetTestTypeId()), ::testing::internal::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite("monitored_duration_unittests.cc" , 24), ::testing::internal::SuiteApiResolver< ::testing::Test >::GetTearDownCaseOrSuite("monitored_duration_unittests.cc" , 24), new ::testing::internal::TestFactoryImpl<DurationDataInterval_basics_Test >); void DurationDataInterval_basics_Test::TestBody() { |
25 | auto start_time = PktEvent::now(); |
26 | |
27 | DurationDataIntervalPtr interval; |
28 | |
29 | // Default Construct a interval. |
30 | interval.reset(new DurationDataInterval()); |
31 | ASSERT_TRUE(interval)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(interval)) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "monitored_duration_unittests.cc", 31, ::testing ::internal::GetBoolAssertionFailureMessage( gtest_ar_, "interval" , "false", "true").c_str()) = ::testing::Message(); |
32 | |
33 | // Verify contents. |
34 | // Start time is set to current time by default. |
35 | EXPECT_GE(interval->getStartTime(), start_time)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperGE("interval->getStartTime()" , "start_time", interval->getStartTime(), start_time))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 35, gtest_ar .failure_message()) = ::testing::Message(); |
36 | EXPECT_EQ(interval->getOccurrences(), 0)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getOccurrences()" , "0", interval->getOccurrences(), 0))) ; else ::testing:: internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 36, gtest_ar.failure_message ()) = ::testing::Message(); |
37 | EXPECT_EQ(interval->getMinDuration(), pos_infin)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMinDuration()" , "pos_infin", interval->getMinDuration(), pos_infin))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 37, gtest_ar .failure_message()) = ::testing::Message(); |
38 | EXPECT_EQ(interval->getMaxDuration(), neg_infin)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMaxDuration()" , "neg_infin", interval->getMaxDuration(), neg_infin))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 38, gtest_ar .failure_message()) = ::testing::Message(); |
39 | EXPECT_EQ(interval->getTotalDuration(), DurationDataInterval::ZERO_DURATION())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getTotalDuration()" , "DurationDataInterval::ZERO_DURATION()", interval->getTotalDuration (), DurationDataInterval::ZERO_DURATION()))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 39, gtest_ar.failure_message ()) = ::testing::Message(); |
40 | EXPECT_EQ(interval->getAverageDuration(), DurationDataInterval::ZERO_DURATION())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getAverageDuration()" , "DurationDataInterval::ZERO_DURATION()", interval->getAverageDuration (), DurationDataInterval::ZERO_DURATION()))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 40, gtest_ar.failure_message ()) = ::testing::Message(); |
41 | |
42 | // Verify that start time can be specified. |
43 | interval.reset(new DurationDataInterval(start_time + milliseconds(5000))); |
44 | ASSERT_TRUE(interval)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(interval)) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "monitored_duration_unittests.cc", 44, ::testing ::internal::GetBoolAssertionFailureMessage( gtest_ar_, "interval" , "false", "true").c_str()) = ::testing::Message(); |
45 | EXPECT_EQ(interval->getStartTime() - start_time, milliseconds(5000))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getStartTime() - start_time" , "milliseconds(5000)", interval->getStartTime() - start_time , milliseconds(5000)))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 45, gtest_ar.failure_message()) = ::testing::Message(); |
46 | |
47 | // Add 100ms duration and check contents. |
48 | Duration d100(milliseconds(100)); |
49 | interval->addDuration(d100); |
50 | EXPECT_EQ(interval->getOccurrences(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getOccurrences()" , "1", interval->getOccurrences(), 1))) ; else ::testing:: internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 50, gtest_ar.failure_message ()) = ::testing::Message(); |
51 | EXPECT_EQ(interval->getMinDuration(), d100)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMinDuration()" , "d100", interval->getMinDuration(), d100))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 51, gtest_ar.failure_message ()) = ::testing::Message(); |
52 | EXPECT_EQ(interval->getMaxDuration(), d100)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMaxDuration()" , "d100", interval->getMaxDuration(), d100))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 52, gtest_ar.failure_message ()) = ::testing::Message(); |
53 | EXPECT_EQ(interval->getTotalDuration(), d100)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getTotalDuration()" , "d100", interval->getTotalDuration(), d100))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 53, gtest_ar.failure_message ()) = ::testing::Message(); |
54 | EXPECT_EQ(interval->getAverageDuration(), d100)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getAverageDuration()" , "d100", interval->getAverageDuration(), d100))) ; else :: testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 54, gtest_ar.failure_message ()) = ::testing::Message(); |
55 | |
56 | // Add 300ms duration and check contents. |
57 | Duration d300(milliseconds(300)); |
58 | interval->addDuration(d300); |
59 | EXPECT_EQ(interval->getOccurrences(), 2)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getOccurrences()" , "2", interval->getOccurrences(), 2))) ; else ::testing:: internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 59, gtest_ar.failure_message ()) = ::testing::Message(); |
60 | EXPECT_EQ(interval->getMinDuration(), d100)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMinDuration()" , "d100", interval->getMinDuration(), d100))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 60, gtest_ar.failure_message ()) = ::testing::Message(); |
61 | EXPECT_EQ(interval->getMaxDuration(), d300)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMaxDuration()" , "d300", interval->getMaxDuration(), d300))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 61, gtest_ar.failure_message ()) = ::testing::Message(); |
62 | EXPECT_EQ(interval->getTotalDuration(), d100 + d300)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getTotalDuration()" , "d100 + d300", interval->getTotalDuration(), d100 + d300 ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 62, gtest_ar .failure_message()) = ::testing::Message(); |
63 | EXPECT_EQ(interval->getAverageDuration(), Duration(milliseconds(200)))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getAverageDuration()" , "Duration(milliseconds(200))", interval->getAverageDuration (), Duration(milliseconds(200))))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 63, gtest_ar.failure_message()) = ::testing::Message(); |
64 | |
65 | // Add 50ms duration and check contents. |
66 | Duration d50(milliseconds(50)); |
67 | interval->addDuration(d50); |
68 | EXPECT_EQ(interval->getOccurrences(), 3)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getOccurrences()" , "3", interval->getOccurrences(), 3))) ; else ::testing:: internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 68, gtest_ar.failure_message ()) = ::testing::Message(); |
69 | EXPECT_EQ(interval->getMinDuration(), d50)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMinDuration()" , "d50", interval->getMinDuration(), d50))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 69, gtest_ar.failure_message ()) = ::testing::Message(); |
70 | EXPECT_EQ(interval->getMaxDuration(), d300)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMaxDuration()" , "d300", interval->getMaxDuration(), d300))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 70, gtest_ar.failure_message ()) = ::testing::Message(); |
71 | EXPECT_EQ(interval->getTotalDuration(), d100 + d300 + d50)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getTotalDuration()" , "d100 + d300 + d50", interval->getTotalDuration(), d100 + d300 + d50))) ; else ::testing::internal::AssertHelper(::testing ::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 71, gtest_ar.failure_message()) = ::testing::Message(); |
72 | EXPECT_EQ(interval->getAverageDuration(), Duration(milliseconds(150)))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getAverageDuration()" , "Duration(milliseconds(150))", interval->getAverageDuration (), Duration(milliseconds(150))))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 72, gtest_ar.failure_message()) = ::testing::Message(); |
73 | |
74 | // Add a zero duration and check contents. |
75 | interval->addDuration(DurationDataInterval::ZERO_DURATION()); |
76 | EXPECT_EQ(interval->getOccurrences(), 4)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getOccurrences()" , "4", interval->getOccurrences(), 4))) ; else ::testing:: internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 76, gtest_ar.failure_message ()) = ::testing::Message(); |
77 | EXPECT_EQ(interval->getMinDuration(), DurationDataInterval::ZERO_DURATION())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMinDuration()" , "DurationDataInterval::ZERO_DURATION()", interval->getMinDuration (), DurationDataInterval::ZERO_DURATION()))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 77, gtest_ar.failure_message ()) = ::testing::Message(); |
78 | EXPECT_EQ(interval->getMaxDuration(), d300)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMaxDuration()" , "d300", interval->getMaxDuration(), d300))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 78, gtest_ar.failure_message ()) = ::testing::Message(); |
79 | EXPECT_EQ(interval->getTotalDuration(), d100 + d300 + d50)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getTotalDuration()" , "d100 + d300 + d50", interval->getTotalDuration(), d100 + d300 + d50))) ; else ::testing::internal::AssertHelper(::testing ::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 79, gtest_ar.failure_message()) = ::testing::Message(); |
80 | EXPECT_EQ(interval->getAverageDuration(), Duration(microseconds(112500)))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("interval->getAverageDuration()" , "Duration(microseconds(112500))", interval->getAverageDuration (), Duration(microseconds(112500))))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 80, gtest_ar.failure_message()) = ::testing::Message(); |
81 | } |
82 | |
83 | // Exercises the basic functions of DurationDataInterval. |
84 | TEST(DurationKey, basics)static_assert(sizeof("DurationKey") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("basics") > 1, "test_name must not be empty" ); class DurationKey_basics_Test : public ::testing::Test { public : DurationKey_basics_Test() {} private: virtual void TestBody (); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); DurationKey_basics_Test(DurationKey_basics_Test const &) = delete; void operator=(DurationKey_basics_Test const &) = delete; }; ::testing::TestInfo* const DurationKey_basics_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "DurationKey" , "basics", nullptr, nullptr, ::testing::internal::CodeLocation ("monitored_duration_unittests.cc", 84), (::testing::internal ::GetTestTypeId()), ::testing::internal::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite("monitored_duration_unittests.cc" , 84), ::testing::internal::SuiteApiResolver< ::testing::Test >::GetTearDownCaseOrSuite("monitored_duration_unittests.cc" , 84), new ::testing::internal::TestFactoryImpl<DurationKey_basics_Test >); void DurationKey_basics_Test::TestBody() { |
85 | DurationKeyPtr key; |
86 | |
87 | // Create valid v4 key, verify contents and label. |
88 | ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { key.reset(new DurationKey(2, DHCPDISCOVER, DHCPOFFER, "process_started", "process_completed", SUBNET_ID_GLOBAL)); } catch (const std::exception& ex) { return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 90, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 90, "Failed") = ::testing ::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))" << " threw non-std::exception"; } } |
89 | "process_started", "process_completed",{ try { key.reset(new DurationKey(2, DHCPDISCOVER, DHCPOFFER, "process_started", "process_completed", SUBNET_ID_GLOBAL)); } catch (const std::exception& ex) { return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 90, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 90, "Failed") = ::testing ::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))" << " threw non-std::exception"; } } |
90 | SUBNET_ID_GLOBAL))){ try { key.reset(new DurationKey(2, DHCPDISCOVER, DHCPOFFER, "process_started", "process_completed", SUBNET_ID_GLOBAL)); } catch (const std::exception& ex) { return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 90, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 90, "Failed") = ::testing ::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))" << " threw non-std::exception"; } }; |
91 | ASSERT_TRUE(key)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(key)) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 91, ::testing::internal:: GetBoolAssertionFailureMessage( gtest_ar_, "key", "false", "true" ).c_str()) = ::testing::Message(); |
92 | EXPECT_EQ(key->getFamily(), AF_INET)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getFamily()" , "2", key->getFamily(), 2))) ; else ::testing::internal:: AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 92, gtest_ar.failure_message()) = ::testing::Message(); |
93 | EXPECT_EQ(key->getQueryType(), DHCPDISCOVER)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getQueryType()" , "DHCPDISCOVER", key->getQueryType(), DHCPDISCOVER))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 93, gtest_ar .failure_message()) = ::testing::Message(); |
94 | EXPECT_EQ(key->getResponseType(), DHCPOFFER)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getResponseType()" , "DHCPOFFER", key->getResponseType(), DHCPOFFER))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 94, gtest_ar .failure_message()) = ::testing::Message(); |
95 | EXPECT_EQ(key->getStartEventLabel(), "process_started")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getStartEventLabel()" , "\"process_started\"", key->getStartEventLabel(), "process_started" ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 95, gtest_ar .failure_message()) = ::testing::Message(); |
96 | EXPECT_EQ(key->getStopEventLabel(), "process_completed")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getStopEventLabel()" , "\"process_completed\"", key->getStopEventLabel(), "process_completed" ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 96, gtest_ar .failure_message()) = ::testing::Message(); |
97 | EXPECT_EQ(key->getSubnetId(), SUBNET_ID_GLOBAL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getSubnetId()" , "SUBNET_ID_GLOBAL", key->getSubnetId(), SUBNET_ID_GLOBAL ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 97, gtest_ar .failure_message()) = ::testing::Message(); |
98 | EXPECT_EQ("DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0",switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("\"DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\"" , "key->getLabel()", "DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0" , key->getLabel()))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 99, gtest_ar.failure_message()) = ::testing::Message() |
99 | key->getLabel())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("\"DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\"" , "key->getLabel()", "DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0" , key->getLabel()))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 99, gtest_ar.failure_message()) = ::testing::Message(); |
100 | EXPECT_EQ("perfmon.DHCPDISCOVER-DHCPOFFER.process_started-process_completed.average-ms",switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("\"perfmon.DHCPDISCOVER-DHCPOFFER.process_started-process_completed.average-ms\"" , "key->getStatName(\"average-ms\")", "perfmon.DHCPDISCOVER-DHCPOFFER.process_started-process_completed.average-ms" , key->getStatName("average-ms")))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 101, gtest_ar.failure_message()) = ::testing::Message() |
101 | key->getStatName("average-ms"))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("\"perfmon.DHCPDISCOVER-DHCPOFFER.process_started-process_completed.average-ms\"" , "key->getStatName(\"average-ms\")", "perfmon.DHCPDISCOVER-DHCPOFFER.process_started-process_completed.average-ms" , key->getStatName("average-ms")))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 101, gtest_ar.failure_message()) = ::testing::Message(); |
102 | |
103 | // Create valid v6 key, verify contents and label. |
104 | ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE,{ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE , "mt_queued", "process_started", 77)); } catch (const std::exception & ex) { return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 105, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 105, "Failed") = ::testing ::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw non-std::exception"; } } |
105 | "mt_queued", "process_started", 77))){ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE , "mt_queued", "process_started", 77)); } catch (const std::exception & ex) { return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 105, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 105, "Failed") = ::testing ::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw non-std::exception"; } }; |
106 | ASSERT_TRUE(key)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(key)) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 106, ::testing::internal ::GetBoolAssertionFailureMessage( gtest_ar_, "key", "false", "true" ).c_str()) = ::testing::Message(); |
107 | EXPECT_EQ(key->getFamily(), AF_INET6)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getFamily()" , "10", key->getFamily(), 10))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 107, gtest_ar.failure_message()) = ::testing::Message(); |
108 | EXPECT_EQ(key->getQueryType(), DHCPV6_SOLICIT)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getQueryType()" , "DHCPV6_SOLICIT", key->getQueryType(), DHCPV6_SOLICIT))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 108, gtest_ar .failure_message()) = ::testing::Message(); |
109 | EXPECT_EQ(key->getResponseType(), DHCPV6_ADVERTISE)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getResponseType()" , "DHCPV6_ADVERTISE", key->getResponseType(), DHCPV6_ADVERTISE ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 109, gtest_ar .failure_message()) = ::testing::Message(); |
110 | EXPECT_EQ(key->getStartEventLabel(), "mt_queued")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getStartEventLabel()" , "\"mt_queued\"", key->getStartEventLabel(), "mt_queued") )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 110, gtest_ar .failure_message()) = ::testing::Message(); |
111 | EXPECT_EQ(key->getStopEventLabel(), "process_started")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getStopEventLabel()" , "\"process_started\"", key->getStopEventLabel(), "process_started" ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 111, gtest_ar .failure_message()) = ::testing::Message(); |
112 | EXPECT_EQ(key->getSubnetId(), 77)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("key->getSubnetId()" , "77", key->getSubnetId(), 77))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 112, gtest_ar.failure_message()) = ::testing::Message(); |
113 | EXPECT_EQ("SOLICIT-ADVERTISE.mt_queued-process_started.77",switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("\"SOLICIT-ADVERTISE.mt_queued-process_started.77\"" , "key->getLabel()", "SOLICIT-ADVERTISE.mt_queued-process_started.77" , key->getLabel()))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 114, gtest_ar.failure_message()) = ::testing::Message() |
114 | key->getLabel())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("\"SOLICIT-ADVERTISE.mt_queued-process_started.77\"" , "key->getLabel()", "SOLICIT-ADVERTISE.mt_queued-process_started.77" , key->getLabel()))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 114, gtest_ar.failure_message()) = ::testing::Message(); |
115 | EXPECT_EQ("subnet-id[77].perfmon.SOLICIT-ADVERTISE.mt_queued-process_started.average-ms",switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("\"subnet-id[77].perfmon.SOLICIT-ADVERTISE.mt_queued-process_started.average-ms\"" , "key->getStatName(\"average-ms\")", "subnet-id[77].perfmon.SOLICIT-ADVERTISE.mt_queued-process_started.average-ms" , key->getStatName("average-ms")))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 116, gtest_ar.failure_message()) = ::testing::Message() |
116 | key->getStatName("average-ms"))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("\"subnet-id[77].perfmon.SOLICIT-ADVERTISE.mt_queued-process_started.average-ms\"" , "key->getStatName(\"average-ms\")", "subnet-id[77].perfmon.SOLICIT-ADVERTISE.mt_queued-process_started.average-ms" , key->getStatName("average-ms")))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 116, gtest_ar.failure_message()) = ::testing::Message(); |
117 | |
118 | // Make sure constructor catches an insane message pairing. |
119 | ASSERT_THROW_MSG(key.reset(new DurationKey(AF_INET6, DHCPV6_ADVERTISE, DHCPV6_SOLICIT,{ try { key.reset(new DurationKey(10, DHCPV6_ADVERTISE, DHCPV6_SOLICIT , "mt_queued", "process_started", 77)); return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 121, "Failed") = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"Query type not supported by monitoring: ADVERTISE\"", std ::string(ex.what()), "Query type not supported by monitoring: ADVERTISE" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 121, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 121, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
120 | "mt_queued", "process_started", 77)), BadValue,{ try { key.reset(new DurationKey(10, DHCPV6_ADVERTISE, DHCPV6_SOLICIT , "mt_queued", "process_started", 77)); return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 121, "Failed") = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"Query type not supported by monitoring: ADVERTISE\"", std ::string(ex.what()), "Query type not supported by monitoring: ADVERTISE" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 121, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 121, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
121 | "Query type not supported by monitoring: ADVERTISE"){ try { key.reset(new DurationKey(10, DHCPV6_ADVERTISE, DHCPV6_SOLICIT , "mt_queued", "process_started", 77)); return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 121, "Failed") = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"Query type not supported by monitoring: ADVERTISE\"", std ::string(ex.what()), "Query type not supported by monitoring: ADVERTISE" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 121, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 121, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "BadValue"; } }; |
122 | } |
123 | |
124 | // Verify v4 message pair validation works. |
125 | TEST(DurationKey, validateMessagePairs4)static_assert(sizeof("DurationKey") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("validateMessagePairs4") > 1, "test_name must not be empty" ); class DurationKey_validateMessagePairs4_Test : public ::testing ::Test { public: DurationKey_validateMessagePairs4_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); DurationKey_validateMessagePairs4_Test (DurationKey_validateMessagePairs4_Test const &) = delete ; void operator=(DurationKey_validateMessagePairs4_Test const &) = delete; }; ::testing::TestInfo* const DurationKey_validateMessagePairs4_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "DurationKey" , "validateMessagePairs4", nullptr, nullptr, ::testing::internal ::CodeLocation("monitored_duration_unittests.cc", 125), (::testing ::internal::GetTestTypeId()), ::testing::internal::SuiteApiResolver < ::testing::Test>::GetSetUpCaseOrSuite("monitored_duration_unittests.cc" , 125), ::testing::internal::SuiteApiResolver< ::testing:: Test>::GetTearDownCaseOrSuite("monitored_duration_unittests.cc" , 125), new ::testing::internal::TestFactoryImpl<DurationKey_validateMessagePairs4_Test >); void DurationKey_validateMessagePairs4_Test::TestBody( ) { |
126 | // Defines a test scenario. |
127 | struct Scenario { |
128 | // Query type to use in the scenario. |
129 | uint8_t query_type_; |
130 | // Valid response types for query type (if any). |
131 | std::unordered_set<uint8_t> valid_responses_; |
132 | }; |
133 | |
134 | // List of scenarios to test, one per v4 message type. |
135 | std::list<Scenario> scenarios { |
136 | {DHCP_NOTYPE, {DHCP_NOTYPE, DHCPOFFER, DHCPACK, DHCPNAK}}, |
137 | {DHCPDISCOVER, {DHCP_NOTYPE, DHCPOFFER, DHCPNAK}}, |
138 | {DHCPOFFER, {}}, |
139 | {DHCPREQUEST, {DHCP_NOTYPE, DHCPACK, DHCPNAK}}, |
140 | {DHCPDECLINE, {}}, |
141 | {DHCPACK, {}}, |
142 | {DHCPNAK, {}}, |
143 | {DHCPRELEASE, {}}, |
144 | {DHCPINFORM, {DHCP_NOTYPE, DHCPACK}}, |
145 | // {DHCPFORCERENEW, {}}, commented out in dhcp4.h |
146 | {DHCPLEASEQUERY, {}}, |
147 | {DHCPLEASEUNASSIGNED, {}}, |
148 | {DHCPLEASEUNKNOWN, {}}, |
149 | {DHCPLEASEACTIVE, {}}, |
150 | {DHCPBULKLEASEQUERY, {}}, |
151 | {DHCPLEASEQUERYDONE, {}}, |
152 | // {DHCPACTIVELEASEQUERY, {}}, commented out in dhcp4.h |
153 | {DHCPLEASEQUERYSTATUS, {}}, |
154 | {DHCPTLS, {}}, |
155 | }; |
156 | |
157 | // Iterate over the scenarios. Attempt to pair each scenario query type with every v4 message |
158 | // type as a response type. If the response type is in the scenario's valid list, the pair |
159 | // should validate, otherwise it should throw. |
160 | for (auto const& scenario : scenarios) { |
161 | for (uint8_t response_type = DHCP_NOTYPE; response_type < DHCP_TYPES_EOF; ++response_type) { |
162 | if (scenario.valid_responses_.count(response_type)) { |
163 | ASSERT_NO_THROW_LOG({ try { DurationKey::validateMessagePair(2, scenario.query_type_ , response_type); } catch (const std::exception& ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "monitored_duration_unittests.cc", 164, "Failed" ) = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type)" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 164, "Failed") = ::testing ::Message() << "DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type)" << " threw non-std::exception"; } } |
164 | DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type)){ try { DurationKey::validateMessagePair(2, scenario.query_type_ , response_type); } catch (const std::exception& ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "monitored_duration_unittests.cc", 164, "Failed" ) = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type)" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 164, "Failed") = ::testing ::Message() << "DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type)" << " threw non-std::exception"; } }; |
165 | } else { |
166 | ASSERT_THROW(switch (0) case 0: default: if (::testing::internal::ConstCharPtr gtest_msg = "") { bool gtest_caught_expected = false; try { if (::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair (2, scenario.query_type_, response_type); }; } catch (BadValue const&) { gtest_caught_expected = true; } catch (...) { gtest_msg .value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws a different type." ; goto gtest_label_testthrow_168; } if (!gtest_caught_expected ) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws nothing." ; goto gtest_label_testthrow_168; } } else gtest_label_testthrow_168 : return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 168, gtest_msg .value) = ::testing::Message() |
167 | DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type),switch (0) case 0: default: if (::testing::internal::ConstCharPtr gtest_msg = "") { bool gtest_caught_expected = false; try { if (::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair (2, scenario.query_type_, response_type); }; } catch (BadValue const&) { gtest_caught_expected = true; } catch (...) { gtest_msg .value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws a different type." ; goto gtest_label_testthrow_168; } if (!gtest_caught_expected ) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws nothing." ; goto gtest_label_testthrow_168; } } else gtest_label_testthrow_168 : return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 168, gtest_msg .value) = ::testing::Message() |
168 | BadValue)switch (0) case 0: default: if (::testing::internal::ConstCharPtr gtest_msg = "") { bool gtest_caught_expected = false; try { if (::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair (2, scenario.query_type_, response_type); }; } catch (BadValue const&) { gtest_caught_expected = true; } catch (...) { gtest_msg .value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws a different type." ; goto gtest_label_testthrow_168; } if (!gtest_caught_expected ) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws nothing." ; goto gtest_label_testthrow_168; } } else gtest_label_testthrow_168 : return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 168, gtest_msg .value) = ::testing::Message(); |
169 | } |
170 | } |
171 | } |
172 | } |
173 | |
174 | // Verify v6 message pair validation works. |
175 | TEST(DurationKey, validateMessagePairs6)static_assert(sizeof("DurationKey") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("validateMessagePairs6") > 1, "test_name must not be empty" ); class DurationKey_validateMessagePairs6_Test : public ::testing ::Test { public: DurationKey_validateMessagePairs6_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); DurationKey_validateMessagePairs6_Test (DurationKey_validateMessagePairs6_Test const &) = delete ; void operator=(DurationKey_validateMessagePairs6_Test const &) = delete; }; ::testing::TestInfo* const DurationKey_validateMessagePairs6_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "DurationKey" , "validateMessagePairs6", nullptr, nullptr, ::testing::internal ::CodeLocation("monitored_duration_unittests.cc", 175), (::testing ::internal::GetTestTypeId()), ::testing::internal::SuiteApiResolver < ::testing::Test>::GetSetUpCaseOrSuite("monitored_duration_unittests.cc" , 175), ::testing::internal::SuiteApiResolver< ::testing:: Test>::GetTearDownCaseOrSuite("monitored_duration_unittests.cc" , 175), new ::testing::internal::TestFactoryImpl<DurationKey_validateMessagePairs6_Test >); void DurationKey_validateMessagePairs6_Test::TestBody( ) { |
176 | // Defines a test scenario. |
177 | struct Scenario { |
178 | // Query type to use in the scenario. |
179 | uint8_t query_type_; |
180 | // Valid response types for query type (if any). |
181 | std::unordered_set<uint8_t> valid_responses_; |
182 | }; |
183 | |
184 | // List of scenarios to test, one per v6 message type. |
185 | std::list<Scenario> scenarios { |
186 | {DHCPV6_NOTYPE, {DHCPV6_NOTYPE, DHCPV6_ADVERTISE, DHCPV6_REPLY}}, |
187 | {DHCPV6_SOLICIT, {DHCPV6_NOTYPE, DHCPV6_ADVERTISE, DHCPV6_REPLY}}, |
188 | {DHCPV6_ADVERTISE, {}}, |
189 | {DHCPV6_REQUEST, {DHCPV6_NOTYPE, DHCPV6_REPLY}}, |
190 | {DHCPV6_CONFIRM, {DHCPV6_NOTYPE, DHCPV6_REPLY}}, |
191 | {DHCPV6_RENEW, {DHCPV6_NOTYPE, DHCPV6_REPLY}}, |
192 | {DHCPV6_REBIND, {DHCPV6_NOTYPE, DHCPV6_REPLY}}, |
193 | {DHCPV6_REPLY, {}}, |
194 | {DHCPV6_RELEASE, {}}, |
195 | {DHCPV6_DECLINE, {}}, |
196 | {DHCPV6_RECONFIGURE, {}}, |
197 | {DHCPV6_INFORMATION_REQUEST, {}}, |
198 | {DHCPV6_RELAY_FORW, {}}, |
199 | {DHCPV6_RELAY_REPL, {}}, |
200 | {DHCPV6_LEASEQUERY, {}}, |
201 | {DHCPV6_LEASEQUERY_REPLY, {}}, |
202 | {DHCPV6_LEASEQUERY_DONE, {}}, |
203 | {DHCPV6_LEASEQUERY_DATA, {}}, |
204 | {DHCPV6_RECONFIGURE_REQUEST, {}}, |
205 | {DHCPV6_RECONFIGURE_REPLY, {}}, |
206 | {DHCPV6_DHCPV4_QUERY, {}}, |
207 | {DHCPV6_DHCPV4_RESPONSE, {}}, |
208 | {DHCPV6_ACTIVELEASEQUERY, {}}, |
209 | {DHCPV6_STARTTLS, {}}, |
210 | {DHCPV6_BNDUPD, {}}, |
211 | {DHCPV6_BNDREPLY, {}}, |
212 | {DHCPV6_POOLREQ, {}}, |
213 | {DHCPV6_POOLRESP, {}}, |
214 | {DHCPV6_UPDREQ, {}}, |
215 | {DHCPV6_UPDREQALL, {}}, |
216 | {DHCPV6_UPDDONE, {}}, |
217 | {DHCPV6_CONNECT, {}}, |
218 | {DHCPV6_CONNECTREPLY, {}}, |
219 | {DHCPV6_DISCONNECT, {}}, |
220 | {DHCPV6_STATE, {}}, |
221 | {DHCPV6_CONTACT, {}} |
222 | }; |
223 | |
224 | // Iterate over the scenarios. Attempt to pair each scenario query type with every v6 message |
225 | // type as a response type. If the response type is in the scenario's valid list, the pair |
226 | // should validate, otherwise it should throw. |
227 | for (auto const& scenario : scenarios) { |
228 | for (uint8_t response_type = DHCPV6_NOTYPE; response_type < DHCPV6_TYPES_EOF; ++response_type) { |
229 | if (scenario.valid_responses_.count(response_type)) { |
230 | ASSERT_NO_THROW_LOG({ try { DurationKey::validateMessagePair(10, scenario.query_type_ , response_type); } catch (const std::exception& ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "monitored_duration_unittests.cc", 231, "Failed" ) = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type)" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 231, "Failed") = ::testing ::Message() << "DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type)" << " threw non-std::exception"; } } |
231 | DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type)){ try { DurationKey::validateMessagePair(10, scenario.query_type_ , response_type); } catch (const std::exception& ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult:: kFatalFailure, "monitored_duration_unittests.cc", 231, "Failed" ) = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type)" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 231, "Failed") = ::testing ::Message() << "DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type)" << " threw non-std::exception"; } }; |
232 | } else { |
233 | ASSERT_THROW(switch (0) case 0: default: if (::testing::internal::ConstCharPtr gtest_msg = "") { bool gtest_caught_expected = false; try { if (::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair (10, scenario.query_type_, response_type); }; } catch (BadValue const&) { gtest_caught_expected = true; } catch (...) { gtest_msg .value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws a different type." ; goto gtest_label_testthrow_235; } if (!gtest_caught_expected ) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws nothing." ; goto gtest_label_testthrow_235; } } else gtest_label_testthrow_235 : return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 235, gtest_msg .value) = ::testing::Message() |
234 | DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type),switch (0) case 0: default: if (::testing::internal::ConstCharPtr gtest_msg = "") { bool gtest_caught_expected = false; try { if (::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair (10, scenario.query_type_, response_type); }; } catch (BadValue const&) { gtest_caught_expected = true; } catch (...) { gtest_msg .value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws a different type." ; goto gtest_label_testthrow_235; } if (!gtest_caught_expected ) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws nothing." ; goto gtest_label_testthrow_235; } } else gtest_label_testthrow_235 : return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 235, gtest_msg .value) = ::testing::Message() |
235 | BadValue)switch (0) case 0: default: if (::testing::internal::ConstCharPtr gtest_msg = "") { bool gtest_caught_expected = false; try { if (::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair (10, scenario.query_type_, response_type); }; } catch (BadValue const&) { gtest_caught_expected = true; } catch (...) { gtest_msg .value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws a different type." ; goto gtest_label_testthrow_235; } if (!gtest_caught_expected ) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)" " throws an exception of type " "BadValue" ".\n Actual: it throws nothing." ; goto gtest_label_testthrow_235; } } else gtest_label_testthrow_235 : return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 235, gtest_msg .value) = ::testing::Message(); |
236 | } |
237 | } |
238 | } |
239 | } |
240 | |
241 | /// @brief Verify DurationKey equality operator |
242 | TEST(DurationKey, equalityOperators)static_assert(sizeof("DurationKey") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("equalityOperators") > 1, "test_name must not be empty" ); class DurationKey_equalityOperators_Test : public ::testing ::Test { public: DurationKey_equalityOperators_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); DurationKey_equalityOperators_Test (DurationKey_equalityOperators_Test const &) = delete; void operator=(DurationKey_equalityOperators_Test const &) = delete ; }; ::testing::TestInfo* const DurationKey_equalityOperators_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "DurationKey" , "equalityOperators", nullptr, nullptr, ::testing::internal:: CodeLocation("monitored_duration_unittests.cc", 242), (::testing ::internal::GetTestTypeId()), ::testing::internal::SuiteApiResolver < ::testing::Test>::GetSetUpCaseOrSuite("monitored_duration_unittests.cc" , 242), ::testing::internal::SuiteApiResolver< ::testing:: Test>::GetTearDownCaseOrSuite("monitored_duration_unittests.cc" , 242), new ::testing::internal::TestFactoryImpl<DurationKey_equalityOperators_Test >); void DurationKey_equalityOperators_Test::TestBody() { |
243 | DurationKeyPtr refkey; |
244 | DurationKeyPtr compkey; |
245 | |
246 | ASSERT_NO_THROW_LOG(refkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY,{ try { refkey.reset(new DurationKey(10, DHCPV6_REQUEST, DHCPV6_REPLY , "event_2", "event_3", 100)); } catch (const std::exception& ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 247, "Failed" ) = ::testing::Message() << "refkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 247, "Failed") = ::testing ::Message() << "refkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw non-std::exception"; } } |
247 | "event_2", "event_3", 100))){ try { refkey.reset(new DurationKey(10, DHCPV6_REQUEST, DHCPV6_REPLY , "event_2", "event_3", 100)); } catch (const std::exception& ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 247, "Failed" ) = ::testing::Message() << "refkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 247, "Failed") = ::testing ::Message() << "refkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw non-std::exception"; } }; |
248 | |
249 | ASSERT_NO_THROW_LOG(compkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY,{ try { compkey.reset(new DurationKey(10, DHCPV6_REQUEST, DHCPV6_REPLY , "event_2", "event_3", 100)); } catch (const std::exception& ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 250, "Failed" ) = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 250, "Failed") = ::testing ::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw non-std::exception"; } } |
250 | "event_2", "event_3", 100))){ try { compkey.reset(new DurationKey(10, DHCPV6_REQUEST, DHCPV6_REPLY , "event_2", "event_3", 100)); } catch (const std::exception& ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 250, "Failed" ) = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 250, "Failed") = ::testing ::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw non-std::exception"; } }; |
251 | EXPECT_EQ(*compkey, *refkey)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("*compkey" , "*refkey", *compkey, *refkey))) ; else ::testing::internal:: AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 251, gtest_ar.failure_message()) = ::testing::Message(); |
252 | |
253 | ASSERT_NO_THROW_LOG(compkey.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_REPLY,{ try { compkey.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_REPLY , "event_2", "event_3", 100)); } catch (const std::exception& ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 254, "Failed" ) = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 254, "Failed") = ::testing ::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw non-std::exception"; } } |
254 | "event_2", "event_3", 100))){ try { compkey.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_REPLY , "event_2", "event_3", 100)); } catch (const std::exception& ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 254, "Failed" ) = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 254, "Failed") = ::testing ::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))" << " threw non-std::exception"; } }; |
255 | EXPECT_NE(*compkey, *refkey)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("*compkey", "*refkey" , *compkey, *refkey))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 255, gtest_ar.failure_message()) = ::testing::Message(); |
256 | } |
257 | |
258 | // Verifies MonitoredDuration valid construction. |
259 | TEST(MonitoredDuration, validConstructors)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("validConstructors") > 1, "test_name must not be empty" ); class MonitoredDuration_validConstructors_Test : public :: testing::Test { public: MonitoredDuration_validConstructors_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); MonitoredDuration_validConstructors_Test (MonitoredDuration_validConstructors_Test const &) = delete ; void operator=(MonitoredDuration_validConstructors_Test const &) = delete; }; ::testing::TestInfo* const MonitoredDuration_validConstructors_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration" , "validConstructors", nullptr, nullptr, ::testing::internal:: CodeLocation("monitored_duration_unittests.cc", 259), (::testing ::internal::GetTestTypeId()), ::testing::internal::SuiteApiResolver < ::testing::Test>::GetSetUpCaseOrSuite("monitored_duration_unittests.cc" , 259), ::testing::internal::SuiteApiResolver< ::testing:: Test>::GetTearDownCaseOrSuite("monitored_duration_unittests.cc" , 259), new ::testing::internal::TestFactoryImpl<MonitoredDuration_validConstructors_Test >); void MonitoredDuration_validConstructors_Test::TestBody () { |
260 | MonitoredDurationPtr mond; |
261 | Duration interval_duration(seconds(60)); |
262 | |
263 | // Create valid v4 duration, verify contents and label. |
264 | ASSERT_NO_THROW_LOG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 266, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 266, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } } |
265 | "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 266, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 266, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } } |
266 | SUBNET_ID_GLOBAL, interval_duration))){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 266, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 266, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } }; |
267 | ASSERT_TRUE(mond)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(mond)) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 267, ::testing::internal ::GetBoolAssertionFailureMessage( gtest_ar_, "mond", "false", "true").c_str()) = ::testing::Message(); |
268 | EXPECT_EQ(mond->getFamily(), AF_INET)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getFamily()" , "2", mond->getFamily(), 2))) ; else ::testing::internal:: AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 268, gtest_ar.failure_message()) = ::testing::Message(); |
269 | EXPECT_EQ(mond->getQueryType(), DHCPDISCOVER)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getQueryType()" , "DHCPDISCOVER", mond->getQueryType(), DHCPDISCOVER))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 269, gtest_ar .failure_message()) = ::testing::Message(); |
270 | EXPECT_EQ(mond->getResponseType(), DHCPOFFER)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getResponseType()" , "DHCPOFFER", mond->getResponseType(), DHCPOFFER))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 270, gtest_ar .failure_message()) = ::testing::Message(); |
271 | EXPECT_EQ(mond->getStartEventLabel(), "process_started")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getStartEventLabel()" , "\"process_started\"", mond->getStartEventLabel(), "process_started" ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 271, gtest_ar .failure_message()) = ::testing::Message(); |
272 | EXPECT_EQ(mond->getStopEventLabel(), "process_completed")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getStopEventLabel()" , "\"process_completed\"", mond->getStopEventLabel(), "process_completed" ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 272, gtest_ar .failure_message()) = ::testing::Message(); |
273 | EXPECT_EQ(mond->getSubnetId(), SUBNET_ID_GLOBAL)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getSubnetId()" , "SUBNET_ID_GLOBAL", mond->getSubnetId(), SUBNET_ID_GLOBAL ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 273, gtest_ar .failure_message()) = ::testing::Message(); |
274 | EXPECT_EQ("DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0", mond->getLabel())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("\"DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\"" , "mond->getLabel()", "DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0" , mond->getLabel()))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 274, gtest_ar.failure_message()) = ::testing::Message(); |
275 | EXPECT_EQ(mond->getIntervalDuration(), interval_duration)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getIntervalDuration()" , "interval_duration", mond->getIntervalDuration(), interval_duration ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 275, gtest_ar .failure_message()) = ::testing::Message(); |
276 | EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 276, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getCurrentInterval()", "true", "false").c_str()) = ::testing::Message(); |
277 | EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 277, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getPreviousInterval()", "true", "false").c_str()) = ::testing::Message(); |
278 | |
279 | // Create valid v6 key and use that to create an alarm. Verify contents and label. |
280 | DurationKeyPtr key; |
281 | ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE,{ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE , "mt_queued", "process_started", 77)); } catch (const std::exception & ex) { return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 282, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 282, "Failed") = ::testing ::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw non-std::exception"; } } |
282 | "mt_queued", "process_started", 77))){ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE , "mt_queued", "process_started", 77)); } catch (const std::exception & ex) { return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 282, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 282, "Failed") = ::testing ::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw non-std::exception"; } }; |
283 | |
284 | ASSERT_NO_THROW_LOG(mond.reset(new MonitoredDuration(*key, interval_duration))){ try { mond.reset(new MonitoredDuration(*key, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 284, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(*key, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 284, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(*key, interval_duration))" << " threw non-std::exception"; } }; |
285 | ASSERT_TRUE(mond)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(mond)) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 285, ::testing::internal ::GetBoolAssertionFailureMessage( gtest_ar_, "mond", "false", "true").c_str()) = ::testing::Message(); |
286 | EXPECT_EQ(mond->getFamily(), AF_INET6)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getFamily()" , "10", mond->getFamily(), 10))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 286, gtest_ar.failure_message()) = ::testing::Message(); |
287 | EXPECT_EQ(mond->getQueryType(), DHCPV6_SOLICIT)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getQueryType()" , "DHCPV6_SOLICIT", mond->getQueryType(), DHCPV6_SOLICIT)) ) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 287, gtest_ar .failure_message()) = ::testing::Message(); |
288 | EXPECT_EQ(mond->getResponseType(), DHCPV6_ADVERTISE)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getResponseType()" , "DHCPV6_ADVERTISE", mond->getResponseType(), DHCPV6_ADVERTISE ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 288, gtest_ar .failure_message()) = ::testing::Message(); |
289 | EXPECT_EQ(mond->getStartEventLabel(), "mt_queued")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getStartEventLabel()" , "\"mt_queued\"", mond->getStartEventLabel(), "mt_queued" ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 289, gtest_ar .failure_message()) = ::testing::Message(); |
290 | EXPECT_EQ(mond->getStopEventLabel(), "process_started")switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getStopEventLabel()" , "\"process_started\"", mond->getStopEventLabel(), "process_started" ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 290, gtest_ar .failure_message()) = ::testing::Message(); |
291 | EXPECT_EQ(mond->getSubnetId(), 77)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getSubnetId()" , "77", mond->getSubnetId(), 77))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 291, gtest_ar.failure_message()) = ::testing::Message(); |
292 | EXPECT_EQ("SOLICIT-ADVERTISE.mt_queued-process_started.77", mond->getLabel())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("\"SOLICIT-ADVERTISE.mt_queued-process_started.77\"" , "mond->getLabel()", "SOLICIT-ADVERTISE.mt_queued-process_started.77" , mond->getLabel()))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 292, gtest_ar.failure_message()) = ::testing::Message(); |
293 | EXPECT_EQ(mond->getIntervalDuration(), interval_duration)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getIntervalDuration()" , "interval_duration", mond->getIntervalDuration(), interval_duration ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 293, gtest_ar .failure_message()) = ::testing::Message(); |
294 | EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 294, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getCurrentInterval()", "true", "false").c_str()) = ::testing::Message(); |
295 | EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 295, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getPreviousInterval()", "true", "false").c_str()) = ::testing::Message(); |
296 | } |
297 | |
298 | // Verifies Copy construction. Since current and previous intervals are not |
299 | // exposed, this test relies on addSample() to alter them. |
300 | TEST(MonitoredDuration, copyConstructors)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("copyConstructors") > 1, "test_name must not be empty" ); class MonitoredDuration_copyConstructors_Test : public ::testing ::Test { public: MonitoredDuration_copyConstructors_Test() {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); MonitoredDuration_copyConstructors_Test (MonitoredDuration_copyConstructors_Test const &) = delete ; void operator=(MonitoredDuration_copyConstructors_Test const &) = delete; }; ::testing::TestInfo* const MonitoredDuration_copyConstructors_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration" , "copyConstructors", nullptr, nullptr, ::testing::internal:: CodeLocation("monitored_duration_unittests.cc", 300), (::testing ::internal::GetTestTypeId()), ::testing::internal::SuiteApiResolver < ::testing::Test>::GetSetUpCaseOrSuite("monitored_duration_unittests.cc" , 300), ::testing::internal::SuiteApiResolver< ::testing:: Test>::GetTearDownCaseOrSuite("monitored_duration_unittests.cc" , 300), new ::testing::internal::TestFactoryImpl<MonitoredDuration_copyConstructors_Test >); void MonitoredDuration_copyConstructors_Test::TestBody () { |
301 | MonitoredDurationPtr mond; |
302 | Duration interval_duration(microseconds(10)); |
303 | |
304 | // Create valid v4 duration, verify contents and label. |
305 | ASSERT_NO_THROW_LOG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 307, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 307, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } } |
306 | "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 307, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 307, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } } |
307 | SUBNET_ID_GLOBAL, interval_duration))){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 307, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 307, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } }; |
308 | |
309 | // Make a copy. |
310 | MonitoredDurationPtr duplicate; |
311 | duplicate.reset(new MonitoredDuration(*mond)); |
312 | |
313 | // Should have different pointers. |
314 | EXPECT_NE(duplicate, mond)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("duplicate", "mond" , duplicate, mond))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 314, gtest_ar.failure_message()) = ::testing::Message(); |
315 | |
316 | // Key values should be equal (DurationKey::operator==). |
317 | EXPECT_EQ(*duplicate, *mond)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("*duplicate" , "*mond", *duplicate, *mond))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 317, gtest_ar.failure_message()) = ::testing::Message(); |
318 | |
319 | // Check non-key members. |
320 | EXPECT_EQ(duplicate->getIntervalDuration(), mond->getIntervalDuration())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("duplicate->getIntervalDuration()" , "mond->getIntervalDuration()", duplicate->getIntervalDuration (), mond->getIntervalDuration()))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 320, gtest_ar.failure_message()) = ::testing::Message(); |
321 | EXPECT_FALSE(duplicate->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(duplicate->getCurrentInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 321, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "duplicate->getCurrentInterval()", "true", "false").c_str ()) = ::testing::Message(); |
322 | EXPECT_FALSE(duplicate->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(duplicate->getPreviousInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 322, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "duplicate->getPreviousInterval()", "true", "false").c_str ()) = ::testing::Message(); |
323 | |
324 | // Add a sample to the original. |
325 | EXPECT_FALSE(mond->addSample(microseconds(2)))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->addSample( microseconds(2))))) ; else ::testing::internal::AssertHelper( ::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 325, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "mond->addSample(microseconds(2))", "true", "false").c_str ()) = ::testing::Message(); |
326 | |
327 | // Make a new copy. |
328 | duplicate.reset(new MonitoredDuration(*mond)); |
329 | |
330 | // Current intervals should exist. |
331 | ASSERT_TRUE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(mond->getCurrentInterval ())) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 331, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "mond->getCurrentInterval()", "false", "true").c_str()) = ::testing::Message(); |
332 | ASSERT_TRUE(duplicate->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(duplicate->getCurrentInterval ())) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 332, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "duplicate->getCurrentInterval()", "false", "true").c_str ()) = ::testing::Message(); |
333 | // They should not be the same object but the content should be equal. |
334 | EXPECT_NE(duplicate->getCurrentInterval(), mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("duplicate->getCurrentInterval()" , "mond->getCurrentInterval()", duplicate->getCurrentInterval (), mond->getCurrentInterval()))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 334, gtest_ar.failure_message()) = ::testing::Message(); |
335 | EXPECT_EQ(*duplicate->getCurrentInterval(), *mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("*duplicate->getCurrentInterval()" , "*mond->getCurrentInterval()", *duplicate->getCurrentInterval (), *mond->getCurrentInterval()))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 335, gtest_ar.failure_message()) = ::testing::Message(); |
336 | // Previous interval should not exist. |
337 | ASSERT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval ()))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 337, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "mond->getPreviousInterval()", "true", "false").c_str()) = ::testing::Message(); |
338 | ASSERT_FALSE(duplicate->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(duplicate->getPreviousInterval ()))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 338, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "duplicate->getPreviousInterval()", "true", "false").c_str ()) = ::testing::Message(); |
339 | |
340 | // Sleep past interval duration. |
341 | usleep(20); |
342 | |
343 | // Add anoter sample to the original. |
344 | EXPECT_TRUE(mond->addSample(microseconds(2)))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(mond->addSample(microseconds (2)))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 344, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->addSample(microseconds(2))", "false", "true").c_str ()) = ::testing::Message(); |
345 | |
346 | // Make a new copy. |
347 | duplicate.reset(new MonitoredDuration(*mond)); |
348 | |
349 | // Current intervals should exist. |
350 | ASSERT_TRUE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(mond->getCurrentInterval ())) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 350, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "mond->getCurrentInterval()", "false", "true").c_str()) = ::testing::Message(); |
351 | ASSERT_TRUE(duplicate->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(duplicate->getCurrentInterval ())) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 351, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "duplicate->getCurrentInterval()", "false", "true").c_str ()) = ::testing::Message(); |
352 | // They should not be the same object but the content should be equal. |
353 | EXPECT_NE(duplicate->getCurrentInterval(), mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("duplicate->getCurrentInterval()" , "mond->getCurrentInterval()", duplicate->getCurrentInterval (), mond->getCurrentInterval()))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 353, gtest_ar.failure_message()) = ::testing::Message(); |
354 | EXPECT_EQ(*duplicate->getCurrentInterval(), *mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("*duplicate->getCurrentInterval()" , "*mond->getCurrentInterval()", *duplicate->getCurrentInterval (), *mond->getCurrentInterval()))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 354, gtest_ar.failure_message()) = ::testing::Message(); |
355 | |
356 | // Current previous should exist. |
357 | ASSERT_TRUE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(mond->getPreviousInterval ())) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 357, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "mond->getPreviousInterval()", "false", "true").c_str()) = ::testing::Message(); |
358 | ASSERT_TRUE(duplicate->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(duplicate->getPreviousInterval ())) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 358, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "duplicate->getPreviousInterval()", "false", "true").c_str ()) = ::testing::Message(); |
359 | // They should not be the same object but the content should be equal. |
360 | EXPECT_NE(duplicate->getPreviousInterval(), mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperNE("duplicate->getPreviousInterval()" , "mond->getPreviousInterval()", duplicate->getPreviousInterval (), mond->getPreviousInterval()))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 360, gtest_ar.failure_message()) = ::testing::Message(); |
361 | EXPECT_EQ(*duplicate->getPreviousInterval(), *mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("*duplicate->getPreviousInterval()" , "*mond->getPreviousInterval()", *duplicate->getPreviousInterval (), *mond->getPreviousInterval()))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 361, gtest_ar.failure_message()) = ::testing::Message(); |
362 | } |
363 | |
364 | // Verifies MonitoredDuration invalid construction. |
365 | TEST(MonitoredDuration, invalidConstructors)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("invalidConstructors") > 1, "test_name must not be empty" ); class MonitoredDuration_invalidConstructors_Test : public :: testing::Test { public: MonitoredDuration_invalidConstructors_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); MonitoredDuration_invalidConstructors_Test (MonitoredDuration_invalidConstructors_Test const &) = delete ; void operator=(MonitoredDuration_invalidConstructors_Test const &) = delete; }; ::testing::TestInfo* const MonitoredDuration_invalidConstructors_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration" , "invalidConstructors", nullptr, nullptr, ::testing::internal ::CodeLocation("monitored_duration_unittests.cc", 365), (::testing ::internal::GetTestTypeId()), ::testing::internal::SuiteApiResolver < ::testing::Test>::GetSetUpCaseOrSuite("monitored_duration_unittests.cc" , 365), ::testing::internal::SuiteApiResolver< ::testing:: Test>::GetTearDownCaseOrSuite("monitored_duration_unittests.cc" , 365), new ::testing::internal::TestFactoryImpl<MonitoredDuration_invalidConstructors_Test >); void MonitoredDuration_invalidConstructors_Test::TestBody () { |
366 | MonitoredDurationPtr mond; |
367 | |
368 | // Make sure we catch an invalid message pairing. |
369 | Duration interval_duration = seconds(60); |
370 | ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPDISCOVER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPDISCOVER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 374, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER\"" , std::string(ex.what()), "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 374, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 374, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
371 | "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPDISCOVER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 374, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER\"" , std::string(ex.what()), "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 374, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 374, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
372 | SUBNET_ID_GLOBAL, interval_duration)),{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPDISCOVER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 374, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER\"" , std::string(ex.what()), "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 374, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 374, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
373 | BadValue,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPDISCOVER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 374, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER\"" , std::string(ex.what()), "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 374, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 374, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
374 | "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER"){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPDISCOVER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 374, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER\"" , std::string(ex.what()), "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 374, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 374, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "BadValue"; } }; |
375 | |
376 | // Interval duration cannot be zero. |
377 | interval_duration = DurationDataInterval::ZERO_DURATION(); |
378 | ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 383, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
379 | "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 383, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
380 | SUBNET_ID_GLOBAL, interval_duration)),{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 383, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
381 | BadValue,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 383, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
382 | "MonitoredDuration - interval_duration 00:00:00,"{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 383, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
383 | " is invalid, it must be greater than 0"){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 383, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 383, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } }; |
384 | |
385 | // Interval duration cannot be negative. |
386 | ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds (-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 391, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
387 | "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds (-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 391, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
388 | SUBNET_ID_GLOBAL, seconds(-5))),{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds (-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 391, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
389 | BadValue,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds (-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 391, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
390 | "MonitoredDuration - interval_duration -00:00:05,"{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds (-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 391, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
391 | " is invalid, it must be greater than 0"){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds (-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 391, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 391, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } }; |
392 | |
393 | // Create valid v6 key. |
394 | DurationKeyPtr key; |
395 | ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE,{ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE , "mt_queued", "process_started", 77)); } catch (const std::exception & ex) { return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 396, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 396, "Failed") = ::testing ::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw non-std::exception"; } } |
396 | "mt_queued", "process_started", 77))){ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE , "mt_queued", "process_started", 77)); } catch (const std::exception & ex) { return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 396, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 396, "Failed") = ::testing ::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))" << " threw non-std::exception"; } }; |
397 | |
398 | // Interval duration cannot be zero. |
399 | ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(*key, interval_duration)),{ try { mond.reset(new MonitoredDuration(*key, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 402, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 402, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 402, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
400 | BadValue,{ try { mond.reset(new MonitoredDuration(*key, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 402, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 402, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 402, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
401 | "MonitoredDuration - interval_duration 00:00:00,"{ try { mond.reset(new MonitoredDuration(*key, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 402, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 402, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 402, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
402 | " is invalid, it must be greater than 0"){ try { mond.reset(new MonitoredDuration(*key, interval_duration )); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 402, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 402, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 402, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } }; |
403 | |
404 | // Interval duration cannot be negative. |
405 | ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(*key, seconds(-5))),{ try { mond.reset(new MonitoredDuration(*key, seconds(-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 408, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 408, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 408, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
406 | BadValue,{ try { mond.reset(new MonitoredDuration(*key, seconds(-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 408, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 408, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 408, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
407 | "MonitoredDuration - interval_duration -00:00:05,"{ try { mond.reset(new MonitoredDuration(*key, seconds(-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 408, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 408, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 408, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } } |
408 | " is invalid, it must be greater than 0"){ try { mond.reset(new MonitoredDuration(*key, seconds(-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 408, "Failed" ) = ::testing::Message() << "no exception, expected: " << "BadValue"; } catch (const BadValue& ex) { switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = ( ::testing::internal::EqHelper::Compare("std::string(ex.what())" , "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\"" , std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05," " is invalid, it must be greater than 0"))) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 408, gtest_ar.failure_message ()) = ::testing::Message(); } catch (...) { return ::testing:: internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 408, "Failed") = ::testing ::Message() << "wrong exception type thrown, expected: " << "BadValue"; } }; |
409 | } |
410 | |
411 | // Exercises MonitoredDuration::addSample() and MonitoredDuration::clear(). |
412 | TEST(MonitoredDuration, addSampleAndClear)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("addSampleAndClear") > 1, "test_name must not be empty" ); class MonitoredDuration_addSampleAndClear_Test : public :: testing::Test { public: MonitoredDuration_addSampleAndClear_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); MonitoredDuration_addSampleAndClear_Test (MonitoredDuration_addSampleAndClear_Test const &) = delete ; void operator=(MonitoredDuration_addSampleAndClear_Test const &) = delete; }; ::testing::TestInfo* const MonitoredDuration_addSampleAndClear_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration" , "addSampleAndClear", nullptr, nullptr, ::testing::internal:: CodeLocation("monitored_duration_unittests.cc", 412), (::testing ::internal::GetTestTypeId()), ::testing::internal::SuiteApiResolver < ::testing::Test>::GetSetUpCaseOrSuite("monitored_duration_unittests.cc" , 412), ::testing::internal::SuiteApiResolver< ::testing:: Test>::GetTearDownCaseOrSuite("monitored_duration_unittests.cc" , 412), new ::testing::internal::TestFactoryImpl<MonitoredDuration_addSampleAndClear_Test >); void MonitoredDuration_addSampleAndClear_Test::TestBody () { |
413 | MonitoredDurationPtr mond; |
414 | Duration interval_duration(milliseconds(50)); |
415 | |
416 | // Create valid v4 duration with interval duration of 50ms. |
417 | ASSERT_NO_THROW_LOG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 419, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 419, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } } |
418 | "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 419, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 419, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } } |
419 | SUBNET_ID_GLOBAL, interval_duration))){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 419, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 419, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } }; |
420 | ASSERT_TRUE(mond)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(mond)) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 420, ::testing::internal ::GetBoolAssertionFailureMessage( gtest_ar_, "mond", "false", "true").c_str()) = ::testing::Message(); |
421 | |
422 | // Initially there are no intervals. |
423 | EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 423, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getCurrentInterval()", "true", "false").c_str()) = ::testing::Message(); |
424 | EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 424, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getPreviousInterval()", "true", "false").c_str()) = ::testing::Message(); |
425 | |
426 | auto two_ms = milliseconds(2); |
427 | bool should_report = false; |
428 | |
429 | // Add a sample and verify nothing to report and that it creates a |
430 | // current interval. |
431 | ASSERT_NO_THROW(should_report = mond->addSample(two_ms))switch (0) case 0: default: if (::testing::internal::AlwaysTrue ()) { try { if (::testing::internal::AlwaysTrue()) { should_report = mond->addSample(two_ms); }; } catch (...) { goto gtest_label_testnothrow_431 ; } } else gtest_label_testnothrow_431: return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 431, "Expected: " "should_report = mond->addSample(two_ms)" " doesn't throw an exception.\n" " Actual: it throws.") = :: testing::Message(); |
432 | EXPECT_FALSE(should_report)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(should_report))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 432, ::testing ::internal::GetBoolAssertionFailureMessage( gtest_ar_, "should_report" , "true", "false").c_str()) = ::testing::Message(); |
433 | DurationDataIntervalPtr current_interval = mond->getCurrentInterval(); |
434 | ASSERT_TRUE(current_interval)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(current_interval)) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 434, ::testing ::internal::GetBoolAssertionFailureMessage( gtest_ar_, "current_interval" , "false", "true").c_str()) = ::testing::Message(); |
435 | |
436 | // First pass, we should only have a current interval, |
437 | // nothing to report, one occurrence and a total duration of 10ms. |
438 | EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 438, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getPreviousInterval()", "true", "false").c_str()) = ::testing::Message(); |
439 | EXPECT_FALSE(should_report)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(should_report))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 439, ::testing ::internal::GetBoolAssertionFailureMessage( gtest_ar_, "should_report" , "true", "false").c_str()) = ::testing::Message(); |
440 | EXPECT_EQ(current_interval->getOccurrences(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getOccurrences()" , "1", current_interval->getOccurrences(), 1))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 440, gtest_ar.failure_message ()) = ::testing::Message(); |
441 | EXPECT_EQ(current_interval->getTotalDuration(), two_ms)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getTotalDuration()" , "two_ms", current_interval->getTotalDuration(), two_ms)) ) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 441, gtest_ar .failure_message()) = ::testing::Message(); |
442 | |
443 | // Save a copy of the current interval pointer. |
444 | DurationDataIntervalPtr original_interval = current_interval; |
445 | |
446 | // Add 4 two ms samples during the current interval. |
447 | DurationDataIntervalPtr previous_interval; |
448 | for (int i = 1; i < 5; ++i) { |
449 | // Add a two ms sample, it should return false as its not |
450 | // time to report. |
451 | ASSERT_NO_THROW(should_report = mond->addSample(two_ms))switch (0) case 0: default: if (::testing::internal::AlwaysTrue ()) { try { if (::testing::internal::AlwaysTrue()) { should_report = mond->addSample(two_ms); }; } catch (...) { goto gtest_label_testnothrow_451 ; } } else gtest_label_testnothrow_451: return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 451, "Expected: " "should_report = mond->addSample(two_ms)" " doesn't throw an exception.\n" " Actual: it throws.") = :: testing::Message(); |
452 | EXPECT_FALSE(should_report)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(should_report))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 452, ::testing ::internal::GetBoolAssertionFailureMessage( gtest_ar_, "should_report" , "true", "false").c_str()) = ::testing::Message(); |
453 | current_interval = mond->getCurrentInterval(); |
454 | ASSERT_TRUE(current_interval)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(current_interval)) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 454, ::testing ::internal::GetBoolAssertionFailureMessage( gtest_ar_, "current_interval" , "false", "true").c_str()) = ::testing::Message(); |
455 | |
456 | // Make sure the current interval hasn't been replaced and we |
457 | // have no previous interval. |
458 | EXPECT_EQ(current_interval, original_interval)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("current_interval" , "original_interval", current_interval, original_interval))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 458, gtest_ar .failure_message()) = ::testing::Message(); |
459 | EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 459, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getPreviousInterval()", "true", "false").c_str()) = ::testing::Message(); |
460 | // Verify the sample was added. |
461 | EXPECT_EQ(current_interval->getOccurrences(), (i + 1))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getOccurrences()" , "(i + 1)", current_interval->getOccurrences(), (i + 1))) ) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 461, gtest_ar .failure_message()) = ::testing::Message(); |
462 | EXPECT_EQ(current_interval->getTotalDuration(), (two_ms * (i + 1)))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getTotalDuration()" , "(two_ms * (i + 1))", current_interval->getTotalDuration (), (two_ms * (i + 1))))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 462, gtest_ar.failure_message()) = ::testing::Message(); |
463 | } |
464 | |
465 | // Sleep til past the end of interval |
466 | usleep(60 * 1000); |
467 | |
468 | // Add another sample. |
469 | ASSERT_NO_THROW(should_report = mond->addSample(two_ms))switch (0) case 0: default: if (::testing::internal::AlwaysTrue ()) { try { if (::testing::internal::AlwaysTrue()) { should_report = mond->addSample(two_ms); }; } catch (...) { goto gtest_label_testnothrow_469 ; } } else gtest_label_testnothrow_469: return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 469, "Expected: " "should_report = mond->addSample(two_ms)" " doesn't throw an exception.\n" " Actual: it throws.") = :: testing::Message(); |
470 | current_interval = mond->getCurrentInterval(); |
471 | ASSERT_TRUE(current_interval)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(current_interval)) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 471, ::testing ::internal::GetBoolAssertionFailureMessage( gtest_ar_, "current_interval" , "false", "true").c_str()) = ::testing::Message(); |
472 | |
473 | // We should have crossed the interval boundary. |
474 | // Previous interval should be equal to the original interval and |
475 | // should_report should be true. The new current interval should |
476 | // have 1 occurrence and a total of 10ms. |
477 | previous_interval = mond->getPreviousInterval(); |
478 | EXPECT_TRUE(previous_interval)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(previous_interval)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 478, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "previous_interval", "false", "true").c_str()) = ::testing:: Message(); |
479 | EXPECT_EQ(previous_interval, original_interval)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("previous_interval" , "original_interval", previous_interval, original_interval)) ) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 479, gtest_ar .failure_message()) = ::testing::Message(); |
480 | EXPECT_TRUE(should_report)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(should_report)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "monitored_duration_unittests.cc", 480, ::testing ::internal::GetBoolAssertionFailureMessage( gtest_ar_, "should_report" , "false", "true").c_str()) = ::testing::Message(); |
481 | EXPECT_EQ(current_interval->getOccurrences(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getOccurrences()" , "1", current_interval->getOccurrences(), 1))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 481, gtest_ar.failure_message ()) = ::testing::Message(); |
482 | EXPECT_EQ(current_interval->getTotalDuration(), two_ms)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getTotalDuration()" , "two_ms", current_interval->getTotalDuration(), two_ms)) ) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 482, gtest_ar .failure_message()) = ::testing::Message(); |
483 | |
484 | // Verify that clear wipes the intervals. |
485 | ASSERT_NO_THROW_LOG(mond->clear()){ try { mond->clear(); } catch (const std::exception& ex ) { return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 485, "Failed" ) = ::testing::Message() << "mond->clear()" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 485, "Failed") = ::testing::Message() << "mond->clear()" << " threw non-std::exception"; } }; |
486 | EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 486, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getCurrentInterval()", "true", "false").c_str()) = ::testing::Message(); |
487 | EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 487, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getPreviousInterval()", "true", "false").c_str()) = ::testing::Message(); |
488 | } |
489 | |
490 | TEST(MonitoredDuration, expireInterval)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("expireInterval") > 1, "test_name must not be empty" ); class MonitoredDuration_expireInterval_Test : public ::testing ::Test { public: MonitoredDuration_expireInterval_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); MonitoredDuration_expireInterval_Test (MonitoredDuration_expireInterval_Test const &) = delete; void operator=(MonitoredDuration_expireInterval_Test const & ) = delete; }; ::testing::TestInfo* const MonitoredDuration_expireInterval_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration" , "expireInterval", nullptr, nullptr, ::testing::internal::CodeLocation ("monitored_duration_unittests.cc", 490), (::testing::internal ::GetTestTypeId()), ::testing::internal::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite("monitored_duration_unittests.cc" , 490), ::testing::internal::SuiteApiResolver< ::testing:: Test>::GetTearDownCaseOrSuite("monitored_duration_unittests.cc" , 490), new ::testing::internal::TestFactoryImpl<MonitoredDuration_expireInterval_Test >); void MonitoredDuration_expireInterval_Test::TestBody() { |
491 | MonitoredDurationPtr mond; |
492 | Duration interval_duration(milliseconds(50)); |
493 | auto start_time = PktEvent::now(); |
Value stored to 'start_time' during its initialization is never read | |
494 | auto ten_ms = milliseconds(10); |
495 | |
496 | // Create valid v4 duration with interval duration of 50ms. |
497 | ASSERT_NO_THROW_LOG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 499, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 499, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } } |
498 | "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 499, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 499, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } } |
499 | SUBNET_ID_GLOBAL, interval_duration))){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER , "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration )); } catch (const std::exception& ex) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 499, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 499, "Failed") = ::testing ::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))" << " threw non-std::exception"; } }; |
500 | ASSERT_TRUE(mond)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(mond)) ; else return :: testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 500, ::testing::internal ::GetBoolAssertionFailureMessage( gtest_ar_, "mond", "false", "true").c_str()) = ::testing::Message(); |
501 | |
502 | // Initially there are no intervals. |
503 | EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 503, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getCurrentInterval()", "true", "false").c_str()) = ::testing::Message(); |
504 | EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 504, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getPreviousInterval()", "true", "false").c_str()) = ::testing::Message(); |
505 | EXPECT_EQ(mond->getCurrentIntervalStart(), PktEvent::MIN_TIME())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getCurrentIntervalStart()" , "PktEvent::MIN_TIME()", mond->getCurrentIntervalStart(), PktEvent::MIN_TIME()))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 505, gtest_ar.failure_message()) = ::testing::Message(); |
506 | |
507 | ASSERT_THROW_MSG(mond->expireCurrentInterval(), InvalidOperation,{ try { mond->expireCurrentInterval(); return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 509, "Failed") = ::testing::Message() << "no exception, expected: " << "InvalidOperation"; } catch (const InvalidOperation & ex) { switch (0) case 0: default: if (const ::testing:: AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare ("std::string(ex.what())", "\"MonitoredDuration::expireInterval - no current interval for:\" \" DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\"" , std::string(ex.what()), "MonitoredDuration::expireInterval - no current interval for:" " DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 509, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 509, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "InvalidOperation"; } } |
508 | "MonitoredDuration::expireInterval - no current interval for:"{ try { mond->expireCurrentInterval(); return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 509, "Failed") = ::testing::Message() << "no exception, expected: " << "InvalidOperation"; } catch (const InvalidOperation & ex) { switch (0) case 0: default: if (const ::testing:: AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare ("std::string(ex.what())", "\"MonitoredDuration::expireInterval - no current interval for:\" \" DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\"" , std::string(ex.what()), "MonitoredDuration::expireInterval - no current interval for:" " DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 509, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 509, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "InvalidOperation"; } } |
509 | " DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0"){ try { mond->expireCurrentInterval(); return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 509, "Failed") = ::testing::Message() << "no exception, expected: " << "InvalidOperation"; } catch (const InvalidOperation & ex) { switch (0) case 0: default: if (const ::testing:: AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare ("std::string(ex.what())", "\"MonitoredDuration::expireInterval - no current interval for:\" \" DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\"" , std::string(ex.what()), "MonitoredDuration::expireInterval - no current interval for:" " DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0" ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 509, gtest_ar.failure_message()) = ::testing::Message(); } catch (...) { return ::testing::internal::AssertHelper(::testing:: TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 509, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: " << "InvalidOperation"; } }; |
510 | |
511 | ASSERT_NO_THROW(mond->addSample(ten_ms))switch (0) case 0: default: if (::testing::internal::AlwaysTrue ()) { try { if (::testing::internal::AlwaysTrue()) { mond-> addSample(ten_ms); }; } catch (...) { goto gtest_label_testnothrow_511 ; } } else gtest_label_testnothrow_511: return ::testing::internal ::AssertHelper(::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 511, "Expected: " "mond->addSample(ten_ms)" " doesn't throw an exception.\n" " Actual: it throws.") = ::testing::Message(); |
512 | auto current_interval = mond->getCurrentInterval(); |
513 | ASSERT_TRUE(current_interval)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(current_interval)) ; else return ::testing::internal::AssertHelper(::testing::TestPartResult ::kFatalFailure, "monitored_duration_unittests.cc", 513, ::testing ::internal::GetBoolAssertionFailureMessage( gtest_ar_, "current_interval" , "false", "true").c_str()) = ::testing::Message(); |
514 | EXPECT_EQ(current_interval->getOccurrences(), 1)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getOccurrences()" , "1", current_interval->getOccurrences(), 1))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 514, gtest_ar.failure_message ()) = ::testing::Message(); |
515 | EXPECT_EQ(current_interval->getTotalDuration(), ten_ms)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getTotalDuration()" , "ten_ms", current_interval->getTotalDuration(), ten_ms)) ) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 515, gtest_ar .failure_message()) = ::testing::Message(); |
516 | EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 516, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getPreviousInterval()", "true", "false").c_str()) = ::testing::Message(); |
517 | EXPECT_GE(mond->getCurrentIntervalStart(), start_time)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::CmpHelperGE("mond->getCurrentIntervalStart()" , "start_time", mond->getCurrentIntervalStart(), start_time ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 517, gtest_ar .failure_message()) = ::testing::Message(); |
518 | EXPECT_EQ(mond->getCurrentIntervalStart(), current_interval->getStartTime())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getCurrentIntervalStart()" , "current_interval->getStartTime()", mond->getCurrentIntervalStart (), current_interval->getStartTime()))) ; else ::testing:: internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "monitored_duration_unittests.cc", 518, gtest_ar.failure_message ()) = ::testing::Message(); |
519 | |
520 | ASSERT_NO_THROW_LOG(mond->expireCurrentInterval()){ try { mond->expireCurrentInterval(); } catch (const std:: exception& ex) { return ::testing::internal::AssertHelper (::testing::TestPartResult::kFatalFailure, "monitored_duration_unittests.cc" , 520, "Failed") = ::testing::Message() << "mond->expireCurrentInterval()" << " threw type: " << typeid(ex).name() << ", what: " << ex.what(); } catch (...) { return ::testing ::internal::AssertHelper(::testing::TestPartResult::kFatalFailure , "monitored_duration_unittests.cc", 520, "Failed") = ::testing ::Message() << "mond->expireCurrentInterval()" << " threw non-std::exception"; } }; |
521 | EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 521, :: testing::internal::GetBoolAssertionFailureMessage( gtest_ar_, "mond->getCurrentInterval()", "true", "false").c_str()) = ::testing::Message(); |
522 | |
523 | auto previous_interval = mond->getPreviousInterval(); |
524 | EXPECT_EQ(previous_interval, current_interval)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("previous_interval" , "current_interval", previous_interval, current_interval))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "monitored_duration_unittests.cc", 524, gtest_ar .failure_message()) = ::testing::Message(); |
525 | EXPECT_EQ(mond->getCurrentIntervalStart(), PktEvent::MIN_TIME())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare("mond->getCurrentIntervalStart()" , "PktEvent::MIN_TIME()", mond->getCurrentIntervalStart(), PktEvent::MIN_TIME()))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "monitored_duration_unittests.cc" , 525, gtest_ar.failure_message()) = ::testing::Message(); |
526 | } |
527 | |
528 | } // end of anonymous namespace |