]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/java/test/org/apache/thrift/test/EqualityTest.java
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / java / test / org / apache / thrift / test / EqualityTest.java
CommitLineData
f67539c2
TL
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20/*
21This program was generated by the following Python script:
22
23#!/usr/bin/python2.5
24
25# Remove this when Python 2.6 hits the streets.
26from __future__ import with_statement
27
28import sys
29import os.path
30
31
32# Quines the easy way.
33with open(sys.argv[0], 'r') as handle:
34 source = handle.read()
35
36with open(os.path.join(os.path.dirname(sys.argv[0]), 'EqualityTest.java'), 'w') as out:
37 print >> out, ("/""*" r"""
38 * Licensed to the Apache Software Foundation (ASF) under one
39 * or more contributor license agreements. See the NOTICE file
40 * distributed with this work for additional information
41 * regarding copyright ownership. The ASF licenses this file
42 * to you under the Apache License, Version 2.0 (the
43 * "License"); you may not use this file except in compliance
44 * with the License. You may obtain a copy of the License at
45 *
46 * http://www.apache.org/licenses/LICENSE-2.0
47 *
48 * Unless required by applicable law or agreed to in writing,
49 * software distributed under the License is distributed on an
50 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
51 * KIND, either express or implied. See the License for the
52 * specific language governing permissions and limitations
53 * under the License.
54 """ "*""/")
55 print >> out
56 print >> out, "/""*"
57 print >> out, "This program was generated by the following Python script:"
58 print >> out
59 out.write(source)
60 print >> out, "*""/"
61
62 print >> out, r'''
63package org.apache.thrift.test;
64
65// Generated code
66import thrift.test.*;
67
68/'''r'''**
69 *'''r'''/
70public class EqualityTest {
71 public static void main(String[] args) throws Exception {
72 JavaTestHelper lhs, rhs;
73'''
74
75 vals = {
76 'int': ("1", "2"),
77 'obj': ("\"foo\"", "\"bar\""),
78 'bin': ("new byte[]{1,2}", "new byte[]{3,4}"),
79 }
80 matrix = (
81 (False,False),
82 (False,True ),
83 (True ,False),
84 (True ,True ),
85 )
86
87 for type in ('int', 'obj', 'bin'):
88 for option in ('req', 'opt'):
89 nulls = matrix[0:1] if type == 'int' else matrix[-1::-1]
90 issets = matrix
91 for is_null in nulls:
92 for is_set in issets:
93 # isset is implied for non-primitives, so only consider the case
94 # where isset and non-null match.
95 if type != 'int' and list(is_set) != [ not null for null in is_null ]:
96 continue
97 for equal in (True, False):
98 print >> out
99 print >> out, " lhs = new JavaTestHelper();"
100 print >> out, " rhs = new JavaTestHelper();"
101 print >> out, " lhs." + option + "_" + type, "=", vals[type][0] + ";"
102 print >> out, " rhs." + option + "_" + type, "=", vals[type][0 if equal else 1] + ";"
103 isset_setter = "set" + option[0].upper() + option[1:] + "_" + type + "IsSet"
104 if (type == 'int' and is_set[0]): print >> out, " lhs." + isset_setter + "(true);"
105 if (type == 'int' and is_set[1]): print >> out, " rhs." + isset_setter + "(true);"
106 if (is_null[0]): print >> out, " lhs." + option + "_" + type, "= null;"
107 if (is_null[1]): print >> out, " rhs." + option + "_" + type, "= null;"
108 this_present = not is_null[0] and (option == 'req' or is_set[0])
109 that_present = not is_null[1] and (option == 'req' or is_set[1])
110 print >> out, " // this_present = " + repr(this_present)
111 print >> out, " // that_present = " + repr(that_present)
112 is_equal = \
113 (not this_present and not that_present) or \
114 (this_present and that_present and equal)
115 eq_str = 'true' if is_equal else 'false'
116
117 print >> out, " if (lhs.equals(rhs) != "+eq_str+")"
118 print >> out, " throw new RuntimeException(\"Failure\");"
119 if is_equal:
120 print >> out, " if (lhs.hashCode() != rhs.hashCode())"
121 print >> out, " throw new RuntimeException(\"Failure\");"
122
123 print >> out, r'''
124 }
125}
126'''
127*/
128
129package org.apache.thrift.test;
130
131// Generated code
132import java.nio.ByteBuffer;
133
134import thrift.test.JavaTestHelper;
135
136/**
137 */
138public class EqualityTest {
139 public static void main(String[] args) throws Exception {
140 JavaTestHelper lhs, rhs;
141
142
143 lhs = new JavaTestHelper();
144 rhs = new JavaTestHelper();
145 lhs.req_int = 1;
146 rhs.req_int = 1;
147 // this_present = True
148 // that_present = True
149 if (lhs.equals(rhs) != true)
150 throw new RuntimeException("Failure");
151 if (lhs.hashCode() != rhs.hashCode())
152 throw new RuntimeException("Failure");
153
154 lhs = new JavaTestHelper();
155 rhs = new JavaTestHelper();
156 lhs.req_int = 1;
157 rhs.req_int = 2;
158 // this_present = True
159 // that_present = True
160 if (lhs.equals(rhs) != false)
161 throw new RuntimeException("Failure");
162
163 lhs = new JavaTestHelper();
164 rhs = new JavaTestHelper();
165 lhs.req_int = 1;
166 rhs.req_int = 1;
167 rhs.setReq_intIsSet(true);
168 // this_present = True
169 // that_present = True
170 if (lhs.equals(rhs) != true)
171 throw new RuntimeException("Failure");
172 if (lhs.hashCode() != rhs.hashCode())
173 throw new RuntimeException("Failure");
174
175 lhs = new JavaTestHelper();
176 rhs = new JavaTestHelper();
177 lhs.req_int = 1;
178 rhs.req_int = 2;
179 rhs.setReq_intIsSet(true);
180 // this_present = True
181 // that_present = True
182 if (lhs.equals(rhs) != false)
183 throw new RuntimeException("Failure");
184
185 lhs = new JavaTestHelper();
186 rhs = new JavaTestHelper();
187 lhs.req_int = 1;
188 rhs.req_int = 1;
189 lhs.setReq_intIsSet(true);
190 // this_present = True
191 // that_present = True
192 if (lhs.equals(rhs) != true)
193 throw new RuntimeException("Failure");
194 if (lhs.hashCode() != rhs.hashCode())
195 throw new RuntimeException("Failure");
196
197 lhs = new JavaTestHelper();
198 rhs = new JavaTestHelper();
199 lhs.req_int = 1;
200 rhs.req_int = 2;
201 lhs.setReq_intIsSet(true);
202 // this_present = True
203 // that_present = True
204 if (lhs.equals(rhs) != false)
205 throw new RuntimeException("Failure");
206
207 lhs = new JavaTestHelper();
208 rhs = new JavaTestHelper();
209 lhs.req_int = 1;
210 rhs.req_int = 1;
211 lhs.setReq_intIsSet(true);
212 rhs.setReq_intIsSet(true);
213 // this_present = True
214 // that_present = True
215 if (lhs.equals(rhs) != true)
216 throw new RuntimeException("Failure");
217 if (lhs.hashCode() != rhs.hashCode())
218 throw new RuntimeException("Failure");
219
220 lhs = new JavaTestHelper();
221 rhs = new JavaTestHelper();
222 lhs.req_int = 1;
223 rhs.req_int = 2;
224 lhs.setReq_intIsSet(true);
225 rhs.setReq_intIsSet(true);
226 // this_present = True
227 // that_present = True
228 if (lhs.equals(rhs) != false)
229 throw new RuntimeException("Failure");
230
231 lhs = new JavaTestHelper();
232 rhs = new JavaTestHelper();
233 lhs.opt_int = 1;
234 rhs.opt_int = 1;
235 // this_present = False
236 // that_present = False
237 if (lhs.equals(rhs) != true)
238 throw new RuntimeException("Failure");
239 if (lhs.hashCode() != rhs.hashCode())
240 throw new RuntimeException("Failure");
241
242 lhs = new JavaTestHelper();
243 rhs = new JavaTestHelper();
244 lhs.opt_int = 1;
245 rhs.opt_int = 2;
246 // this_present = False
247 // that_present = False
248 if (lhs.equals(rhs) != true)
249 throw new RuntimeException("Failure");
250 if (lhs.hashCode() != rhs.hashCode())
251 throw new RuntimeException("Failure");
252
253 lhs = new JavaTestHelper();
254 rhs = new JavaTestHelper();
255 lhs.opt_int = 1;
256 rhs.opt_int = 1;
257 rhs.setOpt_intIsSet(true);
258 // this_present = False
259 // that_present = True
260 if (lhs.equals(rhs) != false)
261 throw new RuntimeException("Failure");
262
263 lhs = new JavaTestHelper();
264 rhs = new JavaTestHelper();
265 lhs.opt_int = 1;
266 rhs.opt_int = 2;
267 rhs.setOpt_intIsSet(true);
268 // this_present = False
269 // that_present = True
270 if (lhs.equals(rhs) != false)
271 throw new RuntimeException("Failure");
272
273 lhs = new JavaTestHelper();
274 rhs = new JavaTestHelper();
275 lhs.opt_int = 1;
276 rhs.opt_int = 1;
277 lhs.setOpt_intIsSet(true);
278 // this_present = True
279 // that_present = False
280 if (lhs.equals(rhs) != false)
281 throw new RuntimeException("Failure");
282
283 lhs = new JavaTestHelper();
284 rhs = new JavaTestHelper();
285 lhs.opt_int = 1;
286 rhs.opt_int = 2;
287 lhs.setOpt_intIsSet(true);
288 // this_present = True
289 // that_present = False
290 if (lhs.equals(rhs) != false)
291 throw new RuntimeException("Failure");
292
293 lhs = new JavaTestHelper();
294 rhs = new JavaTestHelper();
295 lhs.opt_int = 1;
296 rhs.opt_int = 1;
297 lhs.setOpt_intIsSet(true);
298 rhs.setOpt_intIsSet(true);
299 // this_present = True
300 // that_present = True
301 if (lhs.equals(rhs) != true)
302 throw new RuntimeException("Failure");
303 if (lhs.hashCode() != rhs.hashCode())
304 throw new RuntimeException("Failure");
305
306 lhs = new JavaTestHelper();
307 rhs = new JavaTestHelper();
308 lhs.opt_int = 1;
309 rhs.opt_int = 2;
310 lhs.setOpt_intIsSet(true);
311 rhs.setOpt_intIsSet(true);
312 // this_present = True
313 // that_present = True
314 if (lhs.equals(rhs) != false)
315 throw new RuntimeException("Failure");
316
317 lhs = new JavaTestHelper();
318 rhs = new JavaTestHelper();
319 lhs.req_obj = "foo";
320 rhs.req_obj = "foo";
321 lhs.req_obj = null;
322 rhs.req_obj = null;
323 // this_present = False
324 // that_present = False
325 if (lhs.equals(rhs) != true)
326 throw new RuntimeException("Failure");
327 if (lhs.hashCode() != rhs.hashCode())
328 throw new RuntimeException("Failure");
329
330 lhs = new JavaTestHelper();
331 rhs = new JavaTestHelper();
332 lhs.req_obj = "foo";
333 rhs.req_obj = "bar";
334 lhs.req_obj = null;
335 rhs.req_obj = null;
336 // this_present = False
337 // that_present = False
338 if (lhs.equals(rhs) != true)
339 throw new RuntimeException("Failure");
340 if (lhs.hashCode() != rhs.hashCode())
341 throw new RuntimeException("Failure");
342
343 lhs = new JavaTestHelper();
344 rhs = new JavaTestHelper();
345 lhs.req_obj = "foo";
346 rhs.req_obj = "foo";
347 lhs.req_obj = null;
348 // this_present = False
349 // that_present = True
350 if (lhs.equals(rhs) != false)
351 throw new RuntimeException("Failure");
352
353 lhs = new JavaTestHelper();
354 rhs = new JavaTestHelper();
355 lhs.req_obj = "foo";
356 rhs.req_obj = "bar";
357 lhs.req_obj = null;
358 // this_present = False
359 // that_present = True
360 if (lhs.equals(rhs) != false)
361 throw new RuntimeException("Failure");
362
363 lhs = new JavaTestHelper();
364 rhs = new JavaTestHelper();
365 lhs.req_obj = "foo";
366 rhs.req_obj = "foo";
367 rhs.req_obj = null;
368 // this_present = True
369 // that_present = False
370 if (lhs.equals(rhs) != false)
371 throw new RuntimeException("Failure");
372
373 lhs = new JavaTestHelper();
374 rhs = new JavaTestHelper();
375 lhs.req_obj = "foo";
376 rhs.req_obj = "bar";
377 rhs.req_obj = null;
378 // this_present = True
379 // that_present = False
380 if (lhs.equals(rhs) != false)
381 throw new RuntimeException("Failure");
382
383 lhs = new JavaTestHelper();
384 rhs = new JavaTestHelper();
385 lhs.req_obj = "foo";
386 rhs.req_obj = "foo";
387 // this_present = True
388 // that_present = True
389 if (lhs.equals(rhs) != true)
390 throw new RuntimeException("Failure");
391 if (lhs.hashCode() != rhs.hashCode())
392 throw new RuntimeException("Failure");
393
394 lhs = new JavaTestHelper();
395 rhs = new JavaTestHelper();
396 lhs.req_obj = "foo";
397 rhs.req_obj = "bar";
398 // this_present = True
399 // that_present = True
400 if (lhs.equals(rhs) != false)
401 throw new RuntimeException("Failure");
402
403 lhs = new JavaTestHelper();
404 rhs = new JavaTestHelper();
405 lhs.opt_obj = "foo";
406 rhs.opt_obj = "foo";
407 lhs.opt_obj = null;
408 rhs.opt_obj = null;
409 // this_present = False
410 // that_present = False
411 if (lhs.equals(rhs) != true)
412 throw new RuntimeException("Failure");
413 if (lhs.hashCode() != rhs.hashCode())
414 throw new RuntimeException("Failure");
415
416 lhs = new JavaTestHelper();
417 rhs = new JavaTestHelper();
418 lhs.opt_obj = "foo";
419 rhs.opt_obj = "bar";
420 lhs.opt_obj = null;
421 rhs.opt_obj = null;
422 // this_present = False
423 // that_present = False
424 if (lhs.equals(rhs) != true)
425 throw new RuntimeException("Failure");
426 if (lhs.hashCode() != rhs.hashCode())
427 throw new RuntimeException("Failure");
428
429 lhs = new JavaTestHelper();
430 rhs = new JavaTestHelper();
431 lhs.opt_obj = "foo";
432 rhs.opt_obj = "foo";
433 lhs.opt_obj = null;
434 // this_present = False
435 // that_present = True
436 if (lhs.equals(rhs) != false)
437 throw new RuntimeException("Failure");
438
439 lhs = new JavaTestHelper();
440 rhs = new JavaTestHelper();
441 lhs.opt_obj = "foo";
442 rhs.opt_obj = "bar";
443 lhs.opt_obj = null;
444 // this_present = False
445 // that_present = True
446 if (lhs.equals(rhs) != false)
447 throw new RuntimeException("Failure");
448
449 lhs = new JavaTestHelper();
450 rhs = new JavaTestHelper();
451 lhs.opt_obj = "foo";
452 rhs.opt_obj = "foo";
453 rhs.opt_obj = null;
454 // this_present = True
455 // that_present = False
456 if (lhs.equals(rhs) != false)
457 throw new RuntimeException("Failure");
458
459 lhs = new JavaTestHelper();
460 rhs = new JavaTestHelper();
461 lhs.opt_obj = "foo";
462 rhs.opt_obj = "bar";
463 rhs.opt_obj = null;
464 // this_present = True
465 // that_present = False
466 if (lhs.equals(rhs) != false)
467 throw new RuntimeException("Failure");
468
469 lhs = new JavaTestHelper();
470 rhs = new JavaTestHelper();
471 lhs.opt_obj = "foo";
472 rhs.opt_obj = "foo";
473 // this_present = True
474 // that_present = True
475 if (lhs.equals(rhs) != true)
476 throw new RuntimeException("Failure");
477 if (lhs.hashCode() != rhs.hashCode())
478 throw new RuntimeException("Failure");
479
480 lhs = new JavaTestHelper();
481 rhs = new JavaTestHelper();
482 lhs.opt_obj = "foo";
483 rhs.opt_obj = "bar";
484 // this_present = True
485 // that_present = True
486 if (lhs.equals(rhs) != false)
487 throw new RuntimeException("Failure");
488
489 lhs = new JavaTestHelper();
490 rhs = new JavaTestHelper();
491 lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
492 rhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
493 lhs.req_bin = null;
494 rhs.req_bin = null;
495 // this_present = False
496 // that_present = False
497 if (lhs.equals(rhs) != true)
498 throw new RuntimeException("Failure");
499 if (lhs.hashCode() != rhs.hashCode())
500 throw new RuntimeException("Failure");
501
502 lhs = new JavaTestHelper();
503 rhs = new JavaTestHelper();
504 lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
505 rhs.req_bin = ByteBuffer.wrap(new byte[]{3,4});
506 lhs.req_bin = null;
507 rhs.req_bin = null;
508 // this_present = False
509 // that_present = False
510 if (lhs.equals(rhs) != true)
511 throw new RuntimeException("Failure");
512 if (lhs.hashCode() != rhs.hashCode())
513 throw new RuntimeException("Failure");
514
515 lhs = new JavaTestHelper();
516 rhs = new JavaTestHelper();
517 lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
518 rhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
519 lhs.req_bin = null;
520 // this_present = False
521 // that_present = True
522 if (lhs.equals(rhs) != false)
523 throw new RuntimeException("Failure");
524
525 lhs = new JavaTestHelper();
526 rhs = new JavaTestHelper();
527 lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
528 rhs.req_bin = ByteBuffer.wrap(new byte[]{3,4});
529 lhs.req_bin = null;
530 // this_present = False
531 // that_present = True
532 if (lhs.equals(rhs) != false)
533 throw new RuntimeException("Failure");
534
535 lhs = new JavaTestHelper();
536 rhs = new JavaTestHelper();
537 lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
538 rhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
539 rhs.req_bin = null;
540 // this_present = True
541 // that_present = False
542 if (lhs.equals(rhs) != false)
543 throw new RuntimeException("Failure");
544
545 lhs = new JavaTestHelper();
546 rhs = new JavaTestHelper();
547 lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
548 rhs.req_bin = ByteBuffer.wrap(new byte[]{3,4});
549 rhs.req_bin = null;
550 // this_present = True
551 // that_present = False
552 if (lhs.equals(rhs) != false)
553 throw new RuntimeException("Failure");
554
555 lhs = new JavaTestHelper();
556 rhs = new JavaTestHelper();
557 lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
558 rhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
559 // this_present = True
560 // that_present = True
561 if (lhs.equals(rhs) != true)
562 throw new RuntimeException("Failure");
563 if (lhs.hashCode() != rhs.hashCode())
564 throw new RuntimeException("Failure");
565
566 lhs = new JavaTestHelper();
567 rhs = new JavaTestHelper();
568 lhs.req_bin = ByteBuffer.wrap(new byte[]{1,2});
569 rhs.req_bin = ByteBuffer.wrap(new byte[]{3,4});
570 // this_present = True
571 // that_present = True
572 if (lhs.equals(rhs) != false)
573 throw new RuntimeException("Failure");
574
575 lhs = new JavaTestHelper();
576 rhs = new JavaTestHelper();
577 lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
578 rhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
579 lhs.opt_bin = null;
580 rhs.opt_bin = null;
581 // this_present = False
582 // that_present = False
583 if (lhs.equals(rhs) != true)
584 throw new RuntimeException("Failure");
585 if (lhs.hashCode() != rhs.hashCode())
586 throw new RuntimeException("Failure");
587
588 lhs = new JavaTestHelper();
589 rhs = new JavaTestHelper();
590 lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
591 rhs.opt_bin = ByteBuffer.wrap(new byte[]{3,4});
592 lhs.opt_bin = null;
593 rhs.opt_bin = null;
594 // this_present = False
595 // that_present = False
596 if (lhs.equals(rhs) != true)
597 throw new RuntimeException("Failure");
598 if (lhs.hashCode() != rhs.hashCode())
599 throw new RuntimeException("Failure");
600
601 lhs = new JavaTestHelper();
602 rhs = new JavaTestHelper();
603 lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
604 rhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
605 lhs.opt_bin = null;
606 // this_present = False
607 // that_present = True
608 if (lhs.equals(rhs) != false)
609 throw new RuntimeException("Failure");
610
611 lhs = new JavaTestHelper();
612 rhs = new JavaTestHelper();
613 lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
614 rhs.opt_bin = ByteBuffer.wrap(new byte[]{3,4});
615 lhs.opt_bin = null;
616 // this_present = False
617 // that_present = True
618 if (lhs.equals(rhs) != false)
619 throw new RuntimeException("Failure");
620
621 lhs = new JavaTestHelper();
622 rhs = new JavaTestHelper();
623 lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
624 rhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
625 rhs.opt_bin = null;
626 // this_present = True
627 // that_present = False
628 if (lhs.equals(rhs) != false)
629 throw new RuntimeException("Failure");
630
631 lhs = new JavaTestHelper();
632 rhs = new JavaTestHelper();
633 lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
634 rhs.opt_bin = ByteBuffer.wrap(new byte[]{3,4});
635 rhs.opt_bin = null;
636 // this_present = True
637 // that_present = False
638 if (lhs.equals(rhs) != false)
639 throw new RuntimeException("Failure");
640
641 lhs = new JavaTestHelper();
642 rhs = new JavaTestHelper();
643 lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
644 rhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
645 // this_present = True
646 // that_present = True
647 if (lhs.equals(rhs) != true)
648 throw new RuntimeException("Failure");
649 if (lhs.hashCode() != rhs.hashCode())
650 throw new RuntimeException("Failure");
651
652 lhs = new JavaTestHelper();
653 rhs = new JavaTestHelper();
654 lhs.opt_bin = ByteBuffer.wrap(new byte[]{1,2});
655 rhs.opt_bin = ByteBuffer.wrap(new byte[]{3,4});
656 // this_present = True
657 // that_present = True
658 if (lhs.equals(rhs) != false)
659 throw new RuntimeException("Failure");
660
661 }
662}
663