cache_test_sectioncount.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 <vector>
  16. #include <dns/tests/unittest_util.h>
  17. #include <dns/buffer.h>
  18. #include <dns/message.h>
  19. using namespace isc;
  20. using namespace isc::dns;
  21. namespace {
  22. /// \brief Counts the number of rrsets in the given section
  23. ///
  24. /// \param msg The message to count in
  25. /// \param section The section to count
  26. ///
  27. /// \return The number of RRsets in the given section
  28. int
  29. sectionRRsetCount(Message& msg, Message::Section section) {
  30. int count = 0;
  31. for (RRsetIterator rrset_iter = msg.beginSection(section);
  32. rrset_iter != msg.endSection(section);
  33. ++rrset_iter) {
  34. ++count;
  35. }
  36. return count;
  37. }
  38. } // namespace