-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBreadCrumbTest.java
38 lines (31 loc) · 2.16 KB
/
BreadCrumbTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.runners.JUnit4;
public class BreadCrumbTest {
@Test
public void examplesTests() {
// assertEquals("expected", "actual");
String[] urls = new String[] {"https://mysite.com/pictures/holidays.html",
"www.codewars.com/users/GiacomoSorbi?ref=CodeWars",
"www.microsoft.com/docs/index.htm#top",
"mysite.com/very-long-url-to-make-a-silly-yet-meaningful-example/example.asp",
"www.very-long-site_name-to-make-a-silly-yet-meaningful-example.com/users/giacomo-sorbi",
"linkedin.it/insider-transmutation-paper-bed-paper-insider/pippi.pi/most-downloaded/bladder-in-from-paper-eurasian/#info?favourite=code"};
String[] seps = new String[] {" : ", " / ", " * ", " > ", " + "};
String[] anss = new String[] {"<a href=\"/\">HOME</a> : <a href=\"/pictures/\">PICTURES</a> : <span class=\"active\">HOLIDAYS</span>",
"<a href=\"/\">HOME</a> / <a href=\"/users/\">USERS</a> / <span class=\"active\">GIACOMOSORBI</span>",
"<a href=\"/\">HOME</a> * <span class=\"active\">DOCS</span>",
"<a href=\"/\">HOME</a> > <a href=\"/very-long-url-to-make-a-silly-yet-meaningful-example/\">VLUMSYME</a> > <span class=\"active\">EXAMPLE</span>",
"<a href=\"/\">HOME</a> + <a href=\"/users/\">USERS</a> + <span class=\"active\">GIACOMO SORBI</span>"};
for (int i = 0 ; i<5 ; i++) {
System.out.println(" \nTest with : " + urls[i]);
String actual = BreadCrumb.generate_bc(urls[i], seps[i]);
if (!actual.equals(anss[i])) {
System.out.println(String.format("Expected : %s", reformat(anss[i])));
System.out.println(String.format("Actual : %s", reformat(actual)));
}
assertEquals(anss[i], actual);
}
}
String reformat(String s) { return s.replace("<","<"); }
}