Merge "Add test for signed/unsigned char bug (conversion)."

This commit is contained in:
Stephen Hines
2012-02-28 21:01:36 -08:00
committed by Android (Google) Code Review
3 changed files with 78 additions and 0 deletions

View File

@@ -68,6 +68,7 @@ public class RSTestCore {
unitTests.add(new UT_constant(this, mRes, mCtx));
unitTests.add(new UT_vector(this, mRes, mCtx));
unitTests.add(new UT_array_init(this, mRes, mCtx));
unitTests.add(new UT_convert(this, mRes, mCtx));
unitTests.add(new UT_rsdebug(this, mRes, mCtx));
unitTests.add(new UT_rstime(this, mRes, mCtx));
unitTests.add(new UT_rstypes(this, mRes, mCtx));

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.rs.test;
import android.content.Context;
import android.content.res.Resources;
import android.renderscript.*;
public class UT_convert extends UnitTest {
private Resources mRes;
protected UT_convert(RSTestCore rstc, Resources res, Context ctx) {
super(rstc, "Convert", ctx);
mRes = res;
}
public void run() {
RenderScript pRS = RenderScript.create(mCtx);
ScriptC_convert s = new ScriptC_convert(pRS, mRes, R.raw.convert);
pRS.setMessageHandler(mRsMessage);
s.invoke_convert_test();
pRS.finish();
waitForMessage();
pRS.destroy();
}
}

View File

@@ -0,0 +1,37 @@
#include "shared.rsh"
float4 f4 = { 2.0f, 4.0f, 6.0f, 8.0f };
char4 i8_4 = { -1, -2, -3, 4 };
static bool test_convert() {
bool failed = false;
f4 = convert_float4(i8_4);
_RS_ASSERT(f4.x == -1.0f);
_RS_ASSERT(f4.y == -2.0f);
_RS_ASSERT(f4.z == -3.0f);
_RS_ASSERT(f4.w == 4.0f);
if (failed) {
rsDebug("test_convert FAILED", 0);
}
else {
rsDebug("test_convert PASSED", 0);
}
return failed;
}
void convert_test() {
bool failed = false;
failed |= test_convert();
if (failed) {
rsSendToClientBlocking(RS_MSG_TEST_FAILED);
}
else {
rsSendToClientBlocking(RS_MSG_TEST_PASSED);
}
}