1 /* 2 * Copyright (C) 2008 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 package dot.junit; 18 19 public class DxAbstractMain { 20 assertEquals(int expected, int actual)21 static public void assertEquals(int expected, int actual) { 22 if (expected != actual) throw new RuntimeException("AssertionFailedError: not equals. Expected " + expected + " actual " + actual); 23 } 24 assertEquals(String message, int expected, int actual)25 static public void assertEquals(String message, int expected, int actual) { 26 if (expected != actual) throw new RuntimeException("AssertionFailedError: not equals: " + message + " Expected " + expected + " actual " + actual); 27 } 28 29 assertEquals(long expected, long actual)30 static public void assertEquals(long expected, long actual) { 31 if (expected != actual) throw new RuntimeException("AssertionFailedError: not equals. Expected " + expected + " actual " + actual); 32 } 33 assertEquals(double expected, double actual, double delta)34 static public void assertEquals(double expected, double actual, double delta) { 35 if(!(Math.abs(expected-actual) <= delta)) throw new RuntimeException("AssertionFailedError: not within delta"); 36 } 37 assertEquals(Object expected, Object actual)38 static public void assertEquals(Object expected, Object actual) { 39 if (expected == null && actual == null) 40 return; 41 if (expected != null && expected.equals(actual)) 42 return; 43 throw new RuntimeException("AssertionFailedError: not the same"); 44 } 45 assertTrue(boolean condition)46 static public void assertTrue(boolean condition) { 47 if (!condition) throw new RuntimeException("AssertionFailedError: condition was false"); 48 } 49 assertFalse(boolean condition)50 static public void assertFalse(boolean condition) { 51 if (condition) throw new RuntimeException("AssertionFailedError: condition was true"); 52 } 53 assertNotNull(Object object)54 static public void assertNotNull(Object object) { 55 if (object == null) throw new RuntimeException("AssertionFailedError: object was null"); 56 } 57 assertNull(Object object)58 static public void assertNull(Object object) { 59 if (object != null) throw new RuntimeException("AssertionFailedError: object was not null"); 60 } 61 fail(String message)62 static public void fail(String message) { 63 throw new RuntimeException("AssertionFailedError msg:"+message); 64 } 65 66 67 } 68