01: // Modified or written by Object Mentor, Inc. for inclusion with FitNesse.
02: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
03: // Released under the terms of the GNU General Public License version 2 or later.
04: package fit;
05:
06: import junit.framework.TestCase;
07:
08: public class GracefulNamerTest extends TestCase {
09: public void testIsGracefulName() throws Exception {
10: assertTrue(GracefulNamer.isGracefulName("My Nice Fixture"));
11: assertTrue(GracefulNamer.isGracefulName("My_Nice Fixture"));
12: assertTrue(GracefulNamer.isGracefulName("My-Nice-Fixture"));
13: assertTrue(GracefulNamer
14: .isGracefulName("My!Really#Crazy--Name^"));
15: assertTrue(GracefulNamer.isGracefulName("EndsWithADot."));
16: assertFalse(GracefulNamer.isGracefulName("MyNiceFixture"));
17: assertFalse(GracefulNamer.isGracefulName("my.package.Fixture"));
18: }
19:
20: public void testUnGracefulName() throws Exception {
21: assertEquals("BadCompany", GracefulNamer
22: .disgrace("Bad Company"));
23: assertEquals("BadCompany", GracefulNamer
24: .disgrace("bad company"));
25: assertEquals("BadCompany", GracefulNamer
26: .disgrace("Bad-Company"));
27: assertEquals("BadCompany", GracefulNamer
28: .disgrace("Bad Company."));
29: assertEquals("BadCompany", GracefulNamer
30: .disgrace("(Bad Company)"));
31: assertEquals("BadCompany", GracefulNamer.disgrace("BadCompany"));
32: assertEquals("Bad123Company", GracefulNamer
33: .disgrace("bad 123 company"));
34: assertEquals("Bad123Company", GracefulNamer
35: .disgrace("bad 123company"));
36: assertEquals("Bad123Company", GracefulNamer
37: .disgrace(" bad \t123 company "));
38: assertEquals("Bad123Company", GracefulNamer
39: .disgrace("Bad123Company"));
40:
41: // Just to let you know... probably not what you want.
42: assertEquals("MyNamespaceBad123Company", GracefulNamer
43: .disgrace("My.Namespace.Bad123Company"));
44: }
45:
46: public void testEmptyString() throws Exception {
47: assertEquals("", GracefulNamer.disgrace(""));
48: }
49:
50: }
|