EMMA Coverage Report (generated Tue Dec 18 20:38:46 CET 2007)
[all classes][cz.vutbr.feec.packets.rtcp]

## COVERAGE SUMMARY FOR SOURCE FILE [SDESPacketTest.java]

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
SDESPacketTest.java | 100% (1/1) | 100% (5/5) | 98% (222/226) | 100% (41,8/42)

### COVERAGE BREAKDOWN BY CLASS AND METHOD

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
class SDESPacketTest | 100% (1/1) | 100% (5/5) | 98% (222/226) | 100% (41,8/42)
testSDESPacket (int, int): void |  | 100% (1/1) | 97% (140/144) | 99% (21,8/22)
<static initializer> |  | 100% (1/1) | 100% (5/5) | 100% (3/3)
SDESPacketTest (): void |  | 100% (1/1) | 100% (7/7) | 100% (2/2)
getSDESChunk (int, int): SDESChunk |  | 100% (1/1) | 100% (54/54) | 100% (12/12)
testSDESPacket (): void |  | 100% (1/1) | 100% (16/16) | 100% (4/4)

1 | package cz.vutbr.feec.packets.rtcp;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | import cz.vutbr.feec.packets.PacketGenerateException;
7 | import cz.vutbr.feec.packets.PacketParseException;
8 |
9 | public class SDESPacketTest {
10 |
11 | byte[] buffer = new byte[1500];
12 |
13 | private static int id = 0;
14 |
15 | private static char word = 'a';
16 |
17 | public SDESChunk getSDESChunk(int items, int length) {
18 | SDESChunk chunk = new SDESChunk();
19 | id++;
20 | chunk.setSSRC_CSRC(16843009 + id);
21 |
22 | SDESItem it = new SDESItem();
23 | for (int i = 0; i < items; i++) {
24 | it.setType(SDESItem.CNAME);
25 | String s = "";
26 | for (int j = 0; j < length; j++) {
27 | s += word;
28 | }
29 | it.setText(s);
30 | chunk.addItem(it);
31 | }
32 | return chunk;
33 | }
34 |
35 | @Test
36 | public void testSDESPacket() throws PacketGenerateException,
37 | PacketParseException {
38 |
39 | for (int i = 5; i < 30; i++) {
40 | testSDESPacket(0, i);
41 | testSDESPacket(5, i);
42 | }
43 | }
44 |
45 | public void testSDESPacket(int offset, int strlen)
46 | throws PacketGenerateException, PacketParseException {
47 |
48 | SDESPacket orig = new SDESPacket();
49 |
50 | orig.setVersion(2);
51 | orig.setPadding(1);
52 | orig.setPayloadtype(1);
53 | orig.setLength(150);
54 |
55 | for (int i = 0; i < 5; i++) {
56 | byte[] tmp = new byte[1000];
57 |
58 | SDESChunk ch = getSDESChunk(5, strlen);
59 | int length = ch.generate(tmp, offset);
60 | SDESChunk ch2 = new SDESChunk();
61 | int length2 = ch2.parse(tmp, offset, offset);
62 |
63 | Assert.assertTrue("OFF:"+offset+" STRLEN"+strlen,length == length2);
64 | Assert.assertTrue("Musi byt zarovnano na 4 byty", length % 4 == 0);
65 |
66 | orig.addChunk(ch);
67 | }
68 |
69 | int length = orig.generate(buffer, offset);
70 | SDESPacket gen = new SDESPacket();
71 | int length2 = gen.parse(buffer, offset, length);
72 |
73 | Assert.assertTrue("OFFSET:"+offset+"LEN:"+offset,length == length2);
74 | Assert.assertTrue("Musi byt zarovnano na 4 byty", length % 4 == 0);
75 |
76 | Assert.assertTrue("Do not match OFF:" + offset + " LEN:" + strlen
77 | + " \n" + orig + "\n" + gen, gen.equals(orig));
78 | }
79 |
80 | }

[all classes][cz.vutbr.feec.packets.rtcp]
EMMA 2.0.5312 EclEmma Fix 1 (C) Vladimir Roubtsov