MCPcopy Create free account
hub / github.com/apache/pig / testBytesToFloat

Method testBytesToFloat

test/org/apache/pig/test/TestConversions.java:100–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

getBytesMethod · 0.65
bytesToFloatMethod · 0.65
getLoadCasterMethod · 0.65
assertEqualsMethod · 0.45

Tested by

no test coverage detected