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#include "shared.rsh" 18 19// Testing primitive types 20float floatTest = 1.99f; 21double doubleTest = 2.05; 22char charTest = -8; 23short shortTest = -16; 24int intTest = -32; 25long longTest = 17179869184l; // 1 << 34 26long long longlongTest = 68719476736l; // 1 << 36 27 28uchar ucharTest = 8; 29ushort ushortTest = 16; 30uint uintTest = 32; 31ulong ulongTest = 4611686018427387904L; 32int64_t int64_tTest = -17179869184l; // - 1 << 34 33uint64_t uint64_tTest = 117179869184l; 34 35static bool test_primitive_types(uint32_t index) { 36 bool failed = false; 37 start(); 38 39 _RS_ASSERT(floatTest == 2.99f); 40 _RS_ASSERT(doubleTest == 3.05); 41 _RS_ASSERT(charTest == -16); 42 _RS_ASSERT(shortTest == -32); 43 _RS_ASSERT(intTest == -64); 44 _RS_ASSERT(longTest == 17179869185l); 45 _RS_ASSERT(longlongTest == 68719476735l); 46 47 _RS_ASSERT(ucharTest == 8); 48 _RS_ASSERT(ushortTest == 16); 49 _RS_ASSERT(uintTest == 32); 50 _RS_ASSERT(ulongTest == 4611686018427387903L); 51 _RS_ASSERT(int64_tTest == -17179869184l); 52 _RS_ASSERT(uint64_tTest == 117179869185l); 53 54 float time = end(index); 55 56 if (failed) { 57 rsDebug("test_primitives FAILED", time); 58 } 59 else { 60 rsDebug("test_primitives PASSED", time); 61 } 62 63 return failed; 64} 65 66void primitives_test(uint32_t index, int test_num) { 67 bool failed = false; 68 failed |= test_primitive_types(index); 69 70 if (failed) { 71 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 72 } 73 else { 74 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 75 } 76} 77 78