nsas_entry_compare_unittest.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (C) 2010 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. // $Id$
  15. #include <algorithm>
  16. #include <string>
  17. #include <vector>
  18. #include <gtest/gtest.h>
  19. #include <boost/lexical_cast.hpp>
  20. #include "../hash_key.h"
  21. #include "../nsas_entry_compare.h"
  22. #include "nsas_test.h"
  23. using namespace std;
  24. namespace isc {
  25. namespace nsas {
  26. /// \brief Test Fixture Class
  27. class NsasEntryCompareTest : public ::testing::Test {
  28. };
  29. // Test of the comparison
  30. TEST_F(NsasEntryCompareTest, Compare) {
  31. // Construct a couple of different objects
  32. TestEntry entry1("test1", 42);
  33. TestEntry entry2("test1", 24);
  34. TestEntry entry3("test2", 42);
  35. // Create corresponding hash key objects
  36. HashKey key1(entry1.getName(), entry1.getClass());
  37. HashKey key2(entry2.getName(), entry2.getClass());
  38. HashKey key3(entry3.getName(), entry3.getClass());
  39. // Perform the comparison
  40. NsasEntryCompare<TestEntry> compare;
  41. EXPECT_TRUE(compare(&entry1, key1));
  42. EXPECT_FALSE(compare(&entry1, key2));
  43. }
  44. } // namespace nsas
  45. } // namespace isc