• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_int;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.neg_int.d.T_neg_int_1;
22 import dot.junit.opcodes.neg_int.d.T_neg_int_2;
23 import dot.junit.opcodes.neg_int.d.T_neg_int_7;
24 
25 public class Test_neg_int extends DxTestCase {
26 
27     /**
28      * @title Argument = 1
29      */
testN1()30     public void testN1() {
31         T_neg_int_1 t = new T_neg_int_1();
32         assertEquals(-1, t.run(1));
33     }
34 
35     /**
36      * @title Argument = -1
37      */
testN2()38     public void testN2() {
39         T_neg_int_1 t = new T_neg_int_1();
40         assertEquals(1, t.run(-1));
41     }
42 
43     /**
44      * @title Argument = 32768
45      */
testN3()46     public void testN3() {
47         T_neg_int_1 t = new T_neg_int_1();
48         assertEquals(-32768, t.run(32768));
49     }
50 
51     /**
52      * @title Argument = 0
53      */
testN4()54     public void testN4() {
55         T_neg_int_1 t = new T_neg_int_1();
56         assertEquals(0, t.run(0));
57     }
58 
59     /**
60      * @title Check that -x == (~x + 1)
61      */
testN5()62     public void testN5() {
63         T_neg_int_2 t = new T_neg_int_2();
64         assertTrue(t.run(5));
65     }
66 
67     /**
68      * @title Argument = Integer.MAX_VALUE
69      */
testB1()70     public void testB1() {
71         T_neg_int_1 t = new T_neg_int_1();
72         assertEquals(0x80000001, t.run(Integer.MAX_VALUE));
73     }
74 
75     /**
76      * @title Argument = Integer.MIN_VALUE
77      */
testB2()78     public void testB2() {
79         T_neg_int_1 t = new T_neg_int_1();
80         assertEquals(Integer.MIN_VALUE, t.run(Integer.MIN_VALUE));
81     }
82 
83     /**
84      * @constraint A23
85      * @title  number of registers
86      */
testVFE1()87     public void testVFE1() {
88         load("dot.junit.opcodes.neg_int.d.T_neg_int_3", VerifyError.class);
89     }
90 
91 
92 
93     /**
94      *
95      * @constraint B1
96      * @title  type of argument - double
97      */
testVFE2()98     public void testVFE2() {
99         load("dot.junit.opcodes.neg_int.d.T_neg_int_4", VerifyError.class);
100     }
101 
102     /**
103      *
104      * @constraint B1
105      * @title  type of argument - long
106      */
testVFE3()107     public void testVFE3() {
108         load("dot.junit.opcodes.neg_int.d.T_neg_int_5", VerifyError.class);
109     }
110 
111     /**
112      *
113      * @constraint B1
114      * @title  type of argument - reference
115      */
testVFE4()116     public void testVFE4() {
117         load("dot.junit.opcodes.neg_int.d.T_neg_int_6", VerifyError.class);
118     }
119 
120     /**
121      * @constraint B1
122      * @title Types of arguments - float, int. The verifier checks that ints
123      * and floats are not used interchangeably.
124      */
testVFE5()125     public void testVFE5() {
126         load("dot.junit.opcodes.neg_int.d.T_neg_int_7", VerifyError.class);
127     }
128 }
129