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.opcodes.neg_long; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.neg_long.d.T_neg_long_1; 22 import dot.junit.opcodes.neg_long.d.T_neg_long_2; 23 import dot.junit.opcodes.neg_long.d.T_neg_long_4; 24 25 public class Test_neg_long extends DxTestCase { 26 27 /** 28 * @title Argument = 123123123272432432l 29 */ 30 public void testN1() { 31 T_neg_long_1 t = new T_neg_long_1(); 32 assertEquals(-123123123272432432l, t.run(123123123272432432l)); 33 } 34 35 /** 36 * @title Argument = 1 37 */ 38 public void testN2() { 39 T_neg_long_1 t = new T_neg_long_1(); 40 assertEquals(-1l, t.run(1l)); 41 } 42 43 /** 44 * @title Argument = -1 45 */ 46 public void testN3() { 47 T_neg_long_1 t = new T_neg_long_1(); 48 assertEquals(1l, t.run(-1l)); 49 } 50 51 /** 52 * @title Check that -x == (~x + 1) 53 */ 54 public void testN4() { 55 T_neg_long_2 t = new T_neg_long_2(); 56 assertTrue(t.run(15l)); 57 } 58 59 60 /** 61 * @title Argument = 0 62 */ 63 public void testB1() { 64 T_neg_long_1 t = new T_neg_long_1(); 65 assertEquals(0, t.run(0)); 66 } 67 68 /** 69 * @title Argument = Long.MAX_VALUE 70 */ 71 public void testB2() { 72 T_neg_long_1 t = new T_neg_long_1(); 73 assertEquals(-9223372036854775807L, t.run(Long.MAX_VALUE)); 74 } 75 76 /** 77 * @title Argument = Long.MIN_VALUE 78 */ 79 public void testB3() { 80 T_neg_long_1 t = new T_neg_long_1(); 81 assertEquals(-9223372036854775808L, t.run(Long.MIN_VALUE)); 82 } 83 84 /** 85 * @constraint A24 86 * @title number of registers 87 */ 88 public void testVFE1() { 89 try { 90 Class.forName("dot.junit.opcodes.neg_long.d.T_neg_long_3"); 91 fail("expected a verification exception"); 92 } catch (Throwable t) { 93 DxUtil.checkVerifyException(t); 94 } 95 } 96 97 98 /** 99 * 100 * @constraint B1 101 * @title type of argument - int 102 */ 103 public void testVFE2() { 104 try { 105 Class.forName("dot.junit.opcodes.neg_long.d.T_neg_long_5"); 106 fail("expected a verification exception"); 107 } catch (Throwable t) { 108 DxUtil.checkVerifyException(t); 109 } 110 } 111 112 /** 113 * 114 * @constraint B1 115 * @title type of argument - float 116 */ 117 public void testVFE3() { 118 try { 119 Class.forName("dot.junit.opcodes.neg_long.d.T_neg_long_6"); 120 fail("expected a verification exception"); 121 } catch (Throwable t) { 122 DxUtil.checkVerifyException(t); 123 } 124 } 125 126 /** 127 * 128 * @constraint B1 129 * @title type of argument - reference 130 */ 131 public void testVFE4() { 132 try { 133 Class.forName("dot.junit.opcodes.neg_long.d.T_neg_long_7"); 134 fail("expected a verification exception"); 135 } catch (Throwable t) { 136 DxUtil.checkVerifyException(t); 137 } 138 } 139 140 /** 141 * @constraint B1 142 * @title Types of arguments - long, double. The verifier checks that longs 143 * and doubles are not used interchangeably. 144 */ 145 public void testVFE5() { 146 try { 147 Class.forName("dot.junit.opcodes.neg_long.d.T_neg_long_4"); 148 fail("expected a verification exception"); 149 } catch (Throwable t) { 150 DxUtil.checkVerifyException(t); 151 } 152 } 153 } 154