LCOV - code coverage report
Current view: top level - dns - serial.cc (source / functions) Hit Total Coverage
Test: report.info Lines: 24 26 92.3 %
Date: 2012-05-15 Functions: 9 10 90.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 12 83.3 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (C) 2011  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 <dns/serial.h>
      16                 :            : 
      17                 :            : namespace isc {
      18                 :            : namespace dns {
      19                 :            : 
      20                 :            : bool
      21                 :        152 : Serial::operator==(const Serial& other) const {
      22                 :        152 :     return (value_ == other.getValue());
      23                 :            : }
      24                 :            : 
      25                 :            : bool
      26                 :        607 : Serial::operator!=(const Serial& other) const {
      27                 :        607 :     return (value_ != other.getValue());
      28                 :            : }
      29                 :            : 
      30                 :            : bool
      31                 :        129 : Serial::operator<(const Serial& other) const {
      32                 :        129 :     uint32_t other_val = other.getValue();
      33                 :        129 :     bool result = false;
      34         [ +  + ]:        129 :     if (value_ < other_val) {
      35                 :         36 :         result = ((other_val - value_) <= MAX_SERIAL_INCREMENT);
      36         [ +  + ]:         93 :     } else if (other_val < value_) {
      37                 :         78 :         result = ((value_ - other_val) > MAX_SERIAL_INCREMENT);
      38                 :            :     }
      39                 :        129 :     return (result);
      40                 :            : }
      41                 :            : 
      42                 :            : bool
      43                 :         27 : Serial::operator<=(const Serial& other) const {
      44 [ +  + ][ +  + ]:         27 :     return (operator==(other) || operator<(other));
      45                 :            : }
      46                 :            : 
      47                 :            : bool
      48                 :         67 : Serial::operator>(const Serial& other) const {
      49 [ +  - ][ -  + ]:         67 :     return (!operator==(other) && !operator<(other));
      50                 :            : }
      51                 :            : 
      52                 :            : bool
      53                 :         32 : Serial::operator>=(const Serial& other) const {
      54                 :         32 :     return (!operator<(other));
      55                 :            : }
      56                 :            : 
      57                 :            : Serial
      58                 :        674 : Serial::operator+(uint32_t other_val) const {
      59                 :            :     uint64_t new_val = static_cast<uint64_t>(value_) +
      60                 :        674 :                        static_cast<uint64_t>(other_val);
      61                 :        674 :     return Serial(static_cast<uint32_t>(new_val % MAX_SERIAL_VALUE));
      62                 :            : }
      63                 :            : 
      64                 :            : Serial
      65                 :         14 : Serial::operator+(const Serial& other) const {
      66                 :         14 :     return (operator+(other.getValue()));
      67                 :            : }
      68                 :            : 
      69                 :            : std::ostream&
      70                 :          0 : operator<<(std::ostream& os, const Serial& serial) {
      71                 :          0 :     return (os << serial.getValue());
      72                 :            : }
      73                 :            : 
      74                 :            : } // end namespace dns
      75                 :        137 : } // end namespace isc
      76                 :            : 

Generated by: LCOV version 1.9