LCOV - code coverage report
Current view: top level - src - range.cpp (source / functions) Hit Total Coverage
Test: qucs-core-0.0.19 Code Coverage Lines: 0 43 0.0 %
Date: 2015-01-05 16:01:02 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 32 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * range.cpp - range class implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 2006 Stefan Jahn <stefan@lkcc.org>
       5                 :            :  *
       6                 :            :  * This is free software; you can redistribute it and/or modify
       7                 :            :  * it under the terms of the GNU General Public License as published by
       8                 :            :  * the Free Software Foundation; either version 2, or (at your option)
       9                 :            :  * any later version.
      10                 :            :  *
      11                 :            :  * This software is distributed in the hope that it will be useful,
      12                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            :  * GNU General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with this package; see the file COPYING.  If not, write to
      18                 :            :  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
      19                 :            :  * Boston, MA 02110-1301, USA.
      20                 :            :  *
      21                 :            :  * $Id$
      22                 :            :  *
      23                 :            :  */
      24                 :            : 
      25                 :            : #if HAVE_CONFIG_H
      26                 :            : # include <config.h>
      27                 :            : #endif
      28                 :            : 
      29                 :            : #include <stdio.h>
      30                 :            : #include <stdlib.h>
      31                 :            : #include <string.h>
      32                 :            : 
      33                 :            : #include "range.h"
      34                 :            : 
      35                 :            : namespace qucs {
      36                 :            : 
      37                 :            : // Constructor creates an instance of the range class.
      38                 :          0 : range::range () {
      39                 :          0 :   il = ih = '.';
      40                 :          0 :   l = h = 0.0;
      41                 :          0 :   txt = NULL;
      42                 :          0 : }
      43                 :            : 
      44                 :            : // Constructor creates an fully qualified instance of the range class.
      45                 :          0 : range::range (char ilo, nr_double_t lo, nr_double_t hi, char ihi) {
      46                 :          0 :   il = ilo;
      47                 :          0 :   ih = ihi;
      48 [ #  # ][ #  # ]:          0 :   if (lo > hi) {
      49                 :          0 :     h = lo;
      50                 :          0 :     l = hi;
      51                 :            :   } else {
      52                 :          0 :     l = lo;
      53                 :          0 :     h = hi;
      54                 :            :   }
      55                 :          0 :   txt = NULL;
      56                 :          0 : }
      57                 :            : 
      58                 :            : /* This copy constructor creates a instance of the range class based
      59                 :            :    on the given range. */
      60                 :          0 : range::range (const range & r) {
      61 [ #  # ][ #  # ]:          0 :   txt = r.txt ? strdup (r.txt) : NULL;
      62                 :          0 :   il = r.il;
      63                 :          0 :   ih = r.ih;
      64                 :          0 :   l = r.l;
      65                 :          0 :   h = r.h;
      66                 :          0 : }
      67                 :            : 
      68                 :            : /* Checks whether the given value is outside the range. */
      69                 :          0 : bool range::outside (nr_double_t value) {
      70                 :          0 :   return !inside (value);
      71                 :            : }
      72                 :            : 
      73                 :            : /* Checks whether the given value is inside the range. */
      74                 :          0 : bool range::inside (nr_double_t value) {
      75                 :          0 :   int err = 0;
      76 [ #  # ][ #  # ]:          0 :   if (il == '[' &&  (value < l))
      77                 :          0 :     err++;
      78 [ #  # ][ #  # ]:          0 :   if (il == ']' && !(value > l))
      79                 :          0 :     err++;
      80 [ #  # ][ #  # ]:          0 :   if (ih == '[' && !(value < h))
      81                 :          0 :     err++;
      82 [ #  # ][ #  # ]:          0 :   if (ih == ']' &&  (value > h))
      83                 :          0 :     err++;
      84                 :          0 :   return err == 0;
      85                 :            : }
      86                 :            : 
      87                 :            : // Destructor deletes an instance of the range class.
      88                 :          0 : range::~range () {
      89 [ #  # ][ #  # ]:          0 :   if (txt) free (txt);
      90                 :          0 : }
      91                 :            : 
      92                 :            : /* Returns a text representation of the range object. */
      93                 :          0 : char * range::toString (void) {
      94                 :            :   char str[64];
      95                 :          0 :   sprintf (str, "%c%g,%g%c", il, l, h, ih);
      96         [ #  # ]:          0 :   if (txt) free (txt);
      97         [ #  # ]:          0 :   txt = strdup (str);
      98                 :          0 :   return txt;
      99                 :            : }
     100                 :            : 
     101                 :            : } // namespace qucs

Generated by: LCOV version 1.11