1/* 2 * Copyright (C) 2011 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 17package libcore.java.lang; 18 19public class ShortTest extends junit.framework.TestCase { 20 public void test_compare() throws Exception { 21 final short min = Short.MIN_VALUE; 22 final short zero = 0; 23 final short max = Short.MAX_VALUE; 24 assertTrue(Short.compare(max, max) == 0); 25 assertTrue(Short.compare(min, min) == 0); 26 assertTrue(Short.compare(zero, zero) == 0); 27 assertTrue(Short.compare(max, zero) > 0); 28 assertTrue(Short.compare(max, min) > 0); 29 assertTrue(Short.compare(zero, max) < 0); 30 assertTrue(Short.compare(zero, min) > 0); 31 assertTrue(Short.compare(min, zero) < 0); 32 assertTrue(Short.compare(min, max) < 0); 33 } 34 35 public void testStaticHashCode() { 36 assertEquals(Short.valueOf((short) 567).hashCode(), Short.hashCode((short) 567)); 37 } 38 39 public void testBYTES() { 40 assertEquals(2, Short.BYTES); 41 } 42} 43