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.rem_double; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.rem_double.d.T_rem_double_1; 22 import dot.junit.opcodes.rem_double.d.T_rem_double_4; 23 24 public class Test_rem_double extends DxTestCase { 25 26 /** 27 * @title Arguments = 2.7d, 3.14d 28 */ testN1()29 public void testN1() { 30 T_rem_double_1 t = new T_rem_double_1(); 31 assertEquals(2.7d, t.run(2.7d, 3.14d)); 32 } 33 34 /** 35 * @title Dividend = 0 36 */ testN2()37 public void testN2() { 38 T_rem_double_1 t = new T_rem_double_1(); 39 assertEquals(0d, t.run(0, 3.14d)); 40 } 41 42 /** 43 * @title Dividend is negative 44 */ testN3()45 public void testN3() { 46 T_rem_double_1 t = new T_rem_double_1(); 47 assertEquals(-0.43999999999999995d, t.run(-3.14d, 2.7d)); 48 } 49 50 /** 51 * @title Arguments = Double.MAX_VALUE, Double.NaN 52 */ testB1()53 public void testB1() { 54 T_rem_double_1 t = new T_rem_double_1(); 55 assertEquals(Double.NaN, t.run(Double.MAX_VALUE, Double.NaN)); 56 } 57 58 /** 59 * @title Arguments = Double.POSITIVE_INFINITY, 60 * Double.NEGATIVE_INFINITY 61 */ testB2()62 public void testB2() { 63 T_rem_double_1 t = new T_rem_double_1(); 64 assertEquals(Double.NaN, t.run(Double.POSITIVE_INFINITY, 65 Double.NEGATIVE_INFINITY)); 66 } 67 68 /** 69 * @title Arguments = Double.POSITIVE_INFINITY, -2.7d 70 */ testB3()71 public void testB3() { 72 T_rem_double_1 t = new T_rem_double_1(); 73 assertEquals(Double.NaN, t.run(Double.POSITIVE_INFINITY, -2.7d)); 74 } 75 76 /** 77 * @title Arguments = -2.7d, Double.NEGATIVE_INFINITY 78 */ testB4()79 public void testB4() { 80 T_rem_double_1 t = new T_rem_double_1(); 81 assertEquals(-2.7d, t.run(-2.7d, Double.NEGATIVE_INFINITY)); 82 } 83 84 /** 85 * @title Arguments = 0, 0 86 */ testB5()87 public void testB5() { 88 T_rem_double_1 t = new T_rem_double_1(); 89 assertEquals(Double.NaN, t.run(0, 0)); 90 } 91 92 /** 93 * @title Arguments = 0, -2.7 94 */ testB6()95 public void testB6() { 96 T_rem_double_1 t = new T_rem_double_1(); 97 assertEquals(0d, t.run(0, -2.7d)); 98 } 99 100 /** 101 * @title Arguments = -2.7, 0 102 */ testB7()103 public void testB7() { 104 T_rem_double_1 t = new T_rem_double_1(); 105 assertEquals(Double.NaN, t.run(-2.7d, 0)); 106 } 107 108 /** 109 * @title Arguments = 1, Double.MAX_VALUE 110 */ testB8()111 public void testB8() { 112 T_rem_double_1 t = new T_rem_double_1(); 113 assertEquals(0d, t.run(1, Double.MIN_VALUE)); 114 } 115 116 /** 117 * @title Arguments = Double.MAX_VALUE, -1E-9d 118 */ testB9()119 public void testB9() { 120 T_rem_double_1 t = new T_rem_double_1(); 121 122 assertEquals(1.543905285031139E-10d, t.run(Double.MAX_VALUE, -1E-9d)); 123 } 124 125 /** 126 * @constraint A24 127 * @title number of registers 128 */ testVFE1()129 public void testVFE1() { 130 load("dot.junit.opcodes.rem_double.d.T_rem_double_2", VerifyError.class); 131 } 132 133 134 135 /** 136 * @constraint B1 137 * @title types of arguments - float, double 138 */ testVFE2()139 public void testVFE2() { 140 load("dot.junit.opcodes.rem_double.d.T_rem_double_3", VerifyError.class); 141 } 142 143 /** 144 * @constraint B1 145 * @title types of arguments - double, reference 146 */ testVFE3()147 public void testVFE3() { 148 load("dot.junit.opcodes.rem_double.d.T_rem_double_5", VerifyError.class); 149 } 150 151 /** 152 * @constraint B1 153 * @title types of arguments - double, int 154 */ testVFE4()155 public void testVFE4() { 156 load("dot.junit.opcodes.rem_double.d.T_rem_double_6", VerifyError.class); 157 } 158 159 /** 160 * @constraint B1 161 * @title Types of arguments - double, long. The verifier checks that longs 162 * and doubles are not used interchangeably. 163 */ testVFE5()164 public void testVFE5() { 165 load("dot.junit.opcodes.rem_double.d.T_rem_double_4", VerifyError.class); 166 } 167 } 168