intermediate/DefiniteNumericCollectionTest

From ggc

Jump to: navigation, search

01 package intermediate;
02 
03 
04 import java.util.ArrayList;
05 
06 /**
07  * This class provides the shell for testing
08  * an implementation of the DefiniteNumericColleciton.
09  @author Jam Jenkins
10  *
11  */
12 public abstract class DefiniteNumericCollectionTest
13 {
14   /**the description of the tests passed*/
15   protected ArrayList<String> passed;
16   /**the description of the tests failed*/
17   protected ArrayList<String> failed;
18 
19   /**makes the test*/
20   public DefiniteNumericCollectionTest()
21   {
22     passed=new ArrayList<String>();
23     failed=new ArrayList<String>();
24   }
25 
26   /**
27    this method should run tests and add
28    * to the passed and failed ArrayList
29    * collections the names of those tests
30    * that pass and fail
31    */
32   public abstract void runTests(DefiniteNumericCollection collection);
33 
34   /**
35    * gets the description of the tests
36    * that passed
37    @return text describing passed tests
38    */
39   public String getPassReport()
40   {
41     return getReport(passed);
42   }
43   /**
44    * gets the description of the tests
45    * that failed
46    @return text describing failed tests
47    */
48   public String getFailReport()
49   {
50     return getReport(failed);
51   }
52 
53   /**
54    * converts the arraylist into messages
55    * separated by blank lines
56    @param names the description of passed
57    * or failed tests
58    @return a single String containing all
59    * of the contents of the ArrayList, each
60    * separated by a blank line
61    */
62   private static String getReport(ArrayList<String> names)
63   {
64     String report="";
65     for(String name: names)
66     {
67       report+=name+"\n\n";
68     }
69     if(report.length()>0)
70       report=report.substring(0, report.length()-2);
71     return report;
72   }
73 
74   public static void main(String[] args)
75   {
76     //DefiniteNumericCollectionTest test=new DefiniteNumericCollectionTest();
77   }
78 }


Download/View intermediate/DefiniteNumericCollectionTest.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter