public void test4() { try { long l = 5l; byte[] b = NumSummation.longToBytes(l); long l2 = NumSummation.bytesToLong(b); assertTrue(l == l2); } catch (Exception e) { assertTrue(false); } }
public void test5() { try { NumSummation ns = new NumSummation(); for (long l = -5l; l < 8l; l++) { ns.collect(new Value(NumSummation.longToBytes(l))); } long l = NumSummation.bytesToLong(ns.aggregate().get()); assertTrue("l was " + l, l == 13); ns.collect(new Value(NumSummation.longToBytes(Long.MAX_VALUE))); l = NumSummation.bytesToLong(ns.aggregate().get()); assertTrue("l was " + l, l == Long.MAX_VALUE); ns.collect(new Value(NumSummation.longToBytes(Long.MIN_VALUE))); l = NumSummation.bytesToLong(ns.aggregate().get()); assertTrue("l was " + l, l == -1); ns.collect(new Value(NumSummation.longToBytes(Long.MIN_VALUE))); l = NumSummation.bytesToLong(ns.aggregate().get()); assertTrue("l was " + l, l == Long.MIN_VALUE); ns.collect(new Value(NumSummation.longToBytes(Long.MIN_VALUE))); l = NumSummation.bytesToLong(ns.aggregate().get()); assertTrue("l was " + l, l == Long.MIN_VALUE); ns.reset(); l = NumSummation.bytesToLong(ns.aggregate().get()); assertTrue("l was " + l, l == 0); } catch (Exception e) { assertTrue(false); } }