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