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 dxc.junit.opcodes.if_acmpne; 18 19 import dxc.junit.DxTestCase; 20 import dxc.junit.DxUtil; 21 import dxc.junit.opcodes.if_acmpne.jm.T_if_acmpne_1; 22 23 public class Test_if_acmpne extends DxTestCase { 24 25 /** 26 * @title normal test 27 */ 28 public void testN1() { 29 T_if_acmpne_1 t = new T_if_acmpne_1(); 30 String a = "a"; 31 String b = "b"; 32 /* 33 * Compare with 1234 to check that in case of failed comparison 34 * execution proceeds at the address following if_acmpeq instruction 35 */ 36 assertEquals(1234, t.run(a, b)); 37 } 38 39 /** 40 * @title normal test 41 */ 42 public void testN2() { 43 T_if_acmpne_1 t = new T_if_acmpne_1(); 44 String a = "a"; 45 assertEquals(1, t.run(a, a)); 46 } 47 48 /** 49 * @title Compare with null 50 */ 51 public void testB1() { 52 T_if_acmpne_1 t = new T_if_acmpne_1(); 53 String a = "a"; 54 assertEquals(1234, t.run(a, null)); 55 } 56 57 /** 58 * @constraint 4.8.2.1 59 * @title number of arguments 60 */ 61 public void testVFE1() { 62 try { 63 Class.forName("dxc.junit.opcodes.if_acmpne.jm.T_if_acmpne_2"); 64 fail("expected a verification exception"); 65 } catch (Throwable t) { 66 DxUtil.checkVerifyException(t); 67 } 68 } 69 70 /** 71 * @constraint 4.8.2.1 72 * @title types of arguments - reference, double 73 */ 74 public void testVFE2() { 75 try { 76 Class.forName("dxc.junit.opcodes.if_acmpne.jm.T_if_acmpne_3"); 77 fail("expected a verification exception"); 78 } catch (Throwable t) { 79 DxUtil.checkVerifyException(t); 80 } 81 } 82 83 /** 84 * @constraint 4.8.2.1 85 * @title types of arguments - reference, 86 * integer 87 */ 88 public void testVFE3() { 89 try { 90 Class.forName("dxc.junit.opcodes.if_acmpne.jm.T_if_acmpne_4"); 91 fail("expected a verification exception"); 92 } catch (Throwable t) { 93 DxUtil.checkVerifyException(t); 94 } 95 } 96 97 /** 98 * @constraint 4.8.1.7 99 * @title branch target shall be inside the 100 * method 101 */ 102 public void testVFE4() { 103 try { 104 Class.forName("dxc.junit.opcodes.if_acmpne.jm.T_if_acmpne_5"); 105 fail("expected a verification exception"); 106 } catch (Throwable t) { 107 DxUtil.checkVerifyException(t); 108 } 109 } 110 111 /** 112 * @constraint 4.8.1.7 113 * @title branch target shall not be "inside" wide 114 * instruction 115 */ 116 public void testVFE5() { 117 try { 118 Class.forName("dxc.junit.opcodes.if_acmpne.jm.T_if_acmpne_6"); 119 fail("expected a verification exception"); 120 } catch (Throwable t) { 121 DxUtil.checkVerifyException(t); 122 } 123 } 124 125 } 126