LCOV - code coverage report
Current view: top level - tests - api_geospatial.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core c2b6f1024d3a Lines: 264 264 100.0 %
Date: 2019-05-16 09:13:18 Functions: 6 6 100.0 %
Branches: 395 3326 11.9 %

           Branch data     Line data    Source code
       1                 :            : /** @file api_geospatial.cc
       2                 :            :  * @brief Tests of geospatial functionality.
       3                 :            :  */
       4                 :            : /* Copyright 2008 Lemur Consulting Ltd
       5                 :            :  * Copyright 2010,2011 Richard Boulton
       6                 :            :  * Copyright 2012,2016 Olly Betts
       7                 :            :  *
       8                 :            :  * This program is free software; you can redistribute it and/or
       9                 :            :  * modify it under the terms of the GNU General Public License as
      10                 :            :  * published by the Free Software Foundation; either version 2 of the
      11                 :            :  * License, or (at your option) any later version.
      12                 :            :  *
      13                 :            :  * This program is distributed in the hope that it will be useful,
      14                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16                 :            :  * GNU General Public License for more details.
      17                 :            :  *
      18                 :            :  * You should have received a copy of the GNU General Public License
      19                 :            :  * along with this program; if not, write to the Free Software
      20                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      21                 :            :  * USA
      22                 :            :  */
      23                 :            : 
      24                 :            : #include <config.h>
      25                 :            : #include "api_geospatial.h"
      26                 :            : #include <xapian.h>
      27                 :            : 
      28                 :            : #include "apitest.h"
      29                 :            : #include "testsuite.h"
      30                 :            : #include "testutils.h"
      31                 :            : 
      32                 :            : using namespace std;
      33                 :            : using namespace Xapian;
      34                 :            : 
      35                 :            : // #######################################################################
      36                 :            : // # Tests start here
      37                 :            : 
      38                 :            : static void
      39                 :          2 : builddb_coords1(Xapian::WritableDatabase &db, const string &)
      40                 :            : {
      41         [ +  - ]:          2 :     Xapian::LatLongCoord coord1(10, 10);
      42         [ +  - ]:          2 :     Xapian::LatLongCoord coord2(20, 10);
      43         [ +  - ]:          2 :     Xapian::LatLongCoord coord3(30, 10);
      44                 :            : 
      45         [ +  - ]:          2 :     Xapian::Document doc;
      46 [ +  - ][ +  - ]:          2 :     doc.add_value(0, coord1.serialise());
      47         [ +  - ]:          2 :     db.add_document(doc);
      48                 :            : 
      49 [ +  - ][ +  - ]:          2 :     doc = Xapian::Document();
      50 [ +  - ][ +  - ]:          2 :     doc.add_value(0, coord2.serialise());
      51         [ +  - ]:          2 :     db.add_document(doc);
      52                 :            : 
      53 [ +  - ][ +  - ]:          2 :     doc = Xapian::Document();
      54 [ +  - ][ +  - ]:          2 :     doc.add_value(0, coord3.serialise());
      55         [ +  - ]:          2 :     db.add_document(doc);
      56                 :          2 : }
      57                 :            : 
      58                 :            : /// Test behaviour of the LatLongDistancePostingSource
      59                 :          2 : DEFINE_TESTCASE(latlongpostingsource1, generated && !remote && !inmemory) {
      60 [ +  - ][ +  - ]:          2 :     Xapian::Database db = get_database("coords1", builddb_coords1, "");
                 [ +  - ]
      61         [ +  - ]:          2 :     Xapian::LatLongCoord coord1(10, 10);
      62         [ +  - ]:          2 :     Xapian::LatLongCoord coord2(20, 10);
      63         [ +  - ]:          2 :     Xapian::LatLongCoord coord3(30, 10);
      64                 :            : 
      65         [ +  - ]:          4 :     Xapian::GreatCircleMetric metric;
      66                 :          4 :     Xapian::LatLongCoords centre;
      67         [ +  - ]:          2 :     centre.append(coord1);
      68 [ +  - ][ +  - ]:          2 :     double coorddist = metric(coord1, coord2);
                 [ +  - ]
      69 [ +  - ][ +  - ]:          2 :     TEST_EQUAL_DOUBLE(coorddist, metric(coord2, coord3));
         [ +  - ][ +  - ]
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      70                 :            : 
      71                 :            :     // Test a search with no range restriction.
      72                 :            :     {
      73 [ +  - ][ +  - ]:          2 :         Xapian::LatLongDistancePostingSource ps(0, coord1, metric);
      74         [ +  - ]:          2 :         ps.init(db);
      75                 :            : 
      76         [ +  - ]:          2 :         ps.next(0.0);
      77 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      78 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1.0);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      79 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 1);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      80                 :            : 
      81         [ +  - ]:          2 :         ps.next(0.0);
      82 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      83 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      84 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      85                 :            : 
      86         [ +  - ]:          2 :         ps.next(0.0);
      87 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      88 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist * 2));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      89 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 3);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      90                 :            : 
      91         [ +  - ]:          2 :         ps.next(0.0);
      92 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      93                 :            :     }
      94                 :            : 
      95                 :            :     // Test a search with no range restriction and implicit metric.
      96                 :            :     {
      97 [ +  - ][ +  - ]:          2 :         Xapian::LatLongDistancePostingSource ps(0, coord1);
      98         [ +  - ]:          2 :         ps.init(db);
      99                 :            : 
     100         [ +  - ]:          2 :         ps.next(0.0);
     101 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     102 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1.0);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     103 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 1);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     104                 :            : 
     105         [ +  - ]:          2 :         ps.next(0.0);
     106 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     107 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     108 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     109                 :            : 
     110         [ +  - ]:          2 :         ps.next(0.0);
     111 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     112 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist * 2));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     113 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 3);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     114                 :            : 
     115         [ +  - ]:          2 :         ps.next(0.0);
     116 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     117                 :            :     }
     118                 :            : 
     119                 :            :     // Test a search with a tight range restriction
     120                 :            :     {
     121         [ +  - ]:          2 :         Xapian::LatLongDistancePostingSource ps(0, centre, metric, coorddist * 0.5);
     122         [ +  - ]:          2 :         ps.init(db);
     123                 :            : 
     124         [ +  - ]:          2 :         ps.next(0.0);
     125 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     126 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1.0);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     127                 :            : 
     128         [ +  - ]:          2 :         ps.next(0.0);
     129 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     130                 :            :     }
     131                 :            : 
     132                 :            :     // Test a search with a tight range restriction and implicit metric.
     133                 :            :     {
     134         [ +  - ]:          2 :         Xapian::LatLongDistancePostingSource ps(0, centre, coorddist * 0.5);
     135         [ +  - ]:          2 :         ps.init(db);
     136                 :            : 
     137         [ +  - ]:          2 :         ps.next(0.0);
     138 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     139 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1.0);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     140                 :            : 
     141         [ +  - ]:          2 :         ps.next(0.0);
     142 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     143                 :            :     }
     144                 :            : 
     145                 :            :     // Test a search with a looser range restriction
     146                 :            :     {
     147         [ +  - ]:          2 :         Xapian::LatLongDistancePostingSource ps(0, centre, metric, coorddist);
     148         [ +  - ]:          2 :         ps.init(db);
     149                 :            : 
     150         [ +  - ]:          2 :         ps.next(0.0);
     151 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     152 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1.0);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     153                 :            : 
     154         [ +  - ]:          2 :         ps.next(0.0);
     155 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     156 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     157 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     158                 :            : 
     159         [ +  - ]:          2 :         ps.next(0.0);
     160 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     161                 :            :     }
     162                 :            : 
     163                 :            :     // Test a search with a looser range restriction and implicit metric.
     164                 :            :     {
     165         [ +  - ]:          2 :         Xapian::LatLongDistancePostingSource ps(0, centre, coorddist);
     166         [ +  - ]:          2 :         ps.init(db);
     167                 :            : 
     168         [ +  - ]:          2 :         ps.next(0.0);
     169 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     170 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1.0);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     171                 :            : 
     172         [ +  - ]:          2 :         ps.next(0.0);
     173 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     174 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     175 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     176                 :            : 
     177         [ +  - ]:          2 :         ps.next(0.0);
     178 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     179                 :            :     }
     180                 :            : 
     181                 :            :     // Test a search with a looser range restriction, but not enough to return
     182                 :            :     // the next document.
     183                 :            :     {
     184         [ +  - ]:          2 :         Xapian::LatLongDistancePostingSource ps(0, centre, metric, coorddist * 1.5);
     185         [ +  - ]:          2 :         ps.init(db);
     186                 :            : 
     187         [ +  - ]:          2 :         ps.next(0.0);
     188 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     189 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1.0);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     190                 :            : 
     191         [ +  - ]:          2 :         ps.next(0.0);
     192 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     193 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     194 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     195                 :            : 
     196         [ +  - ]:          2 :         ps.next(0.0);
     197 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     198                 :            :     }
     199                 :            : 
     200                 :            :     // Test a search with a looser range restriction, but not enough to return
     201                 :            :     // the next document and implicit metric.
     202                 :            :     {
     203         [ +  - ]:          2 :         Xapian::LatLongDistancePostingSource ps(0, centre, coorddist * 1.5);
     204         [ +  - ]:          2 :         ps.init(db);
     205                 :            : 
     206         [ +  - ]:          2 :         ps.next(0.0);
     207 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     208 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1.0);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     209                 :            : 
     210         [ +  - ]:          2 :         ps.next(0.0);
     211 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     212 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     213 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     214                 :            : 
     215         [ +  - ]:          2 :         ps.next(0.0);
     216 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     217                 :            :     }
     218                 :            : 
     219                 :            :     // Test a search with a loose enough range restriction that all docs should
     220                 :            :     // be returned.
     221                 :            :     {
     222         [ +  - ]:          2 :         Xapian::LatLongDistancePostingSource ps(0, centre, metric, coorddist * 2.5);
     223         [ +  - ]:          2 :         ps.init(db);
     224                 :            : 
     225         [ +  - ]:          2 :         ps.next(0.0);
     226 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     227 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1.0);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     228                 :            : 
     229         [ +  - ]:          2 :         ps.next(0.0);
     230 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     231 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     232 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     233                 :            : 
     234         [ +  - ]:          2 :         ps.next(0.0);
     235 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     236 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist * 2));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     237 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 3);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     238                 :            : 
     239         [ +  - ]:          2 :         ps.next(0.0);
     240 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     241                 :            :     }
     242                 :            : 
     243                 :            :     // Test a search with a loose enough range restriction that all docs should
     244                 :            :     // be returned and implicit metric.
     245                 :            :     {
     246         [ +  - ]:          2 :         Xapian::LatLongDistancePostingSource ps(0, centre, coorddist * 2.5);
     247         [ +  - ]:          2 :         ps.init(db);
     248                 :            : 
     249         [ +  - ]:          2 :         ps.next(0.0);
     250 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     251 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1.0);
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     252                 :            : 
     253         [ +  - ]:          2 :         ps.next(0.0);
     254 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     255 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     256 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     257                 :            : 
     258         [ +  - ]:          2 :         ps.next(0.0);
     259 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), false);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     260 [ +  - ][ +  - ]:          2 :         TEST_EQUAL_DOUBLE(ps.get_weight(), 1000.0 / (1000.0 + coorddist * 2));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     261 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.get_docid(), 3);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     262                 :            : 
     263         [ +  - ]:          2 :         ps.next(0.0);
     264 [ +  - ][ -  + ]:          2 :         TEST_EQUAL(ps.at_end(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     265                 :            :     }
     266                 :            : 
     267                 :          2 :     return true;
     268                 :            : }
     269                 :            : 
     270                 :            : // Test various methods of LatLongCoord and LatLongCoords
     271                 :          1 : DEFINE_TESTCASE(latlongcoords1, !backend) {
     272         [ +  - ]:          1 :     LatLongCoord c1(0, 0);
     273         [ +  - ]:          1 :     LatLongCoord c2(1, 0);
     274         [ +  - ]:          1 :     LatLongCoord c3(1, 0);
     275         [ +  - ]:          1 :     LatLongCoord c4(0, 1);
     276                 :            : 
     277                 :            :     // Test comparison
     278 [ +  - ][ +  - ]:          1 :     TEST_NOT_EQUAL(c1.get_description(), c2.get_description());
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     279                 :            :     // Exactly one of these inequalities should be true.
     280 [ -  + ][ #  # ]:          1 :     TEST((c1 < c2) ^ (c2 < c1));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     281 [ +  - ][ +  - ]:          1 :     TEST_EQUAL(c2.get_description(), c3.get_description());
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     282 [ +  - ][ -  + ]:          1 :     TEST(!(c2 < c3) && !(c3 < c2));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     283 [ +  - ][ +  - ]:          1 :     TEST_NOT_EQUAL(c3.get_description(), c4.get_description());
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     284                 :            :     // Exactly one of these inequalities should be true.  This is a regression
     285                 :            :     // test for bug found prior to 1.3.0.
     286 [ -  + ][ #  # ]:          1 :     TEST((c3 < c4) ^ (c4 < c3));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     287                 :            : 
     288                 :            :     // Test serialisation
     289         [ +  - ]:          1 :     std::string s1 = c1.serialise();
     290                 :          1 :     LatLongCoord c5;
     291         [ +  - ]:          1 :     c4.unserialise(s1);
     292 [ +  - ][ -  + ]:          1 :     TEST(!(c1 < c4 || c4 < c1));
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     293                 :          1 :     const char * ptr = s1.data();
     294                 :          1 :     const char * end = ptr + s1.size();
     295         [ +  - ]:          1 :     c5.unserialise(&ptr, end);
     296 [ +  - ][ +  - ]:          1 :     TEST_EQUAL(c1.get_description(), c4.get_description());
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     297 [ +  - ][ +  - ]:          1 :     TEST_EQUAL(c1.get_description(), "Xapian::LatLongCoord(0, 0)");
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     298 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(ptr, end);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     299                 :            : 
     300                 :            :     // Test uninitialised iterator constructor
     301                 :          1 :     LatLongCoordsIterator i1;
     302                 :            : 
     303                 :            :     // Test building a set of LatLongCoords
     304         [ +  - ]:          2 :     LatLongCoords g1(c1);
     305 [ -  + ][ #  # ]:          1 :     TEST(!g1.empty());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     306 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(g1.size(), 1);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     307 [ +  - ][ +  - ]:          1 :     TEST_EQUAL(g1.get_description(), "Xapian::LatLongCoords((0, 0))");
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     308         [ +  - ]:          1 :     g1.append(c2);
     309 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(g1.size(), 2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     310 [ +  - ][ +  - ]:          1 :     TEST_EQUAL(g1.get_description(), "Xapian::LatLongCoords((0, 0), (1, 0))");
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     311                 :            : 
     312                 :            :     // Test iterating through a set of LatLongCoords
     313                 :          1 :     i1 = g1.begin();
     314 [ -  + ][ #  # ]:          1 :     TEST(i1 != g1.end());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     315 [ +  - ][ +  - ]:          1 :     TEST_EQUAL((*i1).serialise(), c1.serialise());
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     316 [ +  - ][ +  - ]:          1 :     TEST_EQUAL((*i1).serialise(), c1.serialise());
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     317                 :          1 :     ++i1;
     318 [ -  + ][ #  # ]:          1 :     TEST(i1 != g1.end());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     319 [ +  - ][ +  - ]:          1 :     TEST_EQUAL((*i1).serialise(), c2.serialise());
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     320                 :          1 :     i1 = g1.begin();
     321                 :          1 :     ++i1;
     322 [ +  - ][ +  - ]:          1 :     TEST_EQUAL((*i1).serialise(), c2.serialise());
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     323 [ -  + ][ #  # ]:          1 :     TEST(i1 != g1.end());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     324                 :          1 :     ++i1;
     325 [ -  + ][ #  # ]:          1 :     TEST(i1 == g1.end());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     326                 :            : 
     327                 :            :     // Test that duplicates are allowed in the list of coordinates, now.
     328         [ +  - ]:          1 :     g1.append(c3);
     329 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(g1.size(), 3);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     330 [ +  - ][ +  - ]:          1 :     TEST_EQUAL(g1.get_description(), "Xapian::LatLongCoords((0, 0), (1, 0), (1, 0))");
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     331                 :            : 
     332                 :            :     // Test building an empty LatLongCoords
     333                 :          2 :     LatLongCoords g2;
     334 [ -  + ][ #  # ]:          1 :     TEST(g2.empty());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     335 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(g2.size(), 0);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     336 [ +  - ][ +  - ]:          1 :     TEST_EQUAL(g2.get_description(), "Xapian::LatLongCoords()");
         [ -  + ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     337 [ -  + ][ #  # ]:          1 :     TEST(g2.begin() == g2.end());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     338                 :            : 
     339                 :          1 :     return true;
     340                 :            : }
     341                 :            : 
     342                 :            : // Test various methods of LatLongMetric
     343                 :          1 : DEFINE_TESTCASE(latlongmetric1, !backend) {
     344         [ +  - ]:          1 :     LatLongCoord c1(0, 0);
     345         [ +  - ]:          1 :     LatLongCoord c2(1, 0);
     346         [ +  - ]:          1 :     Xapian::GreatCircleMetric m1;
     347 [ +  - ][ +  - ]:          1 :     double d1 = m1(c1, c2);
                 [ +  - ]
     348 [ -  + ][ #  # ]:          1 :     TEST_REL(d1, >, 111226.0);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     349 [ -  + ][ #  # ]:          1 :     TEST_REL(d1, <, 111227.0);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     350                 :            : 
     351                 :            :     // Let's make another metric, this time using the radius of mars, so
     352                 :            :     // distances should be quite a bit smaller.
     353         [ +  - ]:          2 :     Xapian::GreatCircleMetric m2(3310000);
     354 [ +  - ][ +  - ]:          1 :     double d2 = m2(c1, c2);
                 [ +  - ]
     355 [ -  + ][ #  # ]:          1 :     TEST_REL(d2, >, 57770.0);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     356 [ -  + ][ #  # ]:          1 :     TEST_REL(d2, <, 57771.0);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     357                 :            : 
     358                 :            :     // Check serialise and unserialise.
     359         [ +  - ]:          2 :     Xapian::Registry registry;
     360         [ +  - ]:          2 :     std::string s1 = m2.serialise();
     361                 :            :     const Xapian::LatLongMetric * m3;
     362 [ +  - ][ +  - ]:          1 :     m3 = registry.get_lat_long_metric(m2.name());
     363 [ -  + ][ #  # ]:          1 :     TEST(m3 != NULL);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     364         [ +  - ]:          1 :     m3 = m3->unserialise(s1);
     365 [ +  - ][ +  - ]:          1 :     double d3 = (*m3)(c1, c2);
                 [ +  - ]
     366 [ +  - ][ -  + ]:          1 :     TEST_EQUAL_DOUBLE(d2, d3);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     367                 :            : 
     368         [ +  - ]:          1 :     delete m3;
     369                 :            : 
     370                 :          1 :     return true;
     371                 :            : }
     372                 :            : 
     373                 :            : // Test LatLongMetric on lists of coords.
     374                 :          1 : DEFINE_TESTCASE(latlongmetric2, !backend) {
     375         [ +  - ]:          1 :     LatLongCoord c1(0, 0);
     376         [ +  - ]:          1 :     LatLongCoord c2(1, 0);
     377         [ +  - ]:          1 :     LatLongCoords cl1(c1);
     378         [ +  - ]:          2 :     LatLongCoords cl2(c2);
     379         [ +  - ]:          2 :     string c2_str = c2.serialise();
     380         [ +  - ]:          2 :     string cl2_str = cl2.serialise();
     381 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(c2_str, cl2_str);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     382                 :            : 
     383         [ +  - ]:          1 :     LatLongCoord c2_check(5, 5);
     384         [ +  - ]:          1 :     c2_check.unserialise(c2_str);
     385 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(c2_check.latitude, c2.latitude);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     386 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(c2_check.longitude, c2.longitude);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     387                 :            : 
     388         [ +  - ]:          2 :     Xapian::GreatCircleMetric m1;
     389 [ +  - ][ +  - ]:          1 :     double d1 = m1(c1, c2);
                 [ +  - ]
     390         [ +  - ]:          1 :     double dl1 = m1(cl1, cl2);
     391 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(d1, dl1);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     392         [ +  - ]:          1 :     double d1_str = m1(cl1, c2_str);
     393 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(d1, d1_str);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     394                 :            : 
     395                 :          1 :     return true;
     396                 :            : }
     397                 :            : 
     398                 :            : // Test a LatLongDistanceKeyMaker directly.
     399                 :          1 : DEFINE_TESTCASE(latlongkeymaker1, !backend) {
     400         [ +  - ]:          1 :     Xapian::GreatCircleMetric m1(3310000);
     401         [ +  - ]:          1 :     LatLongCoord c1(0, 0);
     402         [ +  - ]:          1 :     LatLongCoord c2(1, 0);
     403         [ +  - ]:          1 :     LatLongCoord c3(2, 0);
     404         [ +  - ]:          1 :     LatLongCoord c4(3, 0);
     405                 :            : 
     406         [ +  - ]:          2 :     LatLongCoords g1(c1);
     407         [ +  - ]:          1 :     g1.append(c2);
     408                 :            : 
     409         [ +  - ]:          2 :     LatLongDistanceKeyMaker keymaker(0, g1, m1);
     410         [ +  - ]:          2 :     Xapian::Document doc1;
     411 [ +  - ][ +  - ]:          1 :     doc1.add_value(0, g1.serialise());
     412         [ +  - ]:          2 :     Xapian::Document doc2;
     413 [ +  - ][ +  - ]:          1 :     doc2.add_value(0, c3.serialise());
     414         [ +  - ]:          2 :     Xapian::Document doc3;
     415 [ +  - ][ +  - ]:          1 :     doc3.add_value(0, c4.serialise());
     416         [ +  - ]:          2 :     Xapian::Document doc4;
     417                 :            : 
     418         [ +  - ]:          2 :     std::string k1 = keymaker(doc1);
     419         [ +  - ]:          2 :     std::string k2 = keymaker(doc2);
     420         [ +  - ]:          2 :     std::string k3 = keymaker(doc3);
     421         [ +  - ]:          2 :     std::string k4 = keymaker(doc4);
     422 [ +  - ][ -  + ]:          1 :     TEST_REL(k1, <, k2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     423 [ +  - ][ -  + ]:          1 :     TEST_REL(k2, <, k3);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     424 [ +  - ][ -  + ]:          1 :     TEST_REL(k3, <, k4);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     425                 :            : 
     426         [ +  - ]:          2 :     LatLongDistanceKeyMaker keymaker2(0, g1, m1, 0);
     427         [ +  - ]:          2 :     std::string k3b = keymaker2(doc3);
     428         [ +  - ]:          2 :     std::string k4b = keymaker2(doc4);
     429 [ -  + ][ #  # ]:          1 :     TEST_EQUAL(k3, k3b);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     430 [ +  - ][ -  + ]:          1 :     TEST_REL(k3b, >, k4b);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     431                 :            : 
     432                 :          1 :     return true;
     433                 :            : }

Generated by: LCOV version 1.11