~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/third_party/google-sparsehash/src/testutil.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (c) 2010, Google Inc.
2
 
// All rights reserved.
3
 
// 
4
 
// Redistribution and use in source and binary forms, with or without
5
 
// modification, are permitted provided that the following conditions are
6
 
// met:
7
 
// 
8
 
//     * Redistributions of source code must retain the above copyright
9
 
// notice, this list of conditions and the following disclaimer.
10
 
//     * Redistributions in binary form must reproduce the above
11
 
// copyright notice, this list of conditions and the following disclaimer
12
 
// in the documentation and/or other materials provided with the
13
 
// distribution.
14
 
//     * Neither the name of Google Inc. nor the names of its
15
 
// contributors may be used to endorse or promote products derived from
16
 
// this software without specific prior written permission.
17
 
// 
18
 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 
 
30
 
// ---
31
 
// Author: Craig Silverstein
32
 
 
33
 
// This macro mimics a unittest framework, but is a bit less flexible
34
 
// than most.  It requires a superclass to derive from, and does all
35
 
// work in global constructors.  The tricky part is implementing
36
 
// TYPED_TEST.
37
 
 
38
 
#ifndef SPARSEHASH_TEST_UTIL_H_
39
 
#define SPARSEHASH_TEST_UTIL_H_
40
 
 
41
 
#include "config.h"
42
 
#include <stdio.h>
43
 
 
44
 
_START_GOOGLE_NAMESPACE_
45
 
 
46
 
namespace testing {
47
 
 
48
 
#define EXPECT_TRUE(cond)  do {                         \
49
 
  if (!(cond)) {                                        \
50
 
    ::fputs("Test failed: " #cond "\n", stderr);        \
51
 
    ::exit(1);                                          \
52
 
  }                                                     \
53
 
} while (0)
54
 
 
55
 
#define EXPECT_FALSE(a)  EXPECT_TRUE(!(a))
56
 
#define EXPECT_EQ(a, b)  EXPECT_TRUE((a) == (b))
57
 
#define EXPECT_LT(a, b)  EXPECT_TRUE((a) < (b))
58
 
#define EXPECT_GT(a, b)  EXPECT_TRUE((a) > (b))
59
 
#define EXPECT_LE(a, b)  EXPECT_TRUE((a) <= (b))
60
 
#define EXPECT_GE(a, b)  EXPECT_TRUE((a) >= (b))
61
 
 
62
 
#define TEST(suitename, testname)                                       \
63
 
  class TEST_##suitename##_##testname {                                 \
64
 
   public:                                                              \
65
 
    TEST_##suitename##_##testname() {                                   \
66
 
      ::fputs("Running " #suitename "." #testname "\n", stderr);        \
67
 
      Run();                                                            \
68
 
    }                                                                   \
69
 
    void Run();                                                         \
70
 
  };                                                                    \
71
 
  static TEST_##suitename##_##testname                                  \
72
 
      test_instance_##suitename##_##testname;                           \
73
 
  void TEST_##suitename##_##testname::Run()
74
 
 
75
 
 
76
 
template<typename C1, typename C2, typename C3, typename C4, typename C5,
77
 
         typename C6> struct TypeList6 {
78
 
  typedef C1 type1;
79
 
  typedef C2 type2;
80
 
  typedef C3 type3;
81
 
  typedef C4 type4;
82
 
  typedef C5 type5;
83
 
  typedef C6 type6;
84
 
};
85
 
 
86
 
// I need to list 18 types here, for code below to compile, though
87
 
// only the first 6 are ever used.
88
 
#define TYPED_TEST_CASE_6(classname, typelist)  \
89
 
  typedef typelist::type1 classname##_type1;    \
90
 
  typedef typelist::type2 classname##_type2;    \
91
 
  typedef typelist::type3 classname##_type3;    \
92
 
  typedef typelist::type4 classname##_type4;    \
93
 
  typedef typelist::type5 classname##_type5;    \
94
 
  typedef typelist::type6 classname##_type6;    \
95
 
  static const int classname##_numtypes = 6;    \
96
 
  typedef typelist::type1 classname##_type7;    \
97
 
  typedef typelist::type1 classname##_type8;    \
98
 
  typedef typelist::type1 classname##_type9;    \
99
 
  typedef typelist::type1 classname##_type10;   \
100
 
  typedef typelist::type1 classname##_type11;   \
101
 
  typedef typelist::type1 classname##_type12;   \
102
 
  typedef typelist::type1 classname##_type13;   \
