()
| 98 | } |
| 99 | |
| 100 | @Test |
| 101 | public void testBytesToFloat() throws IOException |
| 102 | { |
| 103 | // valid floats |
| 104 | String[] a = {"1", "-2.345", "12.12334567", "1.02e-2",".23344", |
| 105 | "23.1234567897", "12312.33", "002312.33", "1.02e-2", ""}; |
| 106 | |
| 107 | Float[] f = {1f, -2.345f, 12.12334567f, 1.02e-2f,.23344f, 23.1234567f, // 23.1234567f is a truncation case |
| 108 | 12312.33f, 2312.33f, 1.02e-2f }; |
| 109 | |
| 110 | for (int j = 0; j < f.length; j++) { |
| 111 | byte[] b = a[j].getBytes(); |
| 112 | assertEquals(f[j], ps.getLoadCaster().bytesToFloat(b)); |
| 113 | } |
| 114 | |
| 115 | // invalid floats |
| 116 | a = new String[]{"1a.1", "23.1234567a890123456", "This is a float", "", " "}; |
| 117 | for (String s : a) { |
| 118 | byte[] b = s.getBytes(); |
| 119 | Float fl = ps.getLoadCaster().bytesToFloat(b); |
| 120 | assertNull(fl); |
| 121 | |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | @Test |
| 126 | public void testBytesToDouble() throws IOException |
nothing calls this directly
no test coverage detected