1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.bcel;
21
22 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24
25 import java.io.ByteArrayOutputStream;
26 import java.io.DataOutputStream;
27 import java.io.IOException;
28
29 import org.apache.bcel.classfile.AnnotationEntry;
30 import org.apache.bcel.classfile.ElementValuePair;
31 import org.apache.bcel.classfile.SimpleElementValue;
32 import org.junit.jupiter.api.Test;
33
34
35
36
37 class AnnotationEntryTest {
38
39 @Test
40 void testAddElementNameValuePair() {
41 final AnnotationEntry annotationEntry = new AnnotationEntry(0, null, false);
42 annotationEntry.addElementNameValuePair(new ElementValuePair(0, new SimpleElementValue(0, 0, null), null));
43 assertEquals(1, annotationEntry.getNumElementValuePairs());
44 }
45
46 @Test
47 void testDump() throws IOException {
48 final ByteArrayOutputStream out = new ByteArrayOutputStream();
49 new AnnotationEntry(0, null, false).dump(new DataOutputStream(out));
50 assertArrayEquals(new byte[4], out.toByteArray());
51 }
52
53 @Test
54 void testGetElementValuePairs() {
55 assertEquals(0, new AnnotationEntry(0, null, false).getElementValuePairs().length);
56 }
57
58 @Test
59 void testGetNumElementValuePairs() {
60 assertEquals(0, new AnnotationEntry(0, null, false).getNumElementValuePairs());
61 }
62 }