Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2015 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 public class Main {
     18   public Main() {
     19   }
     20 
     21   int testIntVReg(int a, int b, int c, int d, int e) {
     22     doNativeCallSetVReg();
     23     return a - b - c - d - e;
     24   }
     25 
     26   long testLongVReg(long a, long b, long c, long d, long e) {
     27     doNativeCallSetVReg();
     28     return a - b - c - d - e;
     29   }
     30 
     31   float testFloatVReg(float a, float b, float c, float d, float e) {
     32     doNativeCallSetVReg();
     33     return a - b - c - d - e;
     34   }
     35 
     36   double testDoubleVReg(double a, double b, double c, double d, double e) {
     37     doNativeCallSetVReg();
     38     return a - b - c - d - e;
     39   }
     40 
     41   native void doNativeCallSetVReg();
     42 
     43   static {
     44     System.loadLibrary("arttest");
     45   }
     46 
     47   public static void main(String[] args) {
     48     Main rm = new Main();
     49     int intExpected = 5 - 4 - 3 - 2 - 1;
     50     int intResult = rm.testIntVReg(0, 0, 0, 0, 0);
     51     if (intResult != intExpected) {
     52       throw new Error("Expected " + intExpected + ", got " + intResult);
     53     }
     54 
     55     long longExpected = Long.MAX_VALUE - 4 - 3 - 2 - 1;
     56     long longResult = rm.testLongVReg(0, 0, 0, 0, 0);
     57     if (longResult != longExpected) {
     58       throw new Error("Expected " + longExpected + ", got " + longResult);
     59     }
     60 
     61     float floatExpected = 5.0f - 4.0f - 3.0f - 2.0f - 1.0f;
     62     float floatResult = rm.testFloatVReg(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
     63     if (floatResult != floatExpected) {
     64       throw new Error("Expected " + floatExpected + ", got " + floatResult);
     65     }
     66 
     67     double doubleExpected = 5.0 - 4.0 - 3.0 - 2.0 - 1.0;
     68     double doubleResult = rm.testDoubleVReg(0.0, 0.0, 0.0, 0.0, 0.0);
     69     if (doubleResult != doubleExpected) {
     70       throw new Error("Expected " + doubleExpected + ", got " + doubleResult);
     71     }
     72   }
     73 }
     74