103
 
  typedef typelist::type1 classname##_type14;   \
104
 
  typedef typelist::type1 classname##_type15;   \
105
 
  typedef typelist::type1 classname##_type16;   \
106
 
  typedef typelist::type1 classname##_type17;   \
107
 
  typedef typelist::type1 classname##_type18;
108
 
 
109
 
template<typename C1, typename C2, typename C3, typename C4, typename C5,
110
 
         typename C6, typename C7, typename C8, typename C9, typename C10,
111
 
         typename C11, typename C12, typename C13, typename C14, typename C15,
112
 
         typename C16, typename C17, typename C18> struct TypeList18 {
113
 
  typedef C1 type1;
114
 
  typedef C2 type2;
115
 
  typedef C3 type3;
116
 
  typedef C4 type4;
117
 
  typedef C5 type5;
118
 
  typedef C6 type6;
119
 
  typedef C7 type7;
120
 
  typedef C8 type8;
121
 
  typedef C9 type9;
122
 
  typedef C10 type10;
123
 
  typedef C11 type11;
124
 
  typedef C12 type12;
125
 
  typedef C13 type13;
126
 
  typedef C14 type14;
127
 
  typedef C15 type15;
128
 
  typedef C16 type16;
129
 
  typedef C17 type17;
130
 
  typedef C18 type18;
131
 
};
132
 
 
133
 
#define TYPED_TEST_CASE_18(classname, typelist)  \
134
 
  typedef typelist::type1 classname##_type1;    \
135
 
  typedef typelist::type2 classname##_type2;    \
136
 
  typedef typelist::type3 classname##_type3;    \
137
 
  typedef typelist::type4 classname##_type4;    \
138
 
  typedef typelist::type5 classname##_type5;    \
139
 
  typedef typelist::type6 classname##_type6;    \
140
 
  typedef typelist::type7 classname##_type7;    \
141
 
  typedef typelist::type8 classname##_type8;    \
142
 
  typedef typelist::type9 classname##_type9;    \
143
 
  typedef typelist::type10 classname##_type10;    \
144
 
  typedef typelist::type11 classname##_type11;    \
145
 
  typedef typelist::type12 classname##_type12;    \
146
 
  typedef typelist::type13 classname##_type13;    \
147
 
  typedef typelist::type14 classname##_type14;    \
148
 
  typedef typelist::type15 classname##_type15;    \
149
 
  typedef typelist::type16 classname##_type16;    \
150
 
  typedef typelist::type17 classname##_type17;    \
151
 
  typedef typelist::type18 classname##_type18;    \
152
 
  static const int classname##_numtypes = 18;
153
 
 
154
 
#define TYPED_TEST(superclass, testname)                                \
155
 
  template<typename TypeParam>                                          \
156
 
  class TEST_onetype_##superclass##_##testname :                        \
157
 
      public superclass<TypeParam> {                                    \
158
 
   public:                                                              \
159
 
    TEST_onetype_##superclass##_##testname() {                          \
160
 
      Run();                                                            \
161
 
    }                                                                   \
162
 
   private:                                                             \
163
 
    void Run();                                                         \
164
 
  };                                                                    \
165
 
  class TEST_typed_##superclass##_##testname {                          \
166
 
   public:                                                              \
167
 
    explicit TEST_typed_##superclass##_##testname() {                   \
