1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.ignore.internal;
11
12 import static org.junit.Assert.assertEquals;
13
14 import org.junit.Test;
15
16 public class StringsTest {
17
18 private void testString(String string, int n, int m) {
19 assertEquals(string, n, Strings.count(string, '/', false));
20 assertEquals(string, m, Strings.count(string, '/', true));
21 }
22
23 @Test
24 public void testCount() {
25 testString("", 0, 0);
26 testString("/", 1, 0);
27 testString("//", 2, 0);
28 testString("///", 3, 1);
29 testString("////", 4, 2);
30 testString("foo", 0, 0);
31 testString("/foo", 1, 0);
32 testString("foo/", 1, 0);
33 testString("/foo/", 2, 0);
34 testString("foo/bar", 1, 1);
35 testString("/foo/bar/", 3, 1);
36 testString("/foo/bar//", 4, 2);
37 testString("/foo//bar/", 4, 2);
38 testString(" /foo/ ", 2, 2);
39 }
40 }