1 /* 2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package org.graalvm.compiler.replacements.test; 24 25 import org.junit.Test; 26 27 import org.graalvm.compiler.core.test.GraalCompilerTest; 28 29 /** 30 * Tests the unsigned operations on {@link Integer} and {@link Long}. 31 */ 32 public class UnsignedIntegerTest extends GraalCompilerTest { 33 34 public static int compareInteger(int a, int b) { 35 return Integer.compareUnsigned(a, b); 36 } 37 38 public static int divideInteger(int a, int b) { 39 return Integer.divideUnsigned(a, b); 40 } 41 42 public static int remainderInteger(int a, int b) { 43 return Integer.remainderUnsigned(a, b); 44 } 45 46 public static long compareLong(long a, long b) { 47 return Long.compareUnsigned(a, b); 48 } 49 50 public static long divideLong(long a, long b) { 51 return Long.divideUnsigned(a, b); 52 } 53 54 public static long remainderLong(long a, long b) { 55 return Long.remainderUnsigned(a, b); 56 } 57 58 private void testInteger(int a, int b) { 59 test("compareInteger", a, b); 60 test("divideInteger", a, b); 61 test("remainderInteger", a, b); 62 } 63 64 private void testLong(long a, long b) { 65 test("compareLong", a, b); 66 test("divideLong", a, b); 67 test("remainderLong", a, b); 68 } 69 70 @Test 71 public void testInteger() { 72 testInteger(5, 7); 73 testInteger(-3, -7); 74 testInteger(-3, 7); 75 testInteger(42, -5); 76 } 77 78 @Test 79 public void testLong() { 80 testLong(5, 7); 81 testLong(-3, -7); 82 testLong(-3, 7); 83 testLong(42, -5); 84 } 85 }