View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   https://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.bcel;
21  
22  import static org.junit.jupiter.api.Assertions.assertEquals;
23  
24  import org.apache.bcel.classfile.JavaClass;
25  import org.junit.jupiter.api.Test;
26  
27  class CounterVisitorTest extends AbstractCounterVisitorTest {
28      @Override
29      protected JavaClass getTestClass() throws ClassNotFoundException {
30          return getTestJavaClass(PACKAGE_BASE_NAME + ".data.MarkedType");
31      }
32  
33      @Test
34      void testAnnotationDefaultCount() {
35          assertEquals(0, getVisitor().annotationDefaultCount, "annotationDefaultCount");
36      }
37  
38      @Test
39      void testAnnotationEntryCount() {
40          assertEquals(2, getVisitor().annotationEntryCount, "annotationEntryCount");
41      }
42  
43      @Test
44      void testAnnotationsCount() {
45          assertEquals(2, getVisitor().annotationCount, "annotationCount");
46      }
47  
48      @Test
49      void testCodeCount() {
50          assertEquals(1, getVisitor().codeCount, "codeCount");
51      }
52  
53      @Test
54      void testCodeExceptionCount() {
55          assertEquals(0, getVisitor().codeExceptionCount, "codeExceptionCount");
56      }
57  
58      @Test
59      void testConstantClassCount() {
60          assertEquals(2, getVisitor().constantClassCount, "constantClassCount");
61      }
62  
63      @Test
64      void testConstantDoubleCount() {
65          assertEquals(0, getVisitor().constantDoubleCount, "constantDoubleCount");
66      }
67  
68      @Test
69      void testConstantFieldrefCount() {
70          assertEquals(0, getVisitor().constantFieldrefCount, "constantFieldrefCount");
71      }
72  
73      @Test
74      void testConstantFloatCount() {
75          assertEquals(0, getVisitor().constantFloatCount, "constantFloatCount");
76      }
77  
78      @Test
79      void testConstantIntegerCount() {
80          assertEquals(0, getVisitor().constantIntegerCount, "constantIntegerCount");
81      }
82  
83      @Test
84      void testConstantInterfaceMethodrefCount() {
85          assertEquals(0, getVisitor().constantInterfaceMethodrefCount, "constantInterfaceMethodrefCount");
86      }
87  
88      @Test
89      void testConstantLongCount() {
90          assertEquals(0, getVisitor().constantLongCount, "constantLongCount");
91      }
92  
93      @Test
94      void testConstantMethodrefCount() {
95          assertEquals(1, getVisitor().constantMethodrefCount, "constantMethodrefCount");
96      }
97  
98      @Test
99      void testConstantNameAndTypeCount() {
100         assertEquals(1, getVisitor().constantNameAndTypeCount, "constantNameAndTypeCount");
101     }
102 
103     @Test
104     void testConstantPoolCount() {
105         assertEquals(1, getVisitor().constantPoolCount, "constantPoolCount");
106     }
107 
108     @Test
109     void testConstantStringCount() {
110         assertEquals(0, getVisitor().constantStringCount, "constantStringCount");
111     }
112 
113     @Test
114     void testConstantValueCount() {
115         assertEquals(0, getVisitor().constantValueCount, "constantValueCount");
116     }
117 
118     @Test
119     void testDeprecatedCount() {
120         assertEquals(0, getVisitor().deprecatedCount, "deprecatedCount");
121     }
122 
123     @Test
124     void testEnclosingMethodCount() {
125         assertEquals(0, getVisitor().enclosingMethodCount, "enclosingMethodCount");
126     }
127 
128     @Test
129     void testExceptionTableCount() {
130         assertEquals(0, getVisitor().exceptionTableCount, "exceptionTableCount");
131     }
132 
133     @Test
134     void testFieldCount() {
135         assertEquals(0, getVisitor().fieldCount, "fieldCount");
136     }
137 
138     @Test
139     void testInnerClassCount() {
140         assertEquals(0, getVisitor().innerClassCount, "innerClassCount");
141     }
142 
143     @Test
144     void testInnerClassesCount() {
145         assertEquals(0, getVisitor().innerClassesCount, "innerClassesCount");
146     }
147 
148     @Test
149     void testJavaClassCount() {
150         assertEquals(1, getVisitor().javaClassCount, "javaClassCount");
151     }
152 
153     @Test
154     void testLineNumberCount() {
155         assertEquals(1, getVisitor().lineNumberCount, "lineNumberCount");
156     }
157 
158     @Test
159     void testLineNumberTableCount() {
160         assertEquals(1, getVisitor().lineNumberTableCount, "lineNumberTableCount");
161     }
162 
163     @Test
164     void testLocalVariableCount() {
165         assertEquals(1, getVisitor().localVariableCount, "localVariableCount");
166     }
167 
168     @Test
169     void testLocalVariableTableCount() {
170         assertEquals(1, getVisitor().localVariableTableCount, "localVariableTableCount");
171     }
172 
173     @Test
174     void testLocalVariableTypeTableCount() {
175         assertEquals(0, getVisitor().localVariableTypeTableCount, "localVariableTypeTableCount");
176     }
177 
178     @Test
179     void testMethodCount() {
180         assertEquals(1, getVisitor().methodCount, "methodCount");
181     }
182 
183     @Test
184     void testParameterAnnotationCount() {
185         assertEquals(0, getVisitor().parameterAnnotationCount, "parameterAnnotationCount");
186     }
187 
188     @Test
189     void testRecordCount() {
190         assertEquals(0, getVisitor().recordCount, "recordCount");
191     }
192 
193     @Test
194     void testSignatureCount() {
195         assertEquals(0, getVisitor().signatureAnnotationCount, "signatureAnnotationCount");
196     }
197 
198     @Test
199     void testSourceFileCount() {
200         assertEquals(1, getVisitor().sourceFileCount, "sourceFileCount");
201     }
202 
203     @Test
204     void testStackMapCount() {
205         assertEquals(0, getVisitor().stackMapCount, "stackMapCount");
206     }
207 
208     @Test
209     void testStackMapEntryCount() {
210         assertEquals(0, getVisitor().stackMapEntryCount, "stackMapEntryCount");
211     }
212 
213     @Test
214     void testStackMapTypeCount() {
215         assertEquals(0, getVisitor().stackMapTypeCount, "stackMapTypeCount");
216     }
217 
218     @Test
219     void testSyntheticCount() {
220         assertEquals(0, getVisitor().syntheticCount, "syntheticCount");
221     }
222 
223     @Test
224     void testUnknownCount() {
225         assertEquals(0, getVisitor().unknownCount, "unknownCount");
226     }
227 }