Restructure 580-fp16 tests into functions
There are a lot of tests present in main and their number is increasing.
Restructure these into functions to make it easier to find related tests.
Test: 580-fp16
Test: art/test/testrunner/run_build_test_target.py -j80 art-test-javac
Change-Id: I8d0e766d1ebab0cf6d6829300a1d09c4a2244365
diff --git a/test/580-fp16/src-art/Main.java b/test/580-fp16/src-art/Main.java
index a89e100..4aa8d55 100644
--- a/test/580-fp16/src-art/Main.java
+++ b/test/580-fp16/src-art/Main.java
@@ -39,8 +39,8 @@
}
}
- public static void main(String args[]) {
- // Test FP16 to float
+ public static void testHalfToFloatToHalfConversions(){
+ // Test FP16 to float and back to Half for all possible Short values
for (short h = Short.MIN_VALUE; h < Short.MAX_VALUE; h++) {
if (FP16.isNaN(h)) {
// NaN inputs are tested below.
@@ -48,7 +48,9 @@
}
assertEquals(h, FP16.toHalf(FP16.toFloat(h)));
}
+ }
+ public static void testToHalf(){
// These asserts check some known values and edge cases for FP16.toHalf
// and have been inspired by the cts HalfTest.
// Zeroes, NaN and infinities
@@ -88,6 +90,9 @@
assertEquals(0x7400, FP16.toHalf(16392.0f));
assertEquals(0x7800, FP16.toHalf(32784.0f));
+ }
+
+ public static void testToFloat(){
// FP16 SNaN/QNaN inputs to float
// The most significant bit of mantissa:
// V
@@ -106,4 +111,10 @@
assertEquals(0xffc00000, TestFP16ToFloatRawIntBits((short)(0xfe00))); // QNaN->QNaN
assertEquals(0xffffe000, TestFP16ToFloatRawIntBits((short)(0xffff))); // QNaN->QNaN
}
+
+ public static void main(String args[]) {
+ testHalfToFloatToHalfConversions();
+ testToHalf();
+ testToFloat();
+ }
}