Skip to main content
summaryrefslogtreecommitdiffstats
blob: fdf7120dc4f08bceace800e837584e7dc0d14595 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package org.eclipse.cdt.debug.testplugin.util;

import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * @author Peter Graves
 *
 *Some simple tests to make sure our ExtraStrings class seems to work.
 */
public class ExpectedStringsTests extends TestCase {

	/**
	 * Constructor for ExpectedStringsTests.
	 * @param name
	 */
	public ExpectedStringsTests(String name) {
		super(name);
	}
	    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     * 
     * Example code test the packages in the project 
     *  "com.qnx.tools.ide.cdt.core"
     */
    protected void setUp() {


    }
    
     /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    protected void tearDown() {
       // release resources here and clean-up
    }
    
    public static TestSuite suite() {
        return new TestSuite(ExpectedStringsTests.class);
    }
    
    public static void main (String[] args){
        junit.textui.TestRunner.run(suite());
    }

	public void testGotAll() {
		ExpectedStrings myExp;
		String[] strings= {"stringOne", "stringTwo", "stringThree" };
		
		myExp=new ExpectedStrings(strings);
		assertTrue("No found strings", !myExp.gotAll());
		myExp.foundString("stringOne");
		assertTrue("1 found strings", !myExp.gotAll());
		myExp.foundString("stringTwo");
		assertTrue("2 found strings", !myExp.gotAll());
		myExp.foundString("stringThree");
		assertTrue("All found strings", myExp.gotAll());
		
		
	}
	public void testGotExtra () {
		ExpectedStrings myExp;
		String[] strings= {"stringOne", "stringTwo", "stringThree" };
		
		myExp=new ExpectedStrings(strings);
		assertTrue("No found strings", !myExp.gotExtra());
		myExp.foundString("stringOne");
		assertTrue("1 found strings", !myExp.gotExtra());
		myExp.foundString("stringTwo");
		assertTrue("2 found strings", !myExp.gotExtra());
		myExp.foundString("stringThree");
		assertTrue("All found strings", !myExp.gotExtra());
		myExp.foundString("Somerandomestring");
		assertTrue("Extra String", myExp.gotExtra());
		
	}
	
	public void testGetMissingString()
	{
		ExpectedStrings myExp;
		String[] strings= {"stringOne", "stringTwo", "stringThree" };
		
		myExp=new ExpectedStrings(strings);
		assertNotNull(myExp.getMissingString());
		myExp.foundString("stringOne");
		assertNotNull(myExp.getMissingString());
		myExp.foundString("stringTwo");
		assertNotNull(myExp.getMissingString());
		myExp.foundString("stringThree");
		assertNotNull(myExp.getMissingString());

	}
	
	public void testGetExtraString()
	{
		ExpectedStrings myExp;
		String[] strings= {"stringOne", "stringTwo", "stringThree" };
		
		myExp=new ExpectedStrings(strings);
		assertNotNull(myExp.getExtraString());
		myExp.foundString("stringOnenot");
		assertNotNull(myExp.getMissingString());
		myExp.foundString("stringTwonot");
		assertNotNull(myExp.getMissingString());

	}



}

Back to the top