• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 import java.util.Objects;
18 
19 abstract class TestBase {
assertTrue(boolean value)20     static void assertTrue(boolean value) {
21         if (!value) {
22             throw new AssertionError("assertTrue value: " + value);
23         }
24     }
25 
assertEquals(byte b1, byte b2)26     static void assertEquals(byte b1, byte b2) {
27         if (b1 == b2) {
28             return;
29         }
30         throw new AssertionError("assertEquals b1: " + b1 + ", b2: " + b2);
31     }
32 
assertEquals(char c1, char c2)33     static void assertEquals(char c1, char c2) {
34         if (c1 == c2) {
35             return;
36         }
37         throw new AssertionError("assertEquals c1: " + c1 + ", c2: " + c2);
38     }
39 
assertEquals(short s1, short s2)40     static void assertEquals(short s1, short s2) {
41         if (s1 == s2) {
42             return;
43         }
44         throw new AssertionError("assertEquals s1: " + s1 + ", s2: " + s2);
45     }
46 
assertEquals(int i1, int i2)47     static void assertEquals(int i1, int i2) {
48         if (i1 == i2) {
49             return;
50         }
51         throw new AssertionError("assertEquals i1: " + i1 + ", i2: " + i2);
52     }
53 
assertEquals(long l1, long l2)54     static void assertEquals(long l1, long l2) {
55         if (l1 == l2) {
56             return;
57         }
58         throw new AssertionError("assertEquals l1: " + l1 + ", l2: " + l2);
59     }
60 
assertEquals(float f1, float f2)61     static void assertEquals(float f1, float f2) {
62         if (f1 == f2) {
63             return;
64         }
65         throw new AssertionError("assertEquals f1: " + f1 + ", f2: " + f2);
66     }
67 
assertEquals(double d1, double d2)68     static void assertEquals(double d1, double d2) {
69         if (d1 == d2) {
70             return;
71         }
72         throw new AssertionError("assertEquals d1: " + d1 + ", d2: " + d2);
73     }
74 
assertEquals(Object o, Object p)75     static void assertEquals(Object o, Object p) {
76         if (!Objects.equals(o, p)) {
77             throw new AssertionError("assertEquals: o1: " + o + ", o2: " + p);
78         }
79     }
80 
assertNotEquals(Object o, Object p)81     static void assertNotEquals(Object o, Object p) {
82         if (Objects.equals(o, p)) {
83             throw new AssertionError("assertNotEquals: o1: " + o + ", o2: " + p);
84         }
85     }
86 
assertNotReached()87     static void assertNotReached() {
88         throw new AssertionError("Unreachable");
89     }
90 
fail()91     static void fail() {
92         System.out.println("fail");
93         Thread.dumpStack();
94     }
95 }
96