Skip to content

Commit 9f77932

Browse files
stephenhinesAndroid (Google) Code Review
authored andcommitted
Merge "Add test for signed/unsigned char bug (conversion)."
2 parents ee31e56 + 47e432e commit 9f77932

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-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
@@ -68,6 +68,7 @@ public void init(RenderScriptGL rs, Resources res, int width, int height) {
6868
unitTests.add(new UT_constant(this, mRes, mCtx));
6969
unitTests.add(new UT_vector(this, mRes, mCtx));
7070
unitTests.add(new UT_array_init(this, mRes, mCtx));
71+
unitTests.add(new UT_convert(this, mRes, mCtx));
7172
unitTests.add(new UT_rsdebug(this, mRes, mCtx));
7273
unitTests.add(new UT_rstime(this, mRes, mCtx));
7374
unitTests.add(new UT_rstypes(this, mRes, mCtx));
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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_convert extends UnitTest {
24+
private Resources mRes;
25+
26+
protected UT_convert(RSTestCore rstc, Resources res, Context ctx) {
27+
super(rstc, "Convert", ctx);
28+
mRes = res;
29+
}
30+
31+
public void run() {
32+
RenderScript pRS = RenderScript.create(mCtx);
33+
ScriptC_convert s = new ScriptC_convert(pRS, mRes, R.raw.convert);
34+
pRS.setMessageHandler(mRsMessage);
35+
s.invoke_convert_test();
36+
pRS.finish();
37+
waitForMessage();
38+
pRS.destroy();
39+
}
40+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include "shared.rsh"
2+
3+
float4 f4 = { 2.0f, 4.0f, 6.0f, 8.0f };
4+
5+
char4 i8_4 = { -1, -2, -3, 4 };
6+
7+
static bool test_convert() {
8+
bool failed = false;
9+
10+
f4 = convert_float4(i8_4);
11+
_RS_ASSERT(f4.x == -1.0f);
12+
_RS_ASSERT(f4.y == -2.0f);
13+
_RS_ASSERT(f4.z == -3.0f);
14+
_RS_ASSERT(f4.w == 4.0f);
15+
16+
if (failed) {
17+
rsDebug("test_convert FAILED", 0);
18+
}
19+
else {
20+
rsDebug("test_convert PASSED", 0);
21+
}
22+
23+
return failed;
24+
}
25+
26+
void convert_test() {
27+
bool failed = false;
28+
failed |= test_convert();
29+
30+
if (failed) {
31+
rsSendToClientBlocking(RS_MSG_TEST_FAILED);
32+
}
33+
else {
34+
rsSendToClientBlocking(RS_MSG_TEST_PASSED);
35+
}
36+
}
37+

0 commit comments

Comments
 (0)