1/******************************************************************************* 2 * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * Evgeny Mandrikov - initial API and implementation 10 * 11 *******************************************************************************/ 12package org.jacoco.core.internal.analysis.filter; 13 14import org.jacoco.core.internal.instr.InstrSupport; 15import org.junit.Test; 16import org.objectweb.asm.Opcodes; 17import org.objectweb.asm.tree.AbstractInsnNode; 18import org.objectweb.asm.tree.MethodNode; 19 20import static org.junit.Assert.assertEquals; 21 22public class PrivateEmptyNoArgConstructorFilterTest implements IFilterOutput { 23 24 private final IFilter filter = new PrivateEmptyNoArgConstructorFilter(); 25 26 private AbstractInsnNode fromInclusive; 27 private AbstractInsnNode toInclusive; 28 29 @Test 30 public void test() { 31 final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, 32 Opcodes.ACC_PRIVATE, "<init>", "()V", null, null); 33 34 m.visitVarInsn(Opcodes.ALOAD, 0); 35 m.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", 36 "()V", false); 37 m.visitInsn(Opcodes.RETURN); 38 39 filter.filter("Foo", "java/lang/Object", m, this); 40 41 assertEquals(m.instructions.getFirst(), fromInclusive); 42 assertEquals(m.instructions.getLast(), toInclusive); 43 } 44 45 public void ignore(final AbstractInsnNode fromInclusive, 46 final AbstractInsnNode toInclusive) { 47 this.fromInclusive = fromInclusive; 48 this.toInclusive = toInclusive; 49 } 50 51} 52