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

Method testBytesToDouble

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

Source from the content-addressed store, hash-verified

123 }
124
125 @Test
126 public void testBytesToDouble() throws IOException
127 {
128 // valid doubles
129 String[] a = {"1", "-2.345", "12.12334567890123456", "1.02e12","-.23344", ""};
130 Double[] d = {1.0, -2.345, 12.12334567890123456, 1.02e12, -.23344};
131 for (int j = 0; j < d.length; j++) {
132 byte[] b = a[j].getBytes();
133 assertEquals(d[j], ps.getLoadCaster().bytesToDouble(b));
134 }
135
136 // invalid doubles
137 a = new String[]{"-0x1.1", "-23a.45", "This is a double", "", " "};
138 for (String s : a) {
139 byte[] b = s.getBytes();
140 Double dl = ps.getLoadCaster().bytesToDouble(b);
141 assertNull(dl);
142
143 }
144 }
145
146 @Test
147 public void testBytesToLong() throws IOException

Callers

nothing calls this directly

Calls 4

getBytesMethod · 0.65
bytesToDoubleMethod · 0.65
getLoadCasterMethod · 0.65
assertEqualsMethod · 0.45

Tested by

no test coverage detected