2 my $copyright = 'Copyright (C) 2007,2009,2012,2014,2015,2016,2017 Olly Betts';
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 my $generated_warning =
21 "/* Warning: This file is generated by $0 - do not modify directly! */\n";
23 my %uncopyableclasses = (
33 'ValuePostingSource' => '0',
34 'ValueWeightPostingSource' => '0',
35 'DecreasingValueWeightPostingSource' => '0',
36 'ValueCountMatchSpy' => '0',
37 'ValueMapPostingSource' => '0',
38 'FixedWeightPostingSource' => '0',
39 'DateRangeProcessor' => '0',
40 'DateValueRangeProcessor' => '0',
41 'MultiValueKeyMaker' => '',
42 'NumberRangeProcessor' => '0, ""',
43 'NumberValueRangeProcessor' => '0, ""',
44 'RangeProcessor' => '',
45 'SimpleStopper' => '',
46 'StringValueRangeProcessor' => '0'
49 my %copyableclasses = (
54 'Enquire' => 'Xapian::Database(std::string(), Xapian::DB_BACKEND_INMEMORY)',
57 'PositionIterator' => '',
58 'PostingIterator' => '',
64 'TermGenerator' => '',
66 'ValueIterator' => '',
67 'WritableDatabase' => ''
70 my %no_get_description = (
71 'DateRangeProcessor' => 1,
72 'DateValueRangeProcessor' => 1,
73 'MultiValueKeyMaker' => 1,
74 'NumberRangeProcessor' => 1,
75 'NumberValueRangeProcessor' => 1,
76 'RangeProcessor' => 1,
78 'StringValueRangeProcessor' => 1,
91 /** @file api_generated.cc
92 * @brief test common features of API classes
95 print $generated_warning;
99 * This program is free software; you can redistribute it and/or modify
100 * it under the terms of the GNU General Public License as published by
101 * the Free Software Foundation; either version 2 of the License, or
102 * (at your option) any later version.
104 * This program is distributed in the hope that it will be useful,
105 * but WITHOUT ANY WARRANTY; without even the implied warranty of
106 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107 * GNU General Public License for more details.
109 * You should have received a copy of the GNU General Public License
110 * along with this program; if not, write to the Free Software
111 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
116 #include "api_generated.h"
118 #define XAPIAN_DEPRECATED(D) D
122 #include "testutils.h"
126 /// Check uncopyable API classes which should have a default ctor actually do.
127 DEFINE_TESTCASE(defaultctor1, !backend) {
130 for my $class (sort keys %uncopyableclasses) {
131 my $params = $uncopyableclasses{$class};
133 $params = "($params)";
135 my $get_description = ! exists $no_get_description{$class};
136 my $object = lc $class;
137 my $full_class = "Xapian::$class";
138 print " $full_class $object$params;\n";
139 if ($get_description) {
141 print "\tconst string& desc = $object.get_description();\n";
142 print "\ttout.clear();\n";
143 print "\ttout << desc << endl;\n";
144 print "\tTEST(startswith(desc, \"$class(\") ||\n";
145 print "\t startswith(desc, \"$full_class(\"));\n";
146 print "\tTEST(desc.back() == ')');\n";
155 /// Test that API classes have a copy ctor and assignment operator.
156 DEFINE_TESTCASE(copyassign1, !backend) {
159 for my $class (sort keys %copyableclasses) {
160 my $params = $copyableclasses{$class};
161 if ($params =~ /INMEMORY/) {
162 print "#ifdef XAPIAN_HAS_INMEMORY_BACKEND\n";
165 $params = "($params)";
167 my $get_description = ! exists $no_get_description{$class};
168 my $object = lc $class;
169 $class = "Xapian::$class";
170 print " $class $object$params;\n";
171 print " TEST(!$object.get_description().empty());\n" if $get_description;
172 print " $class copy_$object($object);\n";
173 print " $object = copy_$object;\n";
174 if ($params =~ /INMEMORY/) {