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