1 /* 2 * Copyright (C) 2017 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 com.android.rs.unittest; 18 19 import android.content.Context; 20 import android.renderscript.RenderScript; 21 22 public class UT_primitives extends UnitTest { 23 24 public UT_primitives(Context ctx) { 25 super("Primitives", ctx); 26 } 27 28 private boolean initializeGlobals(ScriptC_primitives s) { 29 float pF = s.get_floatTest(); 30 if (pF != 1.99f) { 31 return false; 32 } 33 s.set_floatTest(2.99f); 34 35 double pD = s.get_doubleTest(); 36 if (pD != 2.05) { 37 return false; 38 } 39 s.set_doubleTest(3.05); 40 41 byte pC = s.get_charTest(); 42 if (pC != -8) { 43 return false; 44 } 45 s.set_charTest((byte) -16); 46 47 short pS = s.get_shortTest(); 48 if (pS != -16) { 49 return false; 50 } 51 s.set_shortTest((short) -32); 52 53 int pI = s.get_intTest(); 54 if (pI != -32) { 55 return false; 56 } 57 s.set_intTest(-64); 58 59 long pL = s.get_longTest(); 60 if (pL != 17179869184l) { 61 return false; 62 } 63 s.set_longTest(17179869185l); 64 65 long puL = s.get_ulongTest(); 66 if (puL != 4611686018427387904L) { 67 return false; 68 } 69 s.set_ulongTest(4611686018427387903L); 70 71 72 long pLL = s.get_longlongTest(); 73 if (pLL != 68719476736L) { 74 return false; 75 } 76 s.set_longlongTest(68719476735L); 77 78 long pu64 = s.get_uint64_tTest(); 79 if (pu64 != 117179869184l) { 80 return false; 81 } 82 s.set_uint64_tTest(117179869185l); 83 84 return true; 85 } 86 87 public void run() { 88 RenderScript pRS = createRenderScript(true); 89 ScriptC_primitives s = new ScriptC_primitives(pRS); 90 if (!initializeGlobals(s)) { 91 failTest(); 92 } else { 93 s.invoke_primitives_test(0, 0); 94 pRS.finish(); 95 } 96 s.destroy(); 97 pRS.destroy(); 98 } 99 } 100