private static void checkInRange(Map<Seqno, Seqno> map, long seqno, long from, long to) { Seqno val = map.get(new Seqno(seqno, true)); System.out.println("seqno=" + seqno + ", val = " + val); assert val != null; assert val.contains(seqno); assert val.getLow() == from; if (val instanceof SeqnoRange) assert ((SeqnoRange) val).getHigh() == to; }
private static String print(Seqno seqno) { StringBuilder sb = new StringBuilder(); sb.append(seqno.toString()); sb.append(", size= " + seqno.size()); if (seqno instanceof SeqnoRange) { sb.append( ", received=" + ((SeqnoRange) seqno).printBits(true) + " (" + seqno.getNumberOfReceivedMessages() + ")"); sb.append( ", missing=" + ((SeqnoRange) seqno).printBits(false) + " (" + seqno.getNumberOfMissingMessages() + ")"); } return sb.toString(); }
public static void testSetAndGetWith1Seqno() { Seqno range = new SeqnoRange(10, 10); assert range.getNumberOfMissingMessages() == 1; assert range.getNumberOfReceivedMessages() == 0; range.set(10); assert range.getNumberOfMissingMessages() == 0; assert range.getNumberOfReceivedMessages() == 1; assert range.get(10); range.clear(10); assert !range.get(10); assert range.getNumberOfMissingMessages() == 1; assert range.getNumberOfReceivedMessages() == 0; }