Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarkhushalani committed Jan 10, 2022
1 parent 8da32c9 commit 8916ef6
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/test/java/hudson/plugins/greenballs/GreenBallFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ static void patternMatchAnime(Matcher m) {
assertThat(m.group(2), equalTo("_anime"));
}

static void patternMatchColorblind(Matcher m) {
assertThat(m.find(), is(true));
assertThat(m.group(1), equalTo("48x48"));
assertThat(m.group(2), equalTo(""));
}

static void patternMatchColorblindAnime(Matcher m) {
assertThat(m.find(), is(true));
assertThat(m.group(1), equalTo("48x48"));
assertThat(m.group(2), equalTo("_anime"));
}

@Test
public void patternShouldMatch() {
final Matcher m = GreenBallFilter.patternBlue.matcher("/nocacheImages/48x48/blue.gif");
Expand Down Expand Up @@ -69,4 +81,24 @@ public void patternShouldNotMatch() {
final Matcher m3 = GreenBallFilter.patternRed.matcher("/nocacheImages/48x48/yello_anime.gif");
assertThat(m3.find(), is(false));
}
}

@Test
public void patternShouldMatchColorblind() {
final Matcher m = GreenBallFilter.patternBlue.matcher("/nocacheImages/colorblind/48x48/blue.gif");
final Matcher m2 = GreenBallFilter.patternYellow.matcher("/nocacheImages/colorblind/48x48/yellow.gif");
final Matcher m3 = GreenBallFilter.patternRed.matcher("/nocacheImages/colorblind/48x48/red.gif");
patternMatchColorblind(m);
patternMatchColorblind(m2);
patternMatchColorblind(m3);
}

@Test
public void patternShouldMatchColorblindAnime() {
final Matcher m = GreenBallFilter.patternBlue.matcher("/nocacheImages/colorblind/48x48/blue_anime.gif");
final Matcher m2 = GreenBallFilter.patternYellow.matcher("/nocacheImages/colorblind/48x48/yellow_anime.gif");
final Matcher m3 = GreenBallFilter.patternRed.matcher("/nocacheImages/colorblind/48x48/red_anime.gif");
patternMatchColorblindAnime(m);
patternMatchColorblindAnime(m2);
patternMatchColorblindAnime(m3);
}
}

0 comments on commit 8916ef6

Please sign in to comment.