Add client-side tests for StringUtils and Utils.
[online-glom:gwt-glom.git] / src / test / java / org / glom / web / client / GwtTestStringUtils.java
1 package org.glom.web.client;
2
3 import static org.junit.Assert.*;
4
5 import org.junit.Test;
6
7 import com.googlecode.gwt.test.GwtModule;
8 import com.googlecode.gwt.test.GwtTest;
9
10 @GwtModule("org.glom.web.OnlineGlom")
11 public class GwtTestStringUtils extends GwtTest {
12
13         public GwtTestStringUtils() {
14         }
15
16         @Test
17         public void testIsEmpty() {
18                 assertTrue(StringUtils.isEmpty(""));
19                 assertTrue(StringUtils.isEmpty(null));
20                 assertTrue(StringUtils.isEmpty(new String()));
21                 assertFalse(StringUtils.isEmpty("something"));
22         }
23
24         @Test
25         public void testDefaultString() {
26                 assertEquals("", StringUtils.defaultString(""));
27                 assertEquals("", StringUtils.defaultString(null));
28                 
29                 assertEquals("something", StringUtils.defaultString("something"));
30         }
31
32         @Test
33         public void testEquals() {
34                 assertTrue(StringUtils.equals(null, null));
35                 assertTrue(StringUtils.equals("", ""));
36                 assertTrue(StringUtils.equals(new String(), new String()));
37                 assertTrue(StringUtils.equals(null, ""));
38                 assertTrue(StringUtils.equals("", null));
39                 assertTrue(StringUtils.equals(null, new String()));
40                 assertTrue(StringUtils.equals(new String(), null));
41                 assertTrue(StringUtils.equals(null, new String()));
42                 assertTrue(StringUtils.equals(new String(), null));
43                 
44                 assertFalse(StringUtils.equals("something", null));
45                 assertFalse(StringUtils.equals("something", ""));
46                 assertFalse(StringUtils.equals("something", new String()));
47                 assertFalse(StringUtils.equals(null, "something"));
48                 assertFalse(StringUtils.equals("", "something"));
49                 assertFalse(StringUtils.equals(new String(), "something"));
50         }
51
52 }