test_utils.cc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include "test_utils.h"
  15. #include <gtest/gtest.h>
  16. namespace isc {
  17. namespace dhcp {
  18. namespace test {
  19. void
  20. detailCompareLease(const Lease4Ptr& first, const Lease4Ptr& second) {
  21. // Compare address strings. Comparison of address objects is not used, as
  22. // odd things happen when they are different: the EXPECT_EQ macro appears to
  23. // call the operator uint32_t() function, which causes an exception to be
  24. // thrown for IPv6 addresses.
  25. EXPECT_EQ(first->addr_.toText(), second->addr_.toText());
  26. EXPECT_TRUE(first->hwaddr_ == second->hwaddr_);
  27. EXPECT_TRUE(*first->client_id_ == *second->client_id_);
  28. EXPECT_EQ(first->valid_lft_, second->valid_lft_);
  29. EXPECT_EQ(first->cltt_, second->cltt_);
  30. EXPECT_EQ(first->subnet_id_, second->subnet_id_);
  31. }
  32. void
  33. detailCompareLease(const Lease6Ptr& first, const Lease6Ptr& second) {
  34. EXPECT_EQ(first->type_, second->type_);
  35. // Compare address strings. Comparison of address objects is not used, as
  36. // odd things happen when they are different: the EXPECT_EQ macro appears to
  37. // call the operator uint32_t() function, which causes an exception to be
  38. // thrown for IPv6 addresses.
  39. EXPECT_EQ(first->addr_.toText(), second->addr_.toText());
  40. EXPECT_EQ(first->prefixlen_, second->prefixlen_);
  41. EXPECT_EQ(first->iaid_, second->iaid_);
  42. ASSERT_TRUE(first->duid_);
  43. ASSERT_TRUE(second->duid_);
  44. EXPECT_TRUE(*first->duid_ == *second->duid_);
  45. EXPECT_EQ(first->preferred_lft_, second->preferred_lft_);
  46. EXPECT_EQ(first->valid_lft_, second->valid_lft_);
  47. EXPECT_EQ(first->cltt_, second->cltt_);
  48. EXPECT_EQ(first->subnet_id_, second->subnet_id_);
  49. }
  50. };
  51. };
  52. };