aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-04-16 23:22:17 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-04-16 23:22:17 +0000
commita1b1da70a8529afe40472f354256dd4c186deb0d (patch)
tree678dc88c26baa387e49d72558f732cda2834250b
parentdee31f00dbd48f56c1cf02dc389353c8bf55563b (diff)
parente74490b059b9139eb8db30aa06fcc1a28da5459d (diff)
downloadhidl-sdk-release.tar.gz
Snap for 11724015 from e74490b059b9139eb8db30aa06fcc1a28da5459d to sdk-releasesdk-release
Change-Id: Ida6c810eddad923dddf13c94f90a1184e29677d1
-rw-r--r--test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java b/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java
index ef305874..512a4120 100644
--- a/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java
+++ b/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java
@@ -137,6 +137,17 @@ public final class HidlTestJava {
ExpectTrue(!x);
}
+ private void ExpectWithin(double a, double b, double precision, String onError) {
+ if (Math.abs(a - b) < precision) {
+ return;
+ }
+ System.err.printf(
+ "Expected '%f' to be within '%f' of '%f'. %s\n", a, precision, b, onError);
+ Log.e(TAG,
+ "Expected '" + a + "' to be within '" + precision + "' of '" + b + "'. " + onError);
+ throw new RuntimeException();
+ }
+
private void Expect(String result, String s) {
if (result.equals(s)) {
return;
@@ -1097,6 +1108,35 @@ public final class HidlTestJava {
}
IBase.LotsOfPrimitiveArrays out = proxy.testArrays(in);
+
+ final double PRECISION = 0.00001f;
+
+ ExpectDeepEq(in.byte1, out.byte1);
+ ExpectDeepEq(in.byte2, out.byte2);
+ ExpectDeepEq(in.byte3, out.byte3);
+ ExpectDeepEq(in.boolean1, out.boolean1);
+ ExpectDeepEq(in.boolean2, out.boolean2);
+ ExpectDeepEq(in.boolean3, out.boolean3);
+ for (int i = 0; i < 128; ++i) {
+ ExpectWithin(in.double1[i], out.double1[i], PRECISION, String.format("i = %d", i));
+ }
+ for (int i = 0; i < 8; ++i) {
+ for (int j = 0; j < 128; ++j) {
+ ExpectWithin(in.double2[i][j], out.double2[i][j], PRECISION,
+ String.format("i = %d, j = %d", i, j));
+ }
+ }
+ for (int i = 0; i < 8; ++i) {
+ for (int j = 0; j < 16; ++j) {
+ for (int k = 0; k < 128; ++k) {
+ ExpectWithin(in.double3[i][j][k], out.double3[i][j][k], PRECISION,
+ String.format("i = %d, j = %d, k = %d", i, j, k));
+ }
+ }
+ }
+ ExpectDeepEq(in.double1, out.double1);
+ ExpectDeepEq(in.double2, out.double2);
+ ExpectDeepEq(in.double3, out.double3);
ExpectDeepEq(in, out);
}