Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
kashike committed Nov 7, 2016
1 parent 5a5b117 commit 2f2237f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/kitteh/irc/client/library/util/Mask.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public Set<User> getMatches(@Nonnull Channel channel) {
public boolean test(User user) {
Sanity.nullCheck(user, "User cannot be null");

if (!equals(this.getNick(), user.getNick())) {
/*if (!equals(this.getNick(), user.getNick())) {
return false;
}
Expand All @@ -237,9 +237,9 @@ public boolean test(User user) {
if (!equals(this.getHost(), user.getHost())) {
return false;
}
}*/

return true;
return this.test(user.getName());
}

public boolean test(@Nonnull String string) {
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/org/kitteh/irc/client/library/util/MaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,26 @@ public void testSlashHost() {
Assert.assertFalse(matches.contains(bendem));
}

@Test
public void testUserPatternTest() {
final Channel channel = Mockito.mock(Channel.class);
final User mbaxter = new TestUser("mbaxter", "~mbax", "meow/kitties", null);
final User kashike = new TestUser("kashike", "kashike", "hiss/kitties", null);
final User lol768 = new TestUser("lol768", "lol768", "hiss/kitties", null);
final User zarthus = new TestUser("Zarthus", "Zarthus", "meow/kitties", null);
final User bendem = new TestUser("bendem", "bendem", "irc.bendem.be", null);
Mockito.when(channel.getUsers()).thenReturn(new ArrayList<>(Arrays.asList(mbaxter, kashike, lol768, zarthus, bendem)));

Mask mask = Mask.fromHost("*/kitties");
Collection<User> matches = mask.getMatches(channel);
Assert.assertTrue(matches.size() == 4);
Assert.assertTrue(matches.contains(mbaxter));
Assert.assertTrue(matches.contains(kashike));
Assert.assertTrue(matches.contains(lol768));
Assert.assertTrue(matches.contains(zarthus));
Assert.assertFalse(matches.contains(bendem));
}

@Test
public void testStringPatternTest() {
Mask mask = Mask.fromString("*!*@*/kitties");
Expand Down

0 comments on commit 2f2237f

Please sign in to comment.