[letor] Fix to use correct XAPIAN_LDFLAGS
[xapian.git] / xapian-letor / tests / generate-api_generated
blob62b0c7bdae06f3ac5ecb32acf96ce3b46e923cdb
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 = (
26 my %copyableclasses = (
27 'FeatureVector' => ''
30 my %no_get_description = (
31 'FeatureVector' => '',
32 'Feature' => '',
33 'FeatureList' => '',
34 'Letor' => '',
35 'ListNETRanker' => '',
36 'NDCGScore' => '',
37 'SVMRanker' => ''
40 print <<'END';
41 /** @file api_generated.cc
42 * @brief test common features of API classes
44 END
45 print $generated_warning;
46 print <<"END";
47 /* $copyright
49 * This program is free software; you can redistribute it and/or modify
50 * it under the terms of the GNU General Public License as published by
51 * the Free Software Foundation; either version 2 of the License, or
52 * (at your option) any later version.
54 * This program is distributed in the hope that it will be useful,
55 * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 * GNU General Public License for more details.
59 * You should have received a copy of the GNU General Public License
60 * along with this program; if not, write to the Free Software
61 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
64 #include <config.h>
66 #include "api_generated.h"
68 #define XAPIAN_DEPRECATED(D) D
69 #include <xapian.h>
70 #include <xapian-letor.h>
72 #include "apitest.h"
73 #include "testutils.h"
75 using namespace std;
77 /// Check uncopyable API classes which should have a default ctor actually do.
78 DEFINE_TESTCASE(defaultctor1, !backend) {
79 END
81 for my $class (sort keys %uncopyableclasses) {
82 my $params = $uncopyableclasses{$class};
83 if ($params ne '') {
84 $params = "($params)";
86 my $get_description = ! exists $no_get_description{$class};
87 my $object = lc $class;
88 $class = "Xapian::$class";
89 print " $class $object$params;\n";
90 print " TEST(!$object.get_description().empty());\n" if $get_description;
93 print <<'END';
94 return true;
97 /// Test that API classes have a copy ctor and assignment operator.
98 DEFINE_TESTCASE(copyassign1, !backend) {
99 END
101 for my $class (sort keys %copyableclasses) {
102 my $params = $copyableclasses{$class};
103 if ($params =~ /INMEMORY/) {
104 print "#ifdef XAPIAN_HAS_INMEMORY_BACKEND\n";
106 if ($params ne '') {
107 $params = "($params)";
109 my $get_description = ! exists $no_get_description{$class};
110 my $object = lc $class;
111 $class = "Xapian::$class";
112 print " $class $object$params;\n";
113 print " TEST(!$object.get_description().empty());\n" if $get_description;
114 print " $class copy_$object($object);\n";
115 print " $object = copy_$object;\n";
116 if ($params =~ /INMEMORY/) {
117 print "#endif\n";
119 print "\n";
122 print <<'END';
123 return true;