LCOV - code coverage report
Current view: top level - dns - rrsetlist.cc (source / functions) Hit Total Coverage
Test: report.info Lines: 16 16 100.0 %
Date: 2012-05-15 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 34 48 70.8 %

           Branch data     Line data    Source code
       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                 :            : 
      15                 :            : #include <vector>
      16                 :            : 
      17                 :            : #include <boost/foreach.hpp>
      18                 :            : 
      19                 :            : #include <exceptions/exceptions.h>
      20                 :            : 
      21                 :            : #include <dns/rrclass.h>
      22                 :            : #include <dns/rrtype.h>
      23                 :            : #include <dns/rrset.h>
      24                 :            : #include <dns/rrsetlist.h>
      25                 :            : 
      26                 :            : namespace isc {
      27                 :            : namespace dns {
      28                 :            : 
      29                 :            : void
      30                 :        351 : RRsetList::addRRset(RRsetPtr rrsetptr) {
      31                 :        351 :     ConstRRsetPtr rrset_found = findRRset(rrsetptr->getType(),
      32                 :        702 :                                           rrsetptr->getClass());
      33         [ +  + ]:        351 :     if (rrset_found != NULL) {
      34 [ +  - ][ +  - ]:          4 :         isc_throw(DuplicateRRset, "RRset is being doubly added to RRsetList: "
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      35                 :            :                   "type=" << rrsetptr->getType() << ", class=" <<
      36                 :            :                   rrsetptr->getClass());
      37                 :            :     }
      38                 :        349 :     rrsets_.push_back(rrsetptr);
      39                 :        349 : }
      40                 :            : 
      41                 :            : void
      42                 :         27 : RRsetList::append(RRsetList& source) {
      43   [ +  +  +  - ]:        132 :     BOOST_FOREACH(RRsetPtr rrset, source) {
         [ +  - ][ +  + ]
                 [ +  + ]
      44         [ +  + ]:         27 :         addRRset(rrset);
      45                 :            :     }
      46                 :         26 : }
      47                 :            : 
      48                 :            : RRsetPtr
      49                 :        827 : RRsetList::findRRset(const RRType& rrtype, const RRClass& rrclass) {
      50   [ +  +  +  - ]:       2436 :     BOOST_FOREACH(RRsetPtr rrsetptr, rrsets_) {
         [ +  - ][ +  + ]
                 [ +  + ]
      51 [ +  - ][ +  - ]:       1160 :         if ((rrsetptr->getClass() == rrclass) &&
         [ +  + ][ +  + ]
      52         [ +  - ]:        580 :             (rrsetptr->getType() == rrtype)) {
      53                 :            :             return (rrsetptr);
      54                 :            :         }
      55                 :            :     }
      56                 :            :     return (RRsetPtr());
      57                 :            : }
      58                 :            : 
      59                 :            : }
      60                 :        137 : }

Generated by: LCOV version 1.9