View Javadoc
1   package com.atlassian.plugin.util;
2   
3   import org.junit.Test;
4   
5   import static com.atlassian.plugin.util.EfficientStringUtils.endsWith;
6   import static org.junit.Assert.assertFalse;
7   import static org.junit.Assert.assertTrue;
8   
9   public class EfficientStringUtilsTest {
10  
11      @Test
12      public void testEndsWith() {
13          assertTrue(endsWith("abc", "c"));
14          assertTrue(endsWith("foo.xml", ".", "xml"));
15          assertTrue(endsWith("foo", "foo"));
16      }
17  
18      @Test
19      public void testEndsWithNoMatchingSuffix() {
20          assertFalse(endsWith("foo", "ooo"));
21          assertFalse(endsWith("foo.xml", "."));
22      }
23  
24      @Test
25      public void testEndsWithEmptySuffixes() {
26          // Degenerate cases: any string ends with nothing
27          assertTrue(endsWith("foo", ""));
28          assertTrue(endsWith("", ""));
29          assertTrue(endsWith("foo"));
30          assertTrue(endsWith(""));
31      }
32  }