Skip to content

Commit 330f676

Browse files
committed
Revert "Revert "Test initialization of constant array exports.""
This reverts commit 3be5c85.
1 parent 3be5c85 commit 330f676

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed

tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public void init(RenderScriptGL rs, Resources res, int width, int height) {
6767
unitTests.add(new UT_primitives(this, mRes, mCtx));
6868
unitTests.add(new UT_constant(this, mRes, mCtx));
6969
unitTests.add(new UT_vector(this, mRes, mCtx));
70+
unitTests.add(new UT_array_init(this, mRes, mCtx));
7071
unitTests.add(new UT_rsdebug(this, mRes, mCtx));
7172
unitTests.add(new UT_rstime(this, mRes, mCtx));
7273
unitTests.add(new UT_rstypes(this, mRes, mCtx));
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright (C) 2012 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.test;
18+
19+
import android.content.Context;
20+
import android.content.res.Resources;
21+
import android.renderscript.*;
22+
23+
public class UT_array_init extends UnitTest {
24+
private Resources mRes;
25+
26+
protected UT_array_init(RSTestCore rstc, Resources res, Context ctx) {
27+
super(rstc, "Array Init", ctx);
28+
mRes = res;
29+
}
30+
31+
private void checkInit(ScriptC_array_init s) {
32+
float[] fa = s.get_fa();
33+
_RS_ASSERT("fa[0] == 1.0", fa[0] == 1.0);
34+
_RS_ASSERT("fa[1] == 9.9999f", fa[1] == 9.9999f);
35+
_RS_ASSERT("fa[2] == 0", fa[2] == 0);
36+
_RS_ASSERT("fa[3] == 0", fa[3] == 0);
37+
_RS_ASSERT("fa.length == 4", fa.length == 4);
38+
39+
double[] da = s.get_da();
40+
_RS_ASSERT("da[0] == 7.0", da[0] == 7.0);
41+
_RS_ASSERT("da[1] == 8.88888", da[1] == 8.88888);
42+
_RS_ASSERT("da.length == 2", da.length == 2);
43+
44+
byte[] ca = s.get_ca();
45+
_RS_ASSERT("ca[0] == 'a'", ca[0] == 'a');
46+
_RS_ASSERT("ca[1] == 7", ca[1] == 7);
47+
_RS_ASSERT("ca[2] == 'b'", ca[2] == 'b');
48+
_RS_ASSERT("ca[3] == 'c'", ca[3] == 'c');
49+
_RS_ASSERT("ca.length == 4", ca.length == 4);
50+
51+
short[] sa = s.get_sa();
52+
_RS_ASSERT("sa[0] == 1", sa[0] == 1);
53+
_RS_ASSERT("sa[1] == 1", sa[1] == 1);
54+
_RS_ASSERT("sa[2] == 2", sa[2] == 2);
55+
_RS_ASSERT("sa[3] == 3", sa[3] == 3);
56+
_RS_ASSERT("sa.length == 4", sa.length == 4);
57+
58+
int[] ia = s.get_ia();
59+
_RS_ASSERT("ia[0] == 5", ia[0] == 5);
60+
_RS_ASSERT("ia[1] == 8", ia[1] == 8);
61+
_RS_ASSERT("ia[2] == 0", ia[2] == 0);
62+
_RS_ASSERT("ia[3] == 0", ia[3] == 0);
63+
_RS_ASSERT("ia.length == 4", ia.length == 4);
64+
65+
long[] la = s.get_la();
66+
_RS_ASSERT("la[0] == 13", la[0] == 13);
67+
_RS_ASSERT("la[1] == 21", la[1] == 21);
68+
_RS_ASSERT("la.length == 4", la.length == 2);
69+
70+
long[] lla = s.get_lla();
71+
_RS_ASSERT("lla[0] == 34", lla[0] == 34);
72+
_RS_ASSERT("lla[1] == 0", lla[1] == 0);
73+
_RS_ASSERT("lla[2] == 0", lla[2] == 0);
74+
_RS_ASSERT("lla[3] == 0", lla[3] == 0);
75+
_RS_ASSERT("lla.length == 4", lla.length == 4);
76+
77+
boolean[] ba = s.get_ba();
78+
_RS_ASSERT("ba[0] == true", ba[0] == true);
79+
_RS_ASSERT("ba[1] == false", ba[1] == false);
80+
_RS_ASSERT("ba[2] == false", ba[2] == false);
81+
_RS_ASSERT("ba.length == 3", ba.length == 3);
82+
}
83+
84+
public void run() {
85+
RenderScript pRS = RenderScript.create(mCtx);
86+
ScriptC_array_init s = new ScriptC_array_init(pRS, mRes, R.raw.array_init);
87+
pRS.setMessageHandler(mRsMessage);
88+
checkInit(s);
89+
s.invoke_array_init_test();
90+
pRS.finish();
91+
waitForMessage();
92+
pRS.destroy();
93+
passTest();
94+
}
95+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include "shared.rsh"
2+
3+
// Testing constant array initialization
4+
float fa[4] = {1.0, 9.9999f};
5+
double da[2] = {7.0, 8.88888};
6+
char ca[4] = {'a', 7, 'b', 'c'};
7+
short sa[4] = {1, 1, 2, 3};
8+
int ia[4] = {5, 8};
9+
long la[2] = {13, 21};
10+
long long lla[4] = {34};
11+
bool ba[3] = {true, false};
12+
13+
void array_init_test() {
14+
bool failed = false;
15+
16+
_RS_ASSERT(fa[0] == 1.0);
17+
_RS_ASSERT(fa[1] == 9.9999f);
18+
_RS_ASSERT(fa[2] == 0);
19+
_RS_ASSERT(fa[3] == 0);
20+
21+
_RS_ASSERT(da[0] == 7.0);
22+
_RS_ASSERT(da[1] == 8.88888);
23+
24+
_RS_ASSERT(ca[0] == 'a');
25+
_RS_ASSERT(ca[1] == 7);
26+
_RS_ASSERT(ca[2] == 'b');
27+
_RS_ASSERT(ca[3] == 'c');
28+
29+
_RS_ASSERT(sa[0] == 1);
30+
_RS_ASSERT(sa[1] == 1);
31+
_RS_ASSERT(sa[2] == 2);
32+
_RS_ASSERT(sa[3] == 3);
33+
34+
_RS_ASSERT(ia[0] == 5);
35+
_RS_ASSERT(ia[1] == 8);
36+
_RS_ASSERT(ia[2] == 0);
37+
_RS_ASSERT(ia[3] == 0);
38+
39+
_RS_ASSERT(la[0] == 13);
40+
_RS_ASSERT(la[1] == 21);
41+
42+
_RS_ASSERT(lla[0] == 34);
43+
_RS_ASSERT(lla[1] == 0);
44+
_RS_ASSERT(lla[2] == 0);
45+
_RS_ASSERT(lla[3] == 0);
46+
47+
_RS_ASSERT(ba[0] == true);
48+
_RS_ASSERT(ba[1] == false);
49+
_RS_ASSERT(ba[2] == false);
50+
51+
if (failed) {
52+
rsSendToClientBlocking(RS_MSG_TEST_FAILED);
53+
}
54+
else {
55+
rsSendToClientBlocking(RS_MSG_TEST_PASSED);
56+
}
57+
}
58+

0 commit comments

Comments
 (0)