Bootstrap

java 如何写测试类_(五)如何写测试类

/*** A demostration of the class ArrayBag

*@authorAdministrator

**/

public classArrayBagDemo {public static voidmain(String[] args) {

String[] contentsOfBag= {"A", "A", "B", "A", "C", "A"};//Tests on an empty bag

BagInterface aBag = new ArrayBag<>(contentsOfBag.length);

System.out.println("Testing an initially empty bag:");

testIsEmpty(aBag,true);

String[] testStrings1= {"", "B"};

testFrequency(aBag, testStrings1);

testContains(aBag, testStrings1);

testRemove(aBag, testStrings1);//Adding strings

System.out.println("Adding " + contentsOfBag.length + " strings to an initially empty bag "

+ "with the capacity to hold more than " + contentsOfBag.length + " strings:");

testAdd(aBag

;