| 1 | package cz.vutbr.feec.packets.rsi; |
| 2 | |
| 3 | import junit.framework.Assert; |
| 4 | |
| 5 | import org.junit.Test; |
| 6 | |
| 7 | import cz.vutbr.feec.packets.PacketException; |
| 8 | |
| 9 | public class StatisticsBlockTest extends SubReportBlock { |
| 10 | byte[] buf = new byte[100]; |
| 11 | |
| 12 | public void test1(int offset, StatisticsBlock g, StatisticsBlock r) throws PacketException { |
| 13 | |
| 14 | g.setMedianFractionLost(1 << 7); |
| 15 | g.setHighestCummulativeLost(1l << 23); |
| 16 | g.setMedianJitter(1l << 31); |
| 17 | |
| 18 | int pktLength = g.generate(buf, offset); |
| 19 | r.parse(buf, offset, pktLength); |
| 20 | |
| 21 | Assert.assertTrue(g.getHighestCummulativeLost() == r.getHighestCummulativeLost()); |
| 22 | Assert.assertTrue(g.getLength() == r.getLength()); |
| 23 | Assert.assertTrue(g.getLength() == 4*3); |
| 24 | Assert.assertTrue(g.getMedianFractionLost() == r.getMedianFractionLost()); |
| 25 | Assert.assertTrue(g.getMedianJitter() == r.getMedianJitter()); |
| 26 | } |
| 27 | |
| 28 | @Test |
| 29 | public void testAll() throws PacketException { |
| 30 | StatisticsBlock g = new StatisticsBlock(); |
| 31 | StatisticsBlock r = new StatisticsBlock(); |
| 32 | |
| 33 | test1(0, g, r); |
| 34 | test1(5, g, r); |
| 35 | } |
| 36 | } |