LCOV - code coverage report
Current view: top level - tests - internaltest.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 259 270 95.9 %
Date: 2019-06-30 05:20:33 Functions: 16 16 100.0 %
Branches: 235 2684 8.8 %

           Branch data     Line data    Source code
       1                 :            : /** @file internaltest.cc
       2                 :            :  * @brief test of the Xapian internals
       3                 :            :  */
       4                 :            : /* Copyright 1999,2000,2001 BrightStation PLC
       5                 :            :  * Copyright 2002 Ananova Ltd
       6                 :            :  * Copyright 2002,2003,2006,2007,2008,2009,2010,2011,2012,2015 Olly Betts
       7                 :            :  * Copyright 2006 Lemur Consulting Ltd
       8                 :            :  *
       9                 :            :  * This program is free software; you can redistribute it and/or
      10                 :            :  * modify it under the terms of the GNU General Public License as
      11                 :            :  * published by the Free Software Foundation; either version 2 of the
      12                 :            :  * License, or (at your option) any later version.
      13                 :            :  *
      14                 :            :  * This program is distributed in the hope that it will be useful,
      15                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17                 :            :  * GNU General Public License for more details.
      18                 :            :  *
      19                 :            :  * You should have received a copy of the GNU General Public License
      20                 :            :  * along with this program; if not, write to the Free Software
      21                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      22                 :            :  * USA
      23                 :            :  */
      24                 :            : 
      25                 :            : #include <config.h>
      26                 :            : 
      27                 :            : #include <xapian.h>
      28                 :            : 
      29                 :            : #include <iostream>
      30                 :            : #include <string>
      31                 :            : 
      32                 :            : using namespace std;
      33                 :            : 
      34                 :            : #include "testsuite.h"
      35                 :            : #include "testutils.h"
      36                 :            : 
      37                 :            : #include "pack.h"
      38                 :            : #include "str.h"
      39                 :            : 
      40                 :            : class Test_Exception {
      41                 :            :   public:
      42                 :            :     int value;
      43                 :          2 :     Test_Exception(int value_) : value(value_) {}
      44                 :            : };
      45                 :            : 
      46                 :            : // test that nested exceptions work correctly.
      47                 :          1 : static bool test_exception1()
      48                 :            : {
      49                 :            :     try {
      50                 :            :         try {
      51                 :          3 :             throw Test_Exception(1);
      52                 :          2 :         } catch (...) {
      53                 :            :             try {
      54                 :          1 :                 throw Test_Exception(2);
      55         [ -  + ]:          1 :             } catch (...) {
      56                 :            :             }
      57                 :          1 :             throw;
      58                 :            :         }
      59         [ -  + ]:          1 :     } catch (const Test_Exception & e) {
      60   [ -  +  #  #  :          1 :         TEST_EQUAL(e.value, 1);
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                #  #  # ]
      61                 :          1 :         return true;
      62                 :            :     }
      63                 :            :     return false;
      64                 :            : }
      65                 :            : 
      66                 :            : // ###########################################
      67                 :            : // # Tests of the reference counted pointers #
      68                 :            : // ###########################################
      69                 :            : 
      70                 :            : class test_refcnt : public Xapian::Internal::intrusive_base {
      71                 :            :     bool &deleted;
      72                 :            : 
      73                 :            :   public:
      74                 :          4 :     test_refcnt(bool &deleted_) : deleted(deleted_) {
      75                 :          2 :         tout << "constructor\n";
      76                 :          2 :     }
      77                 :            : 
      78                 :            :     Xapian::Internal::intrusive_ptr<const test_refcnt> test() {
      79                 :            :         return Xapian::Internal::intrusive_ptr<const test_refcnt>(this);
      80                 :            :     }
      81                 :            : 
      82                 :          2 :     ~test_refcnt() {
      83                 :          2 :         deleted = true;
      84                 :          2 :         tout << "destructor\n";
      85                 :          2 :     }
      86                 :            : };
      87                 :            : 
      88                 :          1 : static bool test_refcnt1()
      89                 :            : {
      90                 :          1 :     bool deleted = false;
      91                 :            : 
      92 [ +  - ][ +  - ]:          1 :     test_refcnt *p = new test_refcnt(deleted);
      93                 :            : 
      94 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(p->_refs, 0);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      95                 :            : 
      96                 :            :     {
      97                 :          1 :         Xapian::Internal::intrusive_ptr<test_refcnt> rcp(p);
      98                 :            : 
      99 [ -  + ][ #  # ]:          1 :         TEST_EQUAL(rcp->_refs, 1);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     100                 :            : 
     101                 :            :         {
     102                 :          1 :             Xapian::Internal::intrusive_ptr<test_refcnt> rcp2;
     103         [ +  - ]:          1 :             rcp2 = rcp;
     104 [ -  + ][ #  # ]:          1 :             TEST_EQUAL(rcp->_refs, 2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     105                 :            :             // rcp2 goes out of scope here
     106                 :            :         }
     107                 :            : 
     108 [ -  + ][ #  # ]:          1 :         TEST_AND_EXPLAIN(!deleted, "Object prematurely deleted!");
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     109 [ -  + ][ #  # ]:          1 :         TEST_EQUAL(rcp->_refs, 1);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     110                 :            :         // rcp goes out of scope here
     111                 :            :     }
     112                 :            : 
     113 [ -  + ][ #  # ]:          1 :     TEST_AND_EXPLAIN(deleted, "Object not properly deleted");
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     114                 :            : 
     115                 :          1 :     return true;
     116                 :            : }
     117                 :            : 
     118                 :            : // This is a regression test - our home-made equivalent of intrusive_ptr
     119                 :            : // (which was called RefCntPtr) used to delete the object pointed to if you
     120                 :            : // assigned it to itself and the reference count was 1.
     121                 :          1 : static bool test_refcnt2()
     122                 :            : {
     123                 :          1 :     bool deleted = false;
     124                 :            : 
     125 [ +  - ][ +  - ]:          1 :     test_refcnt *p = new test_refcnt(deleted);
     126                 :            : 
     127                 :          1 :     Xapian::Internal::intrusive_ptr<test_refcnt> rcp(p);
     128                 :            : 
     129                 :            : #ifdef __has_warning
     130                 :            : # if __has_warning("-Wself-assign-overloaded")
     131                 :            :     // Suppress warning from newer clang about self-assignment so we can
     132                 :            :     // test that self-assignment works!
     133                 :            : #  pragma clang diagnostic push
     134                 :            : #  pragma clang diagnostic ignored "-Wself-assign-overloaded"
     135                 :            : # endif
     136                 :            : #endif
     137         [ +  - ]:          1 :     rcp = rcp;
     138                 :            : #ifdef __has_warning
     139                 :            : # if __has_warning("-Wself-assign-overloaded")
     140                 :            : #  pragma clang diagnostic pop
     141                 :            : # endif
     142                 :            : #endif
     143                 :            : 
     144 [ -  + ][ #  # ]:          1 :     TEST_AND_EXPLAIN(!deleted, "Object deleted by self-assignment");
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     145                 :            : 
     146                 :          1 :     return true;
     147                 :            : }
     148                 :            : 
     149                 :            : // test string comparisons
     150                 :          1 : static bool test_stringcomp1()
     151                 :            : {
     152                 :          1 :     bool success = true;
     153                 :            : 
     154         [ +  - ]:          1 :     string s1;
     155         [ +  - ]:          2 :     string s2;
     156                 :            : 
     157         [ +  - ]:          1 :     s1 = "foo";
     158         [ +  - ]:          1 :     s2 = "foo";
     159                 :            : 
     160 [ +  - ][ +  - ]:          1 :     if ((s1 != s2) || (s1 > s2)) {
         [ +  - ][ -  + ]
                 [ -  + ]
     161                 :          0 :         success = false;
     162 [ #  # ][ #  # ]:          0 :         tout << "String comparisons BADLY wrong" << endl;
     163                 :            :     }
     164                 :            : 
     165         [ +  - ]:          1 :     s1 += '\0';
     166                 :            : 
     167 [ +  - ][ +  - ]:          1 :     if ((s1 == s2) || (s1 < s2)) {
         [ -  + ][ -  + ]
     168                 :          0 :         success = false;
     169 [ #  # ][ #  # ]:          0 :         tout << "String comparisons don't cope with extra nulls" << endl;
     170                 :            :     }
     171                 :            : 
     172         [ +  - ]:          1 :     s2 += '\0';
     173                 :            : 
     174         [ +  - ]:          1 :     s1 += 'a';
     175         [ +  - ]:          1 :     s2 += 'z';
     176                 :            : 
     177 [ +  - ][ -  + ]:          1 :     if ((s1.length() != 5) || (s2.length() != 5)) {
                 [ -  + ]
     178                 :          0 :         success = false;
     179 [ #  # ][ #  # ]:          0 :         tout << "Lengths with added nulls wrong" << endl;
     180                 :            :     }
     181                 :            : 
     182 [ +  - ][ +  - ]:          1 :     if ((s1 == s2) || !(s1 < s2)) {
         [ -  + ][ -  + ]
     183                 :          0 :         success = false;
     184 [ #  # ][ #  # ]:          0 :         tout << "Characters after a null ignored in comparisons" << endl;
     185                 :            :     }
     186                 :            : 
     187                 :          1 :     return success;
     188                 :            : }
     189                 :            : 
     190                 :            : // By default Sun's C++ compiler doesn't call the destructor on a
     191                 :            : // temporary object until the end of the block (contrary to what
     192                 :            : // ISO C++ requires).  This is done in the name of "compatibility".
     193                 :            : // Passing -features=tmplife to CC fixes this.  This check ensures
     194                 :            : // that this actually works for Sun's C++ and any other compilers
     195                 :            : // that might have this problem.
     196                 :            : struct TempDtorTest {
     197                 :            :     static int count;
     198                 :          2 :     static TempDtorTest factory() { return TempDtorTest(); }
     199                 :          1 :     TempDtorTest() { ++count; }
     200                 :          2 :     ~TempDtorTest() { --count; }
     201                 :            : };
     202                 :            : 
     203                 :            : int TempDtorTest::count = 0;
     204                 :            : 
     205                 :          1 : static bool test_temporarydtor1()
     206                 :            : {
     207 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(TempDtorTest::count, 0);
     208                 :          1 :     TempDtorTest::factory();
     209 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(TempDtorTest::count, 0);
     210                 :            : 
     211                 :          1 :     return true;
     212                 :            : }
     213                 :            : 
     214                 :            : /// Test pack_uint_preserving_sort()
     215                 :          1 : static bool test_pack_uint_preserving_sort1()
     216                 :            : {
     217         [ +  - ]:          1 :     string prev_packed;
     218         [ +  + ]:       1001 :     for (unsigned int i = 0; i != 1000; ++i) {
     219         [ +  - ]:       1000 :         string packed;
     220         [ +  - ]:       1000 :         pack_uint_preserving_sort(packed, i);
     221                 :       1000 :         const char * ptr = packed.data();
     222                 :       1000 :         const char * end = ptr + packed.size();
     223                 :            :         unsigned int result;
     224 [ -  + ][ #  # ]:       1000 :         TEST(unpack_uint_preserving_sort(&ptr, end, &result));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     225 [ -  + ][ #  # ]:       1000 :         TEST_EQUAL(result, i);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     226 [ -  + ][ #  # ]:       1000 :         TEST(ptr == end);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     227 [ +  - ][ -  + ]:       1000 :         TEST_REL(prev_packed, <, packed);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     228         [ +  - ]:       1000 :         swap(prev_packed, packed);
     229                 :       1000 :     }
     230         [ +  + ]:        556 :     for (unsigned int i = 2345; i < 65000; i += 113) {
     231         [ +  - ]:        555 :         string packed;
     232         [ +  - ]:        555 :         pack_uint_preserving_sort(packed, i);
     233                 :        555 :         const char * ptr = packed.data();
     234                 :        555 :         const char * end = ptr + packed.size();
     235                 :            :         unsigned int result;
     236 [ -  + ][ #  # ]:        555 :         TEST(unpack_uint_preserving_sort(&ptr, end, &result));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     237 [ -  + ][ #  # ]:        555 :         TEST_EQUAL(result, i);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     238 [ -  + ][ #  # ]:        555 :         TEST(ptr == end);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     239 [ +  - ][ -  + ]:        555 :         TEST_REL(prev_packed, <, packed);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     240         [ +  - ]:        555 :         swap(prev_packed, packed);
     241                 :        555 :     }
     242                 :          1 :     unsigned int prev = 64999;
     243         [ +  + ]:         18 :     for (unsigned int i = 65000; i > prev; prev = i, i = (i << 1) ^ 1337) {
     244         [ +  - ]:         17 :         string packed;
     245         [ +  - ]:         17 :         pack_uint_preserving_sort(packed, i);
     246                 :         17 :         const char * ptr = packed.data();
     247                 :         17 :         const char * end = ptr + packed.size();
     248                 :            :         unsigned int result;
     249 [ -  + ][ #  # ]:         17 :         TEST(unpack_uint_preserving_sort(&ptr, end, &result));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     250 [ -  + ][ #  # ]:         17 :         TEST_EQUAL(result, i);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     251 [ -  + ][ #  # ]:         17 :         TEST(ptr == end);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     252 [ +  - ][ -  + ]:         17 :         TEST_REL(prev_packed, <, packed);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     253         [ +  - ]:         17 :         swap(prev_packed, packed);
     254                 :         17 :     }
     255                 :            : 
     256                 :            :     /* Test packing multiple numbers to one string. */
     257         [ +  - ]:          2 :     string packed;
     258         [ +  + ]:        658 :     for (unsigned int i = 23456; i < 765432; i += 1131) {
     259         [ +  - ]:        657 :         pack_uint_preserving_sort(packed, i);
     260                 :            :     }
     261                 :          1 :     const char * ptr = packed.data();
     262                 :          1 :     const char * end = ptr + packed.size();
     263         [ +  + ]:        658 :     for (unsigned int i = 23456; i < 765432; i += 1131) {
     264                 :            :         unsigned int result;
     265 [ -  + ][ #  # ]:        657 :         TEST(unpack_uint_preserving_sort(&ptr, end, &result));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     266 [ -  + ][ #  # ]:        657 :         TEST_EQUAL(result, i);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     267                 :            :     }
     268 [ -  + ][ #  # ]:          1 :     TEST(ptr == end);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     269                 :            : 
     270                 :          1 :     return true;
     271                 :            : }
     272                 :            : 
     273                 :            : /// Test C_isupper() etc.
     274                 :          1 : static bool test_chartype1()
     275                 :            : {
     276                 :            :     char tested[128];
     277                 :          1 :     memset(tested, 0, sizeof(tested));
     278         [ +  + ]:         11 :     for (int ch = '0'; ch != '9' + 1; ++ch) {
     279                 :         10 :         tested[ch] = 1;
     280 [ -  + ][ #  # ]:         10 :         TEST(!C_isupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     281 [ -  + ][ #  # ]:         10 :         TEST(!C_islower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     282 [ -  + ][ #  # ]:         10 :         TEST(!C_isalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     283 [ -  + ][ #  # ]:         10 :         TEST(C_isalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     284 [ -  + ][ #  # ]:         10 :         TEST(C_isdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     285 [ -  + ][ #  # ]:         10 :         TEST(C_isxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     286 [ -  + ][ #  # ]:         10 :         TEST(!C_isspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     287 [ -  + ][ #  # ]:         10 :         TEST(C_isnotupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     288 [ -  + ][ #  # ]:         10 :         TEST(C_isnotlower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     289 [ -  + ][ #  # ]:         10 :         TEST(C_isnotalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     290 [ -  + ][ #  # ]:         10 :         TEST(!C_isnotalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     291 [ -  + ][ #  # ]:         10 :         TEST(!C_isnotdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     292 [ -  + ][ #  # ]:         10 :         TEST(!C_isnotxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     293 [ -  + ][ #  # ]:         10 :         TEST(C_isnotspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     294 [ -  + ][ #  # ]:         10 :         TEST_EQUAL(hex_digit(ch), ch - '0');
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     295                 :            :     }
     296                 :            : 
     297         [ +  + ]:          7 :     for (int ch = 'A'; ch != 'F' + 1; ++ch) {
     298                 :          6 :         tested[ch] = 1;
     299 [ -  + ][ #  # ]:          6 :         TEST(C_isupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     300 [ -  + ][ #  # ]:          6 :         TEST(!C_islower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     301 [ -  + ][ #  # ]:          6 :         TEST(C_isalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     302 [ -  + ][ #  # ]:          6 :         TEST(C_isalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     303 [ -  + ][ #  # ]:          6 :         TEST(!C_isdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     304 [ -  + ][ #  # ]:          6 :         TEST(C_isxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     305 [ -  + ][ #  # ]:          6 :         TEST(!C_isspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     306 [ -  + ][ #  # ]:          6 :         TEST(!C_isnotupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     307 [ -  + ][ #  # ]:          6 :         TEST(C_isnotlower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     308 [ -  + ][ #  # ]:          6 :         TEST(!C_isnotalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     309 [ -  + ][ #  # ]:          6 :         TEST(!C_isnotalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     310 [ -  + ][ #  # ]:          6 :         TEST(C_isnotdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     311 [ -  + ][ #  # ]:          6 :         TEST(!C_isnotxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     312 [ -  + ][ #  # ]:          6 :         TEST(C_isnotspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     313 [ -  + ][ #  # ]:          6 :         TEST_EQUAL(hex_digit(ch), ch - 'A' + 10);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     314                 :            :     }
     315                 :            : 
     316         [ +  + ]:         21 :     for (int ch = 'G'; ch != 'Z' + 1; ++ch) {
     317                 :         20 :         tested[ch] = 1;
     318 [ -  + ][ #  # ]:         20 :         TEST(C_isupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     319 [ -  + ][ #  # ]:         20 :         TEST(!C_islower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     320 [ -  + ][ #  # ]:         20 :         TEST(C_isalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     321 [ -  + ][ #  # ]:         20 :         TEST(C_isalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     322 [ -  + ][ #  # ]:         20 :         TEST(!C_isdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     323 [ -  + ][ #  # ]:         20 :         TEST(!C_isxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     324 [ -  + ][ #  # ]:         20 :         TEST(!C_isspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     325 [ -  + ][ #  # ]:         20 :         TEST(!C_isnotupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     326 [ -  + ][ #  # ]:         20 :         TEST(C_isnotlower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     327 [ -  + ][ #  # ]:         20 :         TEST(!C_isnotalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     328 [ -  + ][ #  # ]:         20 :         TEST(!C_isnotalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     329 [ -  + ][ #  # ]:         20 :         TEST(C_isnotdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     330 [ -  + ][ #  # ]:         20 :         TEST(C_isnotxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     331 [ -  + ][ #  # ]:         20 :         TEST(C_isnotspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     332                 :            :     }
     333                 :            : 
     334         [ +  + ]:          7 :     for (int ch = 'a'; ch != 'f' + 1; ++ch) {
     335                 :          6 :         tested[ch] = 1;
     336 [ -  + ][ #  # ]:          6 :         TEST(!C_isupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     337 [ -  + ][ #  # ]:          6 :         TEST(C_islower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     338 [ -  + ][ #  # ]:          6 :         TEST(C_isalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     339 [ -  + ][ #  # ]:          6 :         TEST(C_isalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     340 [ -  + ][ #  # ]:          6 :         TEST(!C_isdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     341 [ -  + ][ #  # ]:          6 :         TEST(C_isxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     342 [ -  + ][ #  # ]:          6 :         TEST(!C_isspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     343 [ -  + ][ #  # ]:          6 :         TEST(C_isnotupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     344 [ -  + ][ #  # ]:          6 :         TEST(!C_isnotlower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     345 [ -  + ][ #  # ]:          6 :         TEST(!C_isnotalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     346 [ -  + ][ #  # ]:          6 :         TEST(!C_isnotalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     347 [ -  + ][ #  # ]:          6 :         TEST(C_isnotdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     348 [ -  + ][ #  # ]:          6 :         TEST(!C_isnotxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     349 [ -  + ][ #  # ]:          6 :         TEST(C_isnotspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     350 [ -  + ][ #  # ]:          6 :         TEST_EQUAL(hex_digit(ch), ch - 'a' + 10);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     351                 :            :     }
     352                 :            : 
     353         [ +  + ]:         21 :     for (int ch = 'g'; ch != 'z' + 1; ++ch) {
     354                 :         20 :         tested[ch] = 1;
     355 [ -  + ][ #  # ]:         20 :         TEST(!C_isupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     356 [ -  + ][ #  # ]:         20 :         TEST(C_islower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     357 [ -  + ][ #  # ]:         20 :         TEST(C_isalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     358 [ -  + ][ #  # ]:         20 :         TEST(C_isalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     359 [ -  + ][ #  # ]:         20 :         TEST(!C_isdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     360 [ -  + ][ #  # ]:         20 :         TEST(!C_isxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     361 [ -  + ][ #  # ]:         20 :         TEST(!C_isspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     362 [ -  + ][ #  # ]:         20 :         TEST(C_isnotupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     363 [ -  + ][ #  # ]:         20 :         TEST(!C_isnotlower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     364 [ -  + ][ #  # ]:         20 :         TEST(!C_isnotalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     365 [ -  + ][ #  # ]:         20 :         TEST(!C_isnotalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     366 [ -  + ][ #  # ]:         20 :         TEST(C_isnotdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     367 [ -  + ][ #  # ]:         20 :         TEST(C_isnotxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     368 [ -  + ][ #  # ]:         20 :         TEST(C_isnotspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     369                 :            :     }
     370                 :            : 
     371         [ +  + ]:          6 :     for (const char *p = "\t\n\f\r "; *p; ++p) {
     372                 :          5 :         int ch = *p;
     373                 :          5 :         tested[ch] = 1;
     374 [ -  + ][ #  # ]:          5 :         TEST(!C_isupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     375 [ -  + ][ #  # ]:          5 :         TEST(!C_islower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     376 [ -  + ][ #  # ]:          5 :         TEST(!C_isalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     377 [ -  + ][ #  # ]:          5 :         TEST(!C_isalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     378 [ -  + ][ #  # ]:          5 :         TEST(!C_isdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     379 [ -  + ][ #  # ]:          5 :         TEST(!C_isxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     380 [ -  + ][ #  # ]:          5 :         TEST(C_isspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     381 [ -  + ][ #  # ]:          5 :         TEST(C_isnotupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     382 [ -  + ][ #  # ]:          5 :         TEST(C_isnotlower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     383 [ -  + ][ #  # ]:          5 :         TEST(C_isnotalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     384 [ -  + ][ #  # ]:          5 :         TEST(C_isnotalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     385 [ -  + ][ #  # ]:          5 :         TEST(C_isnotdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     386 [ -  + ][ #  # ]:          5 :         TEST(C_isnotxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     387 [ -  + ][ #  # ]:          5 :         TEST(!C_isnotspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     388                 :            :     }
     389                 :            : 
     390                 :            :     // Check remaining non-top-bit-set characters aren't anything.
     391         [ +  + ]:        129 :     for (int ch = 0; ch != 128; ++ch) {
     392         [ +  + ]:        128 :         if (tested[ch]) continue;
     393 [ -  + ][ #  # ]:         61 :         TEST(!C_isupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     394 [ -  + ][ #  # ]:         61 :         TEST(!C_islower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     395 [ -  + ][ #  # ]:         61 :         TEST(!C_isalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     396 [ -  + ][ #  # ]:         61 :         TEST(!C_isalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     397 [ -  + ][ #  # ]:         61 :         TEST(!C_isdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     398 [ -  + ][ #  # ]:         61 :         TEST(!C_isxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     399 [ -  + ][ #  # ]:         61 :         TEST(!C_isspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     400 [ -  + ][ #  # ]:         61 :         TEST(C_isnotupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     401 [ -  + ][ #  # ]:         61 :         TEST(C_isnotlower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     402 [ -  + ][ #  # ]:         61 :         TEST(C_isnotalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     403 [ -  + ][ #  # ]:         61 :         TEST(C_isnotalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     404 [ -  + ][ #  # ]:         61 :         TEST(C_isnotdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     405 [ -  + ][ #  # ]:         61 :         TEST(C_isnotxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     406 [ -  + ][ #  # ]:         61 :         TEST(C_isnotspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     407                 :            :     }
     408                 :            : 
     409                 :            :     // Non-ASCII characters aren't anything for these functions.
     410         [ +  + ]:        129 :     for (unsigned char ch = 128; ch != 0; ++ch) {
     411 [ -  + ][ #  # ]:        128 :         TEST(!C_isupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     412 [ -  + ][ #  # ]:        128 :         TEST(!C_islower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     413 [ -  + ][ #  # ]:        128 :         TEST(!C_isalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     414 [ -  + ][ #  # ]:        128 :         TEST(!C_isalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     415 [ -  + ][ #  # ]:        128 :         TEST(!C_isdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     416 [ -  + ][ #  # ]:        128 :         TEST(!C_isxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     417 [ -  + ][ #  # ]:        128 :         TEST(!C_isspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     418 [ -  + ][ #  # ]:        128 :         TEST(C_isnotupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     419 [ -  + ][ #  # ]:        128 :         TEST(C_isnotlower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     420 [ -  + ][ #  # ]:        128 :         TEST(C_isnotalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     421 [ -  + ][ #  # ]:        128 :         TEST(C_isnotalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     422 [ -  + ][ #  # ]:        128 :         TEST(C_isnotdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     423 [ -  + ][ #  # ]:        128 :         TEST(C_isnotxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     424 [ -  + ][ #  # ]:        128 :         TEST(C_isnotspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     425                 :            :     }
     426                 :            : 
     427                 :            :     // Check signed char values work the same way.
     428         [ +  + ]:        129 :     for (signed char ch = -128; ch != 0; ++ch) {
     429 [ -  + ][ #  # ]:        128 :         TEST(!C_isupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     430 [ -  + ][ #  # ]:        128 :         TEST(!C_islower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     431 [ -  + ][ #  # ]:        128 :         TEST(!C_isalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     432 [ -  + ][ #  # ]:        128 :         TEST(!C_isalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     433 [ -  + ][ #  # ]:        128 :         TEST(!C_isdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     434 [ -  + ][ #  # ]:        128 :         TEST(!C_isxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     435 [ -  + ][ #  # ]:        128 :         TEST(!C_isspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     436 [ -  + ][ #  # ]:        128 :         TEST(C_isnotupper(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     437 [ -  + ][ #  # ]:        128 :         TEST(C_isnotlower(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     438 [ -  + ][ #  # ]:        128 :         TEST(C_isnotalpha(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     439 [ -  + ][ #  # ]:        128 :         TEST(C_isnotalnum(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     440 [ -  + ][ #  # ]:        128 :         TEST(C_isnotdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     441 [ -  + ][ #  # ]:        128 :         TEST(C_isnotxdigit(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     442 [ -  + ][ #  # ]:        128 :         TEST(C_isnotspace(ch));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     443                 :            :     }
     444                 :            : 
     445                 :          1 :     return true;
     446                 :            : }
     447                 :            : 
     448                 :            : // ##################################################################
     449                 :            : // # End of actual tests                                            #
     450                 :            : // ##################################################################
     451                 :            : 
     452                 :            : /// The lists of tests to perform
     453                 :            : static const test_desc tests[] = {
     454                 :            :     TESTCASE(exception1),
     455                 :            :     TESTCASE(refcnt1),
     456                 :            :     TESTCASE(refcnt2),
     457                 :            :     TESTCASE(stringcomp1),
     458                 :            :     TESTCASE(temporarydtor1),
     459                 :            :     TESTCASE(pack_uint_preserving_sort1),
     460                 :            :     TESTCASE(chartype1),
     461                 :            :     {0, 0}
     462                 :            : };
     463                 :            : 
     464                 :          1 : int main(int argc, char **argv)
     465                 :            : try {
     466         [ +  - ]:          1 :     test_driver::parse_command_line(argc, argv);
     467         [ +  - ]:          1 :     return test_driver::run(tests);
     468         [ #  # ]:          0 : } catch (const char * e) {
     469   [ #  #  #  # ]:          0 :     cout << e << endl;
     470                 :          0 :     return 1;
     471 [ +  - ][ +  - ]:          4 : }

Generated by: LCOV version 1.11