168
 
      if (superclass##_numtypes >= 1) {                                 \
169
 
        ::fputs("Running " #superclass "." #testname ".1\n", stderr);   \
170
 
        TEST_onetype_##superclass##_##testname<superclass##_type1> t;   \
171
 
      }                                                                 \
172
 
      if (superclass##_numtypes >= 2) {                                 \
173
 
        ::fputs("Running " #superclass "." #testname ".2\n", stderr);   \
174
 
        TEST_onetype_##superclass##_##testname<superclass##_type2> t;   \
175
 
      }                                                                 \
176
 
      if (superclass##_numtypes >= 3) {                                 \
177
 
        ::fputs("Running " #superclass "." #testname ".3\n", stderr);   \
178
 
        TEST_onetype_##superclass##_##testname<superclass##_type3> t;   \
179
 
      }                                                                 \
180
 
      if (superclass##_numtypes >= 4) {                                 \
181
 
        ::fputs("Running " #superclass "." #testname ".4\n", stderr);   \
182
 
        TEST_onetype_##superclass##_##testname<superclass##_type4> t;   \
183
 
      }                                                                 \
184
 
      if (superclass##_numtypes >= 5) {                                 \
185
 
        ::fputs("Running " #superclass "." #testname ".5\n", stderr);   \
186
 
        TEST_onetype_##superclass##_##testname<superclass##_type5> t;   \
187
 
      }                                                                 \
188
 
      if (superclass##_numtypes >= 6) {                                 \
189
 
        ::fputs("Running " #superclass "." #testname ".6\n", stderr);   \
190
 
        TEST_onetype_##superclass##_##testname<superclass##_type6> t;   \
191
 
      }                                                                 \
192
 
      if (superclass##_numtypes >= 7) {                                 \
193
 
        ::fputs("Running " #superclass "." #testname ".7\n", stderr);   \
194
 
        TEST_onetype_##superclass##_##testname<superclass##_type7> t;   \
195
 
      }                                                                 \
196
 
      if (superclass##_numtypes >= 8) {                                 \
197
 
        ::fputs("Running " #superclass "." #testname ".8\n", stderr);   \
198
 
        TEST_onetype_##superclass##_##testname<superclass##_type8> t;   \
199
 
      }                                                                 \
200
 
      if (superclass##_numtypes >= 9) {                                 \
201
 
        ::fputs("Running " #superclass "." #testname ".9\n", stderr);   \
202
 
        TEST_onetype_##superclass##_##testname<superclass##_type9> t;   \
203
 
      }                                                                 \
204
 
      if (superclass##_numtypes >= 10) {                                \
205
 
        ::fputs("Running " #superclass "." #testname ".10\n", stderr);  \
206
 
        TEST_onetype_##superclass##_##testname<superclass##_type10> t;  \
207
 
      }                                                                 \
208
 
      if (superclass##_numtypes >= 11) {                                \
209
 
        ::fputs("Running " #superclass "." #testname ".11\n", stderr);  \
210
 
        TEST_onetype_##superclass##_##testname<superclass##_type11> t;  \
211
 
      }                                                                 \
212
 
      if (superclass##_numtypes >= 12) {                                \
213
 
        ::fputs("Running " #superclass "." #testname ".12\n", stderr);  \
214
 
        TEST_onetype_##superclass##_##testname<superclass##_type12> t;  \
215
 
      }                                                                 \
216
 
      if (superclass##_numtypes >= 13) {                                \
217
 
        ::fputs("Running " #superclass "." #testname ".13\n", stderr);  \
218
 
        TEST_onetype_##superclass##_##testname<superclass##_type13> t;  \
219
 
      }                                                                 \
220
 
      if (superclass##_numtypes >= 14) {                                \
221
 
        ::fputs("Running " #superclass "." #testname ".14\n", stderr);  \
222
 
        TEST_onetype_##superclass##_##testname<superclass##_type14> t;  \
223
 
      }                                                                 \
224
 
      if (superclass##_numtypes >= 15) {                                \
225
 
        ::fputs("Running " #superclass "." #testname ".15\n", stderr);  \
226
 
        TEST_onetype_##superclass##_##testname<superclass##_type15> t;  \
227
 
      }                                                                 \
228
 
      if (superclass##_numtypes >= 16) {                                \
229
 
        ::fputs("Running " #superclass "." #testname ".16\n", stderr);  \
230
 
        TEST_onetype_##superclass##_##testname<superclass##_type16> t;  \
231
 
      }                                                                 \
232
 
      if (superclass##_numtypes >= 17) {                                \
233
 
        ::fputs("Running " #superclass "." #testname ".17\n", stderr);  \
234
 
        TEST_onetype_##superclass##_##testname<superclass##_type17> t;  \
235
 
      }                                                                 \
236
 
      if (superclass##_numtypes >= 18) {                                \
237
 
        ::fputs("Running " #superclass "." #testname ".18\n", stderr);  \
238
 
        TEST_onetype_##superclass##_##testname<superclass##_type18> t;  \
239
 
      }                                                                 \
240
 
    }                                                                   \
241
 
  };                                                                    \
242
 
  static TEST_typed_##superclass##_##testname                           \
243
 
      test_instance_typed_##superclass##_##testname;                    \
244
 
  template<class TypeParam>                                             \
245
 
  void TEST_onetype_##superclass##_##testname<TypeParam>::Run()
246
 
 
247
 
} // namespace testing
248
 
 
249
 
_END_GOOGLE_NAMESPACE_
250
 
 
251
 
#endif  // SPARSEHASH_TEST_UTIL_H_