Пример #1
0
  public static void testSetAndGetWith5Seqnos() {
    SeqnoRange range = new SeqnoRange(10, 15);
    System.out.println("range=" + print(range));

    assert range.size() == 6;
    assert range.getNumberOfMissingMessages() == 6;
    assert range.getNumberOfReceivedMessages() == 0;

    range.set(10);
    assert range.getNumberOfMissingMessages() == 5;
    assert range.getNumberOfReceivedMessages() == 1;

    assert range.get(10);

    range.set(13);
    assert range.size() == 6;
    assert range.getNumberOfMissingMessages() == 4;
    assert range.getNumberOfReceivedMessages() == 2;

    range.set(13);
    assert range.size() == 6;
    assert range.getNumberOfMissingMessages() == 4;
    assert range.getNumberOfReceivedMessages() == 2;

    System.out.println("range=" + print(range));

    Collection<Range> xmits = range.getMessagesToRetransmit();
    Collection<Range> cleared_bits = range.getBits(false);

    System.out.println("xmits = " + xmits);
    System.out.println("cleared_bits = " + cleared_bits);

    assert xmits.equals(cleared_bits);
  }
Пример #2
0
  public static void testSet() {
    SeqnoRange range = new SeqnoRange(10, 15);
    range.set(11, 12, 13, 14);
    System.out.println("range=" + print(range));
    assert range.size() == 6;
    assert range.getNumberOfReceivedMessages() == 4;
    assert range.getNumberOfMissingMessages() == 2;
    Collection<Range> xmits = range.getMessagesToRetransmit();
    assert xmits.size() == 2;
    Iterator<Range> it = xmits.iterator();
    Range r = it.next();
    assert r.low == 10 && r.high == 10;
    r = it.next();
    assert r.low == 15 && r.high == 15;

    range = new SeqnoRange(10, 15);
    range.set(10, 11, 12, 13, 14);
    System.out.println("range=" + print(range));
    assert range.size() == 6;
    assert range.getNumberOfReceivedMessages() == 5;
    assert range.getNumberOfMissingMessages() == 1;
    xmits = range.getMessagesToRetransmit();
    assert xmits.size() == 1;
    it = xmits.iterator();
    r = it.next();
    assert r.low == 15 && r.high == 15;

    range = new SeqnoRange(10, 15);
    range.set(11, 12, 13, 14, 15);
    System.out.println("range=" + print(range));
    assert range.size() == 6;
    assert range.getNumberOfReceivedMessages() == 5;
    assert range.getNumberOfMissingMessages() == 1;
    xmits = range.getMessagesToRetransmit();
    assert xmits.size() == 1;
    it = xmits.iterator();
    r = it.next();
    assert r.low == 10 && r.high == 10;

    range = new SeqnoRange(10, 15);
    range.set(10, 11, 12, 13, 14, 15);
    System.out.println("range=" + print(range));
    assert range.size() == 6;
    assert range.getNumberOfReceivedMessages() == 6;
    assert range.getNumberOfMissingMessages() == 0;
    xmits = range.getMessagesToRetransmit();
    assert xmits.isEmpty();

    range = new SeqnoRange(10, 15);
    range.set(11, 12, 14, 15);
    System.out.println("range=" + print(range));
    assert range.size() == 6;
    assert range.getNumberOfReceivedMessages() == 4;
    assert range.getNumberOfMissingMessages() == 2;
    xmits = range.getMessagesToRetransmit();
    assert xmits.size() == 2;
    it = xmits.iterator();
    r = it.next();
    assert r.low == 10 && r.high == 10;
    r = it.next();
    assert r.low == 13 && r.high == 13;

    range.set(13);
    assert range.getNumberOfReceivedMessages() == 5;
    assert range.getNumberOfMissingMessages() == 1;
    xmits = range.getMessagesToRetransmit();
    it = xmits.iterator();
    r = it.next();
    assert r.low == 10 && r.high == 10;

    range.set(10);
    System.out.println("range=" + print(range));
    assert range.getNumberOfReceivedMessages() == 6;
    assert range.getNumberOfMissingMessages() == 0;
    xmits = range.getMessagesToRetransmit();
    assert xmits.isEmpty();
  }