Skip to content

Instantly share code, notes, and snippets.

@dedeibel
Created February 8, 2016 10:43
Show Gist options
  • Save dedeibel/1284459e46f23e85b5ee to your computer and use it in GitHub Desktop.
Save dedeibel/1284459e46f23e85b5ee to your computer and use it in GitHub Desktop.
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test;
import com.google.common.collect.ImmutableList;
public class MyMatchersTest {
@Test
public void testSameAsSet() throws Exception {
assertThat(asList("a", "b", "c"), sameAsSet(asList("a", "b", "c")));
assertThat(asList("c", "b", "a"), sameAsSet(asList("a", "b", "c")));
assertThat(asList("b", "c", "a"), sameAsSet(asList("a", "b", "c")));
assertThat(ImmutableList.of("b", "c", "a"), sameAsSet(asList("a", "b", "c")));
assertThat(asList("b", "c", "a"), sameAsSet(ImmutableList.of("a", "b", "c")));
}
@Test(expected = AssertionError.class)
public void testSameAsSetFailMoreExpected() throws Exception {
assertThat(asList("a", "b", "c"), sameAsSet(asList("a", "b", "c", "d")));
}
@Test(expected = AssertionError.class)
public void testSameAsSetFailLessExpected() throws Exception {
assertThat(asList("a", "b", "c"), sameAsSet(asList("a", "b")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment