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 constant array initialization 20float fa[4] = {1.0, 9.9999f}; 21double da[2] = {7.0, 8.88888}; 22char ca[4] = {'a', 7, 'b', 'c'}; 23short sa[4] = {1, 1, 2, 3}; 24int ia[4] = {5, 8}; 25long la[2] = {13, 21}; 26long long lla[4] = {34}; 27bool ba[3] = {true, false}; 28 29void array_init_test() { 30 bool failed = false; 31 32 _RS_ASSERT(fa[0] == 1.0); 33 _RS_ASSERT(fa[1] == 9.9999f); 34 _RS_ASSERT(fa[2] == 0); 35 _RS_ASSERT(fa[3] == 0); 36 37 _RS_ASSERT(da[0] == 7.0); 38 _RS_ASSERT(da[1] == 8.88888); 39 40 _RS_ASSERT(ca[0] == 'a'); 41 _RS_ASSERT(ca[1] == 7); 42 _RS_ASSERT(ca[2] == 'b'); 43 _RS_ASSERT(ca[3] == 'c'); 44 45 _RS_ASSERT(sa[0] == 1); 46 _RS_ASSERT(sa[1] == 1); 47 _RS_ASSERT(sa[2] == 2); 48 _RS_ASSERT(sa[3] == 3); 49 50 _RS_ASSERT(ia[0] == 5); 51 _RS_ASSERT(ia[1] == 8); 52 _RS_ASSERT(ia[2] == 0); 53 _RS_ASSERT(ia[3] == 0); 54 55 _RS_ASSERT(la[0] == 13); 56 _RS_ASSERT(la[1] == 21); 57 58 _RS_ASSERT(lla[0] == 34); 59 _RS_ASSERT(lla[1] == 0); 60 _RS_ASSERT(lla[2] == 0); 61 _RS_ASSERT(lla[3] == 0); 62 63 _RS_ASSERT(ba[0] == true); 64 _RS_ASSERT(ba[1] == false); 65 _RS_ASSERT(ba[2] == false); 66 67 if (failed) { 68 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 69 } 70 else { 71 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 72 } 73} 74 75