LCOV - code coverage report
Current view: top level - tests - dbcheck.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 194 196 99.0 %
Date: 2019-06-30 05:20:33 Functions: 6 6 100.0 %
Branches: 301 1276 23.6 %

           Branch data     Line data    Source code
       1                 :            : /** @file dbcheck.cc
       2                 :            :  * @brief test database contents and consistency.
       3                 :            :  */
       4                 :            : /* Copyright 2009 Richard Boulton
       5                 :            :  * Copyright 2010,2015 Olly Betts
       6                 :            :  *
       7                 :            :  * This program is free software; you can redistribute it and/or
       8                 :            :  * modify it under the terms of the GNU General Public License as
       9                 :            :  * published by the Free Software Foundation; either version 2 of the
      10                 :            :  * License, or (at your option) any later version.
      11                 :            :  *
      12                 :            :  * This program is distributed in the hope that it will be useful,
      13                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :            :  * GNU General Public License for more details.
      16                 :            :  *
      17                 :            :  * You should have received a copy of the GNU General Public License
      18                 :            :  * along with this program; if not, write to the Free Software
      19                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      20                 :            :  * USA
      21                 :            :  */
      22                 :            : 
      23                 :            : #include <config.h>
      24                 :            : 
      25                 :            : #include "dbcheck.h"
      26                 :            : 
      27                 :            : #include "str.h"
      28                 :            : #include "testsuite.h"
      29                 :            : 
      30                 :            : using namespace std;
      31                 :            : 
      32                 :            : string
      33                 :     106710 : positions_to_string(Xapian::PositionIterator & it,
      34                 :            :                     const Xapian::PositionIterator & end,
      35                 :            :                     Xapian::termcount * count)
      36                 :            : {
      37                 :     106710 :     string result;
      38                 :     106710 :     bool need_comma = false;
      39                 :     106710 :     Xapian::termcount c = 0;
      40         [ +  + ]:     125472 :     while (it != end) {
      41         [ +  + ]:      18762 :         if (need_comma)
      42         [ +  - ]:       3761 :             result += ", ";
      43 [ +  - ][ +  - ]:      18762 :         result += str(*it);
                 [ +  - ]
      44                 :      18762 :         need_comma = true;
      45         [ +  - ]:      18762 :         ++it;
      46                 :      18762 :         ++c;
      47                 :            :     }
      48         [ +  + ]:     106710 :     if (count) {
      49                 :      71486 :         *count = c;
      50                 :            :     }
      51                 :     106710 :     return result;
      52                 :            : }
      53                 :            : 
      54                 :            : string
      55                 :         71 : postlist_to_string(const Xapian::Database & db, const string & tname)
      56                 :            : {
      57                 :         71 :     string result;
      58                 :         71 :     bool need_comma = false;
      59                 :            : 
      60         [ +  - ]:        567 :     for (Xapian::PostingIterator p = db.postlist_begin(tname);
           [ +  -  +  + ]
      61                 :        378 :          p != db.postlist_end(tname);
      62                 :            :          ++p) {
      63         [ +  + ]:        118 :         if (need_comma)
      64         [ +  - ]:         52 :             result += ", ";
      65                 :            : 
      66         [ +  - ]:        118 :         Xapian::PositionIterator it(p.positionlist_begin());
      67         [ +  - ]:        236 :         string posrepr = positions_to_string(it, p.positionlist_end());
      68         [ +  + ]:        118 :         if (!posrepr.empty()) {
      69 [ +  - ][ +  - ]:         60 :             posrepr = ", pos=[" + posrepr + "]";
                 [ +  - ]
      70                 :            :         }
      71                 :            : 
      72 [ +  - ][ +  - ]:        236 :         result += "(" + str(*p) +
         [ +  - ][ +  - ]
      73 [ +  - ][ +  - ]:        472 :                 ", doclen=" + str(p.get_doclength()) +
         [ +  - ][ +  - ]
      74 [ +  - ][ +  - ]:        472 :                 ", wdf=" + str(p.get_wdf()) +
         [ +  - ][ +  - ]
      75 [ +  - ][ +  - ]:        118 :                 posrepr + ")";
      76                 :        118 :         need_comma = true;
      77                 :        189 :     }
      78                 :         71 :     return result;
      79                 :            : }
      80                 :            : 
      81                 :            : string
      82                 :        130 : docterms_to_string(const Xapian::Database & db, Xapian::docid did)
      83                 :            : {
      84                 :        130 :     string result;
      85                 :        130 :     bool need_comma = false;
      86                 :            : 
      87         [ +  + ]:       1370 :     for (Xapian::TermIterator t = db.termlist_begin(did);
           [ +  -  +  + ]
      88                 :        910 :          t != db.termlist_end(did);
      89                 :            :          ++t) {
      90         [ +  - ]:        330 :         Xapian::PositionIterator it(t.positionlist_begin());
      91         [ +  - ]:        660 :         string posrepr = positions_to_string(it, t.positionlist_end());
      92         [ +  + ]:        330 :         if (!posrepr.empty()) {
      93 [ +  - ][ +  - ]:         40 :             posrepr = ", pos=[" + posrepr + "]";
                 [ +  - ]
      94                 :            :         }
      95         [ +  + ]:        330 :         if (need_comma)
      96         [ +  - ]:        205 :             result += ", ";
      97 [ +  - ][ +  - ]:        330 :         result += "Term(" + *t + ", wdf=" + str(t.get_wdf()) + posrepr;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      98         [ +  - ]:        330 :         result += ")";
      99                 :        330 :         need_comma = true;
     100                 :        460 :     }
     101                 :        125 :     return result;
     102                 :            : }
     103                 :            : 
     104                 :            : string
     105                 :          5 : docstats_to_string(const Xapian::Database & db, Xapian::docid did)
     106                 :            : {
     107                 :          5 :     string result;
     108                 :            : 
     109 [ -  + ][ #  # ]:          5 :     result += "len=" + str(db.get_doclength(did));
         [ #  # ][ #  # ]
     110                 :            : 
     111                 :          0 :     return result;
     112                 :            : }
     113                 :            : 
     114                 :            : string
     115                 :          5 : termstats_to_string(const Xapian::Database & db, const string & term)
     116                 :            : {
     117                 :          5 :     string result;
     118                 :            : 
     119 [ +  - ][ +  - ]:          5 :     result += "tf=" + str(db.get_termfreq(term));
         [ +  - ][ +  - ]
     120 [ +  - ][ +  - ]:          5 :     result += ",cf=" + str(db.get_collection_freq(term));
         [ +  - ][ +  - ]
     121                 :            : 
     122                 :          5 :     return result;
     123                 :            : }
     124                 :            : 
     125                 :            : void
     126                 :        154 : dbcheck(const Xapian::Database & db,
     127                 :            :         Xapian::doccount expected_doccount,
     128                 :            :         Xapian::docid expected_lastdocid)
     129                 :            : {
     130 [ +  - ][ -  + ]:        154 :     TEST_EQUAL(db.get_doccount(), expected_doccount);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     131 [ +  - ][ -  + ]:        154 :     TEST_EQUAL(db.get_lastdocid(), expected_lastdocid);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     132                 :            : 
     133                 :            :     // Note - may not be a very big type, but we're only expecting to use this
     134                 :            :     // for small databases, so should be fine.
     135                 :        154 :     unsigned long totlen = 0;
     136                 :            : 
     137                 :            :     // A map from term to a representation of the posting list for that term.
     138                 :            :     // We build this up from the documents, and then check it against the
     139                 :            :     // equivalent built up from the posting lists.
     140         [ +  - ]:        154 :     map<string, string> posting_reprs;
     141         [ +  - ]:        308 :     map<Xapian::valueno, string> value_reprs;
     142                 :            : 
     143                 :        154 :     Xapian::termcount doclen_lower_bound = Xapian::termcount(-1);
     144                 :        154 :     Xapian::termcount doclen_upper_bound = 0;
     145                 :            : 
     146 [ +  - ][ +  - ]:      91767 :     for (Xapian::PostingIterator dociter = db.postlist_begin(string());
           [ +  -  +  + ]
     147         [ +  - ]:      61178 :          dociter != db.postlist_end(string());
     148                 :            :          ++dociter) {
     149         [ +  - ]:      30435 :         Xapian::docid did = *dociter;
     150 [ +  - ][ -  + ]:      30435 :         TEST_EQUAL(dociter.get_wdf(), 1);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     151         [ +  - ]:      30435 :         Xapian::Document doc(db.get_document(did));
     152         [ +  - ]:      30435 :         Xapian::termcount doclen(db.get_doclength(did));
     153         [ +  - ]:      30435 :         Xapian::termcount unique_terms(db.get_unique_terms(did));
     154         [ +  + ]:      30435 :         if (doclen < doclen_lower_bound)
     155                 :        168 :             doclen_lower_bound = doclen;
     156         [ +  + ]:      30435 :         if (doclen > doclen_upper_bound)
     157                 :        176 :             doclen_upper_bound = doclen;
     158                 :      30435 :         totlen += doclen;
     159                 :            : 
     160                 :      30435 :         Xapian::termcount found_termcount = 0;
     161                 :      30435 :         Xapian::termcount found_unique_terms = 0;
     162                 :      30435 :         Xapian::termcount wdf_sum = 0;
     163                 :      60870 :         Xapian::TermIterator t, t2;
     164 [ +  - ][ +  - ]:     198534 :         for (t = doc.termlist_begin(), t2 = db.termlist_begin(did);
         [ +  - ][ +  - ]
                 [ +  - ]
           [ +  -  +  + ]
     165                 :     132356 :              t != doc.termlist_end();
     166                 :            :              ++t, ++t2) {
     167 [ -  + ][ #  # ]:      35743 :             TEST(t2 != db.termlist_end(did));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     168                 :            : 
     169                 :      35743 :             ++found_termcount;
     170         [ +  - ]:      35743 :             auto wdf = t.get_wdf();
     171         [ +  + ]:      35743 :             if (wdf) ++found_unique_terms;
     172                 :      35743 :             wdf_sum += wdf;
     173                 :            : 
     174 [ +  - ][ +  - ]:      35743 :             TEST_EQUAL(*t, *t2);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     175 [ +  - ][ +  - ]:      35743 :             TEST_EQUAL(t.get_wdf(), t2.get_wdf());
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     176 [ +  - ][ +  - ]:      35743 :             TEST_EQUAL(db.get_termfreq(*t), t.get_termfreq());
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     177 [ +  - ][ +  - ]:      35743 :             TEST_EQUAL(db.get_termfreq(*t), t2.get_termfreq());
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     178                 :            : 
     179                 :            :             // Check the position lists are equal.
     180                 :            :             Xapian::termcount tc1, tc2;
     181         [ +  - ]:      35743 :             Xapian::PositionIterator it1(t.positionlist_begin());
     182         [ +  - ]:      71486 :             string posrepr = positions_to_string(it1, t.positionlist_end(), &tc1);
     183         [ +  - ]:      71486 :             Xapian::PositionIterator it2(t2.positionlist_begin());
     184         [ +  - ]:      71486 :             string posrepr2 = positions_to_string(it2, t2.positionlist_end(), &tc2);
     185 [ -  + ][ #  # ]:      35743 :             TEST_EQUAL(posrepr, posrepr2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     186 [ -  + ][ #  # ]:      35743 :             TEST_EQUAL(tc1, tc2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     187 [ +  - ][ -  + ]:      35743 :             TEST_EQUAL(tc1, t.positionlist_count());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     188                 :            : 
     189                 :            :             // Make a representation of the posting.
     190         [ +  + ]:      35743 :             if (!posrepr.empty()) {
     191 [ +  - ][ +  - ]:       5290 :                 posrepr = ",[" + posrepr + "]";
                 [ +  - ]
     192                 :            :             }
     193 [ +  - ][ +  - ]:      71486 :             string posting_repr = "(" + str(did) + "," +
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     194 [ +  - ][ +  - ]:     107229 :                     str(t.get_wdf()) + "/" + str(doclen) +
         [ +  - ][ +  - ]
     195         [ +  - ]:     107229 :                     posrepr + ")";
     196                 :            : 
     197                 :            :             // Append the representation to the list for the term.
     198 [ +  - ][ +  - ]:      35743 :             map<string, string>::iterator i = posting_reprs.find(*t);
     199         [ +  + ]:      35743 :             if (i == posting_reprs.end()) {
     200 [ +  - ][ +  - ]:       3404 :                 posting_reprs[*t] = posting_repr;
                 [ +  - ]
     201                 :            :             } else {
     202 [ +  - ][ +  - ]:      32339 :                 i->second += "," + posting_repr;
     203                 :            :             }
     204                 :      35743 :         }
     205                 :            : 
     206                 :      30435 :         Xapian::termcount vcount = 0;
     207 [ +  - ][ +  - ]:     100461 :         for (Xapian::ValueIterator v = doc.values_begin();
                 [ +  + ]
     208                 :      66974 :              v != doc.values_end();
     209                 :            :              ++v, ++vcount) {
     210 [ +  - ][ -  + ]:       3052 :             TEST((*v).size() != 0);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     211 [ +  - ][ +  - ]:       3052 :             string value_repr = "(" + str(did) + "," + *v + ")";
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     212                 :            : 
     213                 :            :             // Append the values to the value lists.
     214                 :       3052 :             map<Xapian::valueno, string>::iterator i;
     215 [ +  - ][ +  - ]:       3052 :             i = value_reprs.find(v.get_valueno());
     216         [ +  + ]:       3052 :             if (i == value_reprs.end()) {
     217 [ +  - ][ +  - ]:        378 :                 value_reprs[v.get_valueno()] = value_repr;
                 [ +  - ]
     218                 :            :             } else {
     219 [ +  - ][ +  - ]:       2674 :                 i->second += "," + value_repr;
     220                 :            :             }
     221                 :      33487 :         }
     222 [ +  - ][ -  + ]:      30435 :         TEST_EQUAL(vcount, doc.values_count());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     223 [ -  + ][ #  # ]:      30435 :         TEST(t2 == db.termlist_end(did));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     224         [ +  - ]:      30435 :         Xapian::termcount expected_termcount = doc.termlist_count();
     225 [ -  + ][ #  # ]:      30435 :         TEST_EQUAL(expected_termcount, found_termcount);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     226                 :            :         // Ideally this would be equal, but currently we don't store the
     227                 :            :         // unique_terms values but calculate them, and scanning the termlist
     228                 :            :         // of each document would be slow, so instead get_unique_terms(did)
     229                 :            :         // returns min(doclen, termcount) at present.
     230 [ -  + ][ #  # ]:      30435 :         TEST_REL(unique_terms, >=, found_unique_terms);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     231 [ -  + ][ #  # ]:      30435 :         TEST_REL(unique_terms, <=, found_termcount);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     232 [ -  + ][ #  # ]:      30435 :         TEST_REL(unique_terms, <=, doclen);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     233 [ -  + ][ #  # ]:      30435 :         TEST_EQUAL(doclen, wdf_sum);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     234                 :      30589 :     }
     235                 :            : 
     236 [ +  - ][ -  + ]:        154 :     TEST_REL(doclen_lower_bound, >=, db.get_doclength_lower_bound());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     237 [ +  - ][ -  + ]:        154 :     TEST_REL(doclen_upper_bound, <=, db.get_doclength_upper_bound());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     238                 :            : 
     239                 :        308 :     Xapian::TermIterator t;
     240                 :        154 :     map<string, string>::const_iterator i;
     241 [ +  - ][ +  - ]:       9114 :     for (t = db.allterms_begin(), i = posting_reprs.begin();
         [ +  - ][ +  - ]
                 [ +  + ]
     242         [ +  - ]:       6076 :          t != db.allterms_end();
     243                 :            :          ++t, ++i) {
     244 [ +  - ][ +  - ]:       2890 :         TEST(db.term_exists(*t));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     245 [ -  + ][ #  # ]:       2890 :         TEST(i != posting_reprs.end());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     246 [ +  - ][ -  + ]:       2890 :         TEST_EQUAL(i->first, *t);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     247                 :            : 
     248                 :       2890 :         Xapian::doccount tf_count = 0;
     249                 :       2890 :         Xapian::termcount cf_count = 0;
     250                 :       2890 :         Xapian::termcount wdf_upper_bound = 0;
     251         [ +  - ]:       2890 :         string posting_repr;
     252                 :       2890 :         bool need_comma = false;
     253 [ +  - ][ +  - ]:     112985 :         for (Xapian::PostingIterator p = db.postlist_begin(*t);
           [ +  +  +  + ]
     254         [ +  - ]:      75320 :              p != db.postlist_end(*t);
     255                 :            :              ++p) {
     256         [ +  + ]:      34776 :             if (need_comma) {
     257         [ +  - ]:      31886 :                 posting_repr += ",";
     258                 :            :             }
     259                 :            : 
     260                 :      34776 :             ++tf_count;
     261         [ +  - ]:      34776 :             cf_count += p.get_wdf();
     262                 :            : 
     263         [ +  - ]:      34776 :             Xapian::PositionIterator it(p.positionlist_begin());
     264         [ +  - ]:      69552 :             string posrepr = positions_to_string(it, p.positionlist_end());
     265         [ +  + ]:      34776 :             if (!posrepr.empty()) {
     266 [ +  - ][ +  - ]:       4321 :                 posrepr = ",[" + posrepr + "]";
                 [ +  - ]
     267                 :            :             }
     268 [ +  - ][ +  - ]:      69550 :             posting_repr += "(" + str(*p) + "," +
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     269 [ +  + ][ +  - ]:     139101 :                     str(p.get_wdf()) + "/" +
         [ +  - ][ +  - ]
     270 [ +  - ][ +  - ]:      34775 :                     str(p.get_doclength()) + posrepr + ")";
                 [ +  - ]
     271 [ +  - ][ +  + ]:      34775 :             if (wdf_upper_bound < p.get_wdf())
     272         [ +  - ]:       2956 :                 wdf_upper_bound = p.get_wdf();
     273                 :      34775 :             need_comma = true;
     274                 :      37665 :         }
     275                 :            : 
     276 [ -  + ][ #  # ]:       2884 :         TEST_EQUAL(posting_repr, i->second);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     277 [ +  - ][ -  + ]:       2884 :         TEST_EQUAL(tf_count, t.get_termfreq());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     278 [ +  - ][ +  - ]:       2884 :         TEST_EQUAL(tf_count, db.get_termfreq(*t));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     279 [ +  - ][ +  - ]:       2884 :         TEST_EQUAL(cf_count, db.get_collection_freq(*t));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     280 [ +  - ][ +  - ]:       2884 :         TEST_REL(wdf_upper_bound, <=, db.get_wdf_upper_bound(*t));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     281                 :       2890 :     }
     282 [ -  + ][ #  # ]:        148 :     TEST(i == posting_reprs.end());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     283                 :            : 
     284                 :        148 :     map<Xapian::valueno, string>::const_iterator j;
     285         [ +  + ]:        456 :     for (j = value_reprs.begin(); j != value_reprs.end(); ++j) {
     286         [ +  - ]:        308 :         string value_repr;
     287         [ +  - ]:        616 :         string value_lower_bound;
     288         [ +  - ]:        616 :         string value_upper_bound;
     289                 :        308 :         bool first = true;
     290         [ +  - ]:       8232 :         for (Xapian::ValueIterator v = db.valuestream_begin(j->first);
           [ +  -  +  + ]
     291                 :       5488 :              v != db.valuestream_end(j->first); ++v) {
     292         [ +  + ]:       2436 :             if (first) {
     293 [ +  - ][ +  - ]:        308 :                 value_lower_bound = *v;
     294 [ +  - ][ +  - ]:        308 :                 value_upper_bound = *v;
     295                 :        308 :                 first = false;
     296                 :            :             } else {
     297         [ +  - ]:       2128 :                 value_repr += ",";
     298 [ +  - ][ +  - ]:       2128 :                 if (*v > value_upper_bound) {
                 [ +  + ]
     299 [ +  - ][ +  - ]:        359 :                     value_upper_bound = *v;
     300                 :            :                 }
     301 [ +  - ][ +  - ]:       2128 :                 if (*v < value_lower_bound) {
                 [ +  + ]
     302 [ +  - ][ +  - ]:        332 :                     value_lower_bound = *v;
     303                 :            :                 }
     304                 :            :             }
     305 [ +  - ][ +  - ]:       2436 :             value_repr += "(" + str(v.get_docid()) + "," + *v + ")";
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     306                 :        308 :         }
     307 [ -  + ][ #  # ]:        308 :         TEST_EQUAL(value_repr, j->second);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     308                 :            :         try {
     309 [ +  - ][ +  - ]:        308 :             TEST_REL(value_upper_bound, <=, db.get_value_upper_bound(j->first));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     310 [ +  - ][ +  - ]:        308 :             TEST_REL(value_lower_bound, >=, db.get_value_lower_bound(j->first));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     311         [ #  # ]:          0 :         } catch (const Xapian::UnimplementedError &) {
     312                 :            :             // Skip the checks if the methods to get the bounds aren't
     313                 :            :             // implemented for this backend.
     314                 :            :         }
     315                 :        308 :     }
     316                 :            : 
     317         [ +  + ]:        148 :     if (expected_doccount == 0) {
     318 [ +  - ][ -  + ]:         13 :         TEST_EQUAL(0, db.get_avlength());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     319                 :            :     } else {
     320 [ +  - ][ +  - ]:        135 :         TEST_EQUAL_DOUBLE(double(totlen) / expected_doccount,
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     321                 :            :                           db.get_avlength());
     322                 :        154 :     }
     323                 :        148 : }

Generated by: LCOV version 1.11