author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:58:11 +0200 | |
changeset 154 | 0fd5e9c500b9 |
parent 153 | b5cbb797ec0a |
permissions | -rw-r--r-- |
jtulach@54 | 1 |
package apifest; |
jtulach@54 | 2 |
|
jtulach@54 | 3 |
import junit.framework.TestCase; |
jtulach@54 | 4 |
import org.netbeans.apifest.boolcircuit.Circuit; |
jtulach@54 | 5 |
|
jtulach@54 | 6 |
|
jtulach@54 | 7 |
/** Write a test that works with version from day A and fails with version B. |
jtulach@54 | 8 |
*/ |
jtulach@59 | 9 |
// BEGIN: apifest.day3.against-welltestedsolution |
jtulach@54 | 10 |
public class CircuitTest extends TestCase { |
jtulach@54 | 11 |
public CircuitTest(String n) { |
jtulach@54 | 12 |
super(n); |
jtulach@54 | 13 |
} |
jtulach@54 | 14 |
|
jtulach@54 | 15 |
public void testClass() throws Exception { |
jtulach@54 | 16 |
// OK, this is not fair as well. |
jtulach@154 | 17 |
assertEquals("Created AND circuit", "AndCircuit", |
jtulach@154 | 18 |
getName(Circuit.createAndCircuit(null, null)) |
jtulach@154 | 19 |
); |
jtulach@154 | 20 |
assertEquals("Created OR circuit", "OrCircuit", |
jtulach@154 | 21 |
getName(Circuit.createOrCircuit(null, null)) |
jtulach@154 | 22 |
); |
jtulach@54 | 23 |
} |
jtulach@54 | 24 |
|
jtulach@54 | 25 |
private String getName(Object obj) { |
jtulach@54 | 26 |
String base = obj.getClass().getName(); |
jtulach@54 | 27 |
int lastDot = base.lastIndexOf('.'); |
jtulach@54 | 28 |
int last = base.lastIndexOf('$'); |
jtulach@54 | 29 |
if (lastDot > last) last = lastDot; |
jtulach@54 | 30 |
return base.substring(last+1); |
jtulach@54 | 31 |
} |
jtulach@54 | 32 |
} |
jtulach@59 | 33 |
// END: apifest.day3.against-welltestedsolution |