Merge "Revert "Revert "Add proper CTS tests for array initialization."""
diff --git a/tests/src/android/renderscript/cts/array_init.rs b/tests/src/android/renderscript/cts/array_init.rs
new file mode 100644
index 0000000..842249a
--- /dev/null
+++ b/tests/src/android/renderscript/cts/array_init.rs
@@ -0,0 +1,58 @@
+#include "shared.rsh"
+
+// Testing constant array initialization
+float fa[4] = {1.0, 9.9999f};
+double da[2] = {7.0, 8.88888};
+char ca[4] = {'a', 7, 'b', 'c'};
+short sa[4] = {1, 1, 2, 3};
+int ia[4] = {5, 8};
+long la[2] = {13, 21};
+long long lla[4] = {34};
+bool ba[3] = {true, false};
+
+void array_init_test() {
+ bool failed = false;
+
+ _RS_ASSERT(fa[0] == 1.0);
+ _RS_ASSERT(fa[1] == 9.9999f);
+ _RS_ASSERT(fa[2] == 0);
+ _RS_ASSERT(fa[3] == 0);
+
+ _RS_ASSERT(da[0] == 7.0);
+ _RS_ASSERT(da[1] == 8.88888);
+
+ _RS_ASSERT(ca[0] == 'a');
+ _RS_ASSERT(ca[1] == 7);
+ _RS_ASSERT(ca[2] == 'b');
+ _RS_ASSERT(ca[3] == 'c');
+
+ _RS_ASSERT(sa[0] == 1);
+ _RS_ASSERT(sa[1] == 1);
+ _RS_ASSERT(sa[2] == 2);
+ _RS_ASSERT(sa[3] == 3);
+
+ _RS_ASSERT(ia[0] == 5);
+ _RS_ASSERT(ia[1] == 8);
+ _RS_ASSERT(ia[2] == 0);
+ _RS_ASSERT(ia[3] == 0);
+
+ _RS_ASSERT(la[0] == 13);
+ _RS_ASSERT(la[1] == 21);
+
+ _RS_ASSERT(lla[0] == 34);
+ _RS_ASSERT(lla[1] == 0);
+ _RS_ASSERT(lla[2] == 0);
+ _RS_ASSERT(lla[3] == 0);
+
+ _RS_ASSERT(ba[0] == true);
+ _RS_ASSERT(ba[1] == false);
+ _RS_ASSERT(ba[2] == false);
+
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
index 22ceb8b..08a9428 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
@@ -324,6 +324,74 @@
checkForErrors();
}
+ private void checkInit(ScriptC_array_init s) {
+ float[] fa = s.get_fa();
+ assertTrue(fa[0] == 1.0);
+ assertTrue(fa[1] == 9.9999f);
+ assertTrue(fa[2] == 0);
+ assertTrue(fa[3] == 0);
+ assertTrue(fa.length == 4);
+
+ double[] da = s.get_da();
+ assertTrue(da[0] == 7.0);
+ assertTrue(da[1] == 8.88888);
+ assertTrue(da.length == 2);
+
+ byte[] ca = s.get_ca();
+ assertTrue(ca[0] == 'a');
+ assertTrue(ca[1] == 7);
+ assertTrue(ca[2] == 'b');
+ assertTrue(ca[3] == 'c');
+ assertTrue(ca.length == 4);
+
+ short[] sa = s.get_sa();
+ assertTrue(sa[0] == 1);
+ assertTrue(sa[1] == 1);
+ assertTrue(sa[2] == 2);
+ assertTrue(sa[3] == 3);
+ assertTrue(sa.length == 4);
+
+ int[] ia = s.get_ia();
+ assertTrue(ia[0] == 5);
+ assertTrue(ia[1] == 8);
+ assertTrue(ia[2] == 0);
+ assertTrue(ia[3] == 0);
+ assertTrue(ia.length == 4);
+
+ long[] la = s.get_la();
+ assertTrue(la[0] == 13);
+ assertTrue(la[1] == 21);
+ assertTrue(la.length == 2);
+
+ long[] lla = s.get_lla();
+ assertTrue(lla[0] == 34);
+ assertTrue(lla[1] == 0);
+ assertTrue(lla[2] == 0);
+ assertTrue(lla[3] == 0);
+ assertTrue(lla.length == 4);
+
+ boolean[] ba = s.get_ba();
+ assertTrue(ba[0] == true);
+ assertTrue(ba[1] == false);
+ assertTrue(ba[2] == false);
+ assertTrue(ba.length == 3);
+ }
+
+ /**
+ * Test array initialization.
+ */
+ public void testArrayInit() {
+ ScriptC_array_init t = new ScriptC_array_init(mRS,
+ mRes,
+ R.raw.array_init);
+
+ checkInit(t);
+ t.invoke_array_init_test();
+ mRS.finish();
+ waitForMessage();
+ checkForErrors();
+ }
+
/**
* Test utility functions.
*/