The start of a test case.

This commit is contained in:
Oliver Burn 2010-09-30 17:09:25 +10:00
parent fead6ef45a
commit 5320065461
3 changed files with 217 additions and 18 deletions

View File

@ -34,21 +34,6 @@ import java.util.EnumMap;
*/
public final class MethodCountCheck extends Check
{
/** default maximum number of methods */
private static final int DEFAULT_MAX_METHODS = 999;
/** Maximum private methods. */
private int mMaxPrivate = DEFAULT_MAX_METHODS;
/** Maximum package methods. */
private int mMaxPackage = DEFAULT_MAX_METHODS;
/** Maximum protected methods. */
private int mMaxProtected = DEFAULT_MAX_METHODS;
/** Maximum public methods. */
private int mMaxPublic = DEFAULT_MAX_METHODS;
/** Maximum total number of methods. */
private int mMaxTotal = DEFAULT_MAX_METHODS;
/**
* Marker class used to collect data about the number of methods per
* class. Objects of this class are used on the Stack to count the
@ -80,9 +65,19 @@ public final class MethodCountCheck extends Check
}
};
/**
* To be able to trace also inner-classes correctly we need a stack.
*/
/** default maximum number of methods */
private static final int DEFAULT_MAX_METHODS = 999;
/** Maximum private methods. */
private int mMaxPrivate = DEFAULT_MAX_METHODS;
/** Maximum package methods. */
private int mMaxPackage = DEFAULT_MAX_METHODS;
/** Maximum protected methods. */
private int mMaxProtected = DEFAULT_MAX_METHODS;
/** Maximum public methods. */
private int mMaxPublic = DEFAULT_MAX_METHODS;
/** Maximum total number of methods. */
private int mMaxTotal = DEFAULT_MAX_METHODS;
/** Maintains stack of counters, to support inner types. */
private FastStack<MethodCounter> mCounters =
new FastStack<MethodCounter>();

View File

@ -0,0 +1,191 @@
package com.puppycrawl.tools.checkstyle.checks.metrics;
public class MethodCountCheckInput {
/**
* Dummy inner class to check that the inner-classes methods are not counted
* for the outer class.
*/
public class PublicMethodsInnerclassInnerclass {
/**
* Dummy method doing nothing
*/
public void doNothing50() {
}
/**
* Dummy method doing nothing
*/
public void doNothing51() {
}
/**
* Dummy method doing nothing
*/
public void doNothing52() {
}
/**
* Dummy method doing nothing
*/
public void doNothing53() {
}
/**
* Dummy method doing nothing
*/
public void doNothing54() {
}
}
/**
* Dummy inner class to check that the inner-classes methods are not counted
* for the outer class.
*/
public interface PublicMethodsInnerInterface {
/**
* Dummy method doing nothing
*/
public void doNothing60();
/**
* Dummy method doing nothing
*/
public void doNothing61();
/**
* Dummy method doing nothing
*/
public void doNothing62();
/**
* Dummy method doing nothing
*/
public void doNothing63();
/**
* Dummy method doing nothing
*/
public void doNothing64();
}
/**
* Dummy method doing nothing
*/
public void doNothing00() {
}
/**
* Dummy method doing nothing
*/
public void doNothing01() {
}
/**
* Dummy method doing nothing
*/
public void doNothing02() {
}
/**
* Dummy method doing nothing
*/
public void doNothing03() {
}
/**
* Dummy method doing nothing
*/
public void doNothing04() {
}
/**
* Dummy method doing nothing
*/
protected void doNothing10() {
}
/**
* Dummy method doing nothing
*/
protected void doNothing11() {
}
/**
* Dummy method doing nothing
*/
protected void doNothing12() {
}
/**
* Dummy method doing nothing
*/
protected void doNothing13() {
}
/**
* Dummy method doing nothing
*/
protected void doNothing14() {
}
/**
* Dummy method doing nothing
*/
void doNothing20() {
}
/**
* Dummy method doing nothing
*/
void doNothing21() {
}
/**
* Dummy method doing nothing
*/
void doNothing22() {
}
/**
* Dummy method doing nothing
*/
void doNothing23() {
}
/**
* Dummy method doing nothing
*/
void doNothing24() {
}
/**
* Dummy method doing nothing
*/
private void doNothing30() {
}
/**
* Dummy method doing nothing
*/
private void doNothing31() {
}
/**
* Dummy method doing nothing
*/
private void doNothing32() {
}
/**
* Dummy method doing nothing
*/
private void doNothing33() {
}
/**
* Dummy method doing nothing
*/
private void doNothing34() {
}
}

View File

@ -0,0 +1,13 @@
package com.puppycrawl.tools.checkstyle.checks.metrics;
import org.junit.Test;
import static org.junit.Assert.*;
public class MethodCountCheckTest {
@Test
public void testSomeMethod() {
fail("Need to implement");
}
}