Remove unused header include
[xapian.git] / xapian-core / tests / generate-api_generated
blob28fcd9d83a0a62eaddd6e71552526eb43bd9608a
1 #!/usr/bin/perl -w
2 my $copyright = 'Copyright (C) 2007,2009,2012,2014,2015,2016 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
18 use strict;
20 my $generated_warning =
21 "/* Warning: This file is generated by $0 - do not modify directly! */\n";
23 my %uncopyableclasses = (
24 'BB2Weight' => '',
25 'BM25Weight' => '',
26 'BoolWeight' => '',
27 'DLHWeight' => '',
28 'IfB2Weight' => '',
29 'IneB2Weight' => '',
30 'InL2Weight' => '',
31 'TfIdfWeight' => '',
32 'TradWeight' => '',
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 = (
50 'Database' => '',
51 'Document' => '',
52 'ESet' => '',
53 'ESetIterator' => '',
54 'Enquire' => 'Xapian::Database(std::string(), Xapian::DB_BACKEND_INMEMORY)',
55 'MSet' => '',
56 'MSetIterator' => '',
57 'PositionIterator' => '',
58 'PostingIterator' => '',
59 'Query' => '',
60 'QueryParser' => '',
61 'Registry' => '',
62 'RSet' => '',
63 'Stem' => '',
64 'TermGenerator' => '',
65 'TermIterator' => '',
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,
77 'Registry' => 1,
78 'StringValueRangeProcessor' => 1,
79 'BB2Weight' => 1,
80 'BM25Weight' => 1,
81 'BoolWeight' => 1,
82 'DLHWeight' => 1,
83 'IfB2Weight' => 1,
84 'IneB2Weight' => 1,
85 'InL2Weight' => 1,
86 'TfIdfWeight' => 1,
87 'TradWeight' => 1
90 print <<'END';
91 /** @file api_generated.cc
92 * @brief test common features of API classes
94 END
95 print $generated_warning;
96 print <<"END";
97 /* $copyright
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
114 #include <config.h>
116 #include "api_generated.h"
118 #define XAPIAN_DEPRECATED(D) D
119 #include <xapian.h>
121 #include "apitest.h"
122 #include "testutils.h"
124 using namespace std;
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};
132 if ($params ne '') {
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;
142 print <<'END';
143 return true;
146 /// Test that API classes have a copy ctor and assignment operator.
147 DEFINE_TESTCASE(copyassign1, !backend) {
150 for my $class (sort keys %copyableclasses) {
151 my $params = $copyableclasses{$class};
152 if ($params =~ /INMEMORY/) {
153 print "#ifdef XAPIAN_HAS_INMEMORY_BACKEND\n";
155 if ($params ne '') {
156 $params = "($params)";
158 my $get_description = ! exists $no_get_description{$class};
159 my $object = lc $class;
160 $class = "Xapian::$class";
161 print " $class $object$params;\n";
162 print " TEST(!$object.get_description().empty());\n" if $get_description;
163 print " $class copy_$object($object);\n";
164 print " $object = copy_$object;\n";
165 if ($params =~ /INMEMORY/) {
166 print "#endif\n";
168 print "\n";
171 print <<'END';
172 return true;