1// This file is automatically generated from
2// frameworks/rs/tests/java_api/RSUnitTests/RSUnitTests.py
3/*
4 * Copyright (C) 2017 The Android Open Source Project
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *      http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#include "shared.rsh"
20
21// Testing primitive types
22float floatTest = 1.99f;
23double doubleTest = 2.05;
24char charTest = -8;
25short shortTest = -16;
26int intTest = -32;
27long longTest = 17179869184l; // 1 << 34
28long long longlongTest = 68719476736l; // 1 << 36
29
30uchar ucharTest = 8;
31ushort ushortTest = 16;
32uint uintTest = 32;
33ulong ulongTest = 4611686018427387904L;
34int64_t int64_tTest = -17179869184l; // - 1 << 34
35uint64_t uint64_tTest = 117179869184l;
36
37static bool test_primitive_types(uint32_t index) {
38    bool failed = false;
39    start();
40
41    _RS_ASSERT(floatTest == 2.99f);
42    _RS_ASSERT(doubleTest == 3.05);
43    _RS_ASSERT(charTest == -16);
44    _RS_ASSERT(shortTest == -32);
45    _RS_ASSERT(intTest == -64);
46    _RS_ASSERT(longTest == 17179869185l);
47    _RS_ASSERT(longlongTest == 68719476735l);
48
49    _RS_ASSERT(ucharTest == 8);
50    _RS_ASSERT(ushortTest == 16);
51    _RS_ASSERT(uintTest == 32);
52    _RS_ASSERT(ulongTest == 4611686018427387903L);
53    _RS_ASSERT(int64_tTest == -17179869184l);
54    _RS_ASSERT(uint64_tTest == 117179869185l);
55
56    float time = end(index);
57
58    if (failed) {
59        rsDebug("test_primitives FAILED", time);
60    }
61    else {
62        rsDebug("test_primitives PASSED", time);
63    }
64
65    return failed;
66}
67
68void primitives_test(uint32_t index, int test_num) {
69    bool failed = false;
70    failed |= test_primitive_types(index);
71
72    if (failed) {
73        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
74    }
75    else {
76        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
77    }
78}
79
80