rrset_entry_unittest.cc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 <config.h>
  16. #include <string>
  17. #include <gtest/gtest.h>
  18. #include "../cache_entry_key.h"
  19. using namespace isc::cache;
  20. using namespace isc::dns;
  21. using namespace std;
  22. namespace {
  23. class GenCacheKeyTest: public testing::Test {
  24. };
  25. TEST_F(GenCacheKeyTest, genCacheEntryKey1) {
  26. string name = "example.com.";
  27. uint16_t type = 12;
  28. string name_type = "example.com.12";
  29. pair<const char*, const int32_t> key = genCacheEntryKey(name, type);
  30. EXPECT_EQ(name_type, string(key.first));
  31. EXPECT_EQ(name_type.length(), key.second);
  32. }
  33. TEST_F(GenCacheKeyTest, genCacheEntryKey2) {
  34. Name name("example.com");
  35. RRType type(1234);
  36. string keystr = "example.com.1234";
  37. pair<const char*, const int32_t> key = genCacheEntryKey(name, type);
  38. EXPECT_EQ(keystr, string(key.first));
  39. EXPECT_EQ(keystr.length(), key.second);
  40. }
  41. } // namespace