1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
#!/usr/bin/perl -w
my $copyright = 'Copyright (C) 2007,2009,2012,2014,2015,2016 Olly Betts';
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
use strict;
my $generated_warning =
"/* Warning: This file is generated by $0 - do not modify directly! */\n";
my %uncopyableclasses = (
'BB2Weight' => '',
'BM25Weight' => '',
'BoolWeight' => '',
'DLHWeight' => '',
'IfB2Weight' => '',
'IneB2Weight' => '',
'InL2Weight' => '',
'TfIdfWeight' => '',
'TradWeight' => '',
'ValuePostingSource' => '0',
'ValueWeightPostingSource' => '0',
'DecreasingValueWeightPostingSource' => '0',
'ValueCountMatchSpy' => '0',
'ValueMapPostingSource' => '0',
'FixedWeightPostingSource' => '0',
'DateRangeProcessor' => '0',
'DateValueRangeProcessor' => '0',
'MultiValueKeyMaker' => '',
'NumberRangeProcessor' => '0, ""',
'NumberValueRangeProcessor' => '0, ""',
'RangeProcessor' => '',
'SimpleStopper' => '',
'StringValueRangeProcessor' => '0'
);
my %copyableclasses = (
'Database' => '',
'Document' => '',
'ESet' => '',
'ESetIterator' => '',
'Enquire' => 'Xapian::Database(std::string(), Xapian::DB_BACKEND_INMEMORY)',
'MSet' => '',
'MSetIterator' => '',
'PositionIterator' => '',
'PostingIterator' => '',
'Query' => '',
'QueryParser' => '',
'Registry' => '',
'RSet' => '',
'Stem' => '',
'TermGenerator' => '',
'TermIterator' => '',
'ValueIterator' => '',
'WritableDatabase' => ''
);
my %no_get_description = (
'DateRangeProcessor' => 1,
'DateValueRangeProcessor' => 1,
'MultiValueKeyMaker' => 1,
'NumberRangeProcessor' => 1,
'NumberValueRangeProcessor' => 1,
'RangeProcessor' => 1,
'Registry' => 1,
'StringValueRangeProcessor' => 1,
'BB2Weight' => 1,
'BM25Weight' => 1,
'BoolWeight' => 1,
'DLHWeight' => 1,
'IfB2Weight' => 1,
'IneB2Weight' => 1,
'InL2Weight' => 1,
'TfIdfWeight' => 1,
'TradWeight' => 1
);
print <<'END';
/** @file api_generated.cc
* @brief test common features of API classes
*/
END
print $generated_warning;
print <<"END";
/* $copyright
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <config.h>
#include "api_generated.h"
#define XAPIAN_DEPRECATED(D) D
#include <xapian.h>
#include "apitest.h"
#include "testutils.h"
using namespace std;
/// Check uncopyable API classes which should have a default ctor actually do.
DEFINE_TESTCASE(defaultctor1, !backend) {
END
for my $class (sort keys %uncopyableclasses) {
my $params = $uncopyableclasses{$class};
if ($params ne '') {
$params = "($params)";
}
my $get_description = ! exists $no_get_description{$class};
my $object = lc $class;
$class = "Xapian::$class";
print " $class $object$params;\n";
print " TEST(!$object.get_description().empty());\n" if $get_description;
}
print <<'END';
return true;
}
/// Test that API classes have a copy ctor and assignment operator.
DEFINE_TESTCASE(copyassign1, !backend) {
END
for my $class (sort keys %copyableclasses) {
my $params = $copyableclasses{$class};
if ($params =~ /INMEMORY/) {
print "#ifdef XAPIAN_HAS_INMEMORY_BACKEND\n";
}
if ($params ne '') {
$params = "($params)";
}
my $get_description = ! exists $no_get_description{$class};
my $object = lc $class;
$class = "Xapian::$class";
print " $class $object$params;\n";
print " TEST(!$object.get_description().empty());\n" if $get_description;
print " $class copy_$object($object);\n";
print " $object = copy_$object;\n";
if ($params =~ /INMEMORY/) {
print "#endif\n";
}
print "\n";
}
print <<'END';
return true;
}
END
|