Eliminate broken PostListCursor for non-const HoneyTable
[xapian.git] / xapian-core / tests / generate-api_generated
blob629e935a9c593df4f559e5c9a438d0170cd0b99f
1 #!/usr/bin/perl -w
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
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 my $full_class = "Xapian::$class";
138 print " $full_class $object$params;\n";
139 if ($get_description) {
140 print " {\n";
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";
147 print " }\n";
151 print <<'END';
152 return true;
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";
164 if ($params ne '') {
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/) {
175 print "#endif\n";
177 print "\n";
180 print <<'END';
181 return true;