2 my $copyright = 'Copyright (C) 2007,2009,2012,2014,2015,2016,2018 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,
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 $class = "Xapian::$class";
138 print " $class $object$params;\n";
139 print " TEST(!$object.get_description().empty());\n" if $get_description;
145 /// Test that API classes have a copy ctor and assignment operator.
146 DEFINE_TESTCASE(copyassign1, !backend) {
149 for my $class (sort keys %copyableclasses) {
150 my $params = $copyableclasses{$class};
151 if ($params =~ /INMEMORY/) {
152 print "#ifdef XAPIAN_HAS_INMEMORY_BACKEND\n";
155 $params = "($params)";
157 my $get_description = ! exists $no_get_description{$class};
158 my $object = lc $class;
159 $class = "Xapian::$class";
160 print " $class $object$params;\n";
161 print " TEST(!$object.get_description().empty());\n" if $get_description;
162 print " $class copy_$object($object);\n";
163 print " TEST(!copy_$object.get_description().empty());\n" if $get_description;
164 print " $class move_$object(std::move($object));\n";
165 print " TEST(!move_$object.get_description().empty());\n" if $get_description;
166 print " $object = copy_$object;\n";
167 print " TEST(!$object.get_description().empty());\n" if $get_description;
168 print " copy_$object = std::move(move_$object);\n";
169 print " TEST(!copy_$object.get_description().empty());\n" if $get_description;
170 if ($params =~ /INMEMORY/) {