Esempio n. 1
0
  /** Test method for {@link Sequence#compareTo(Value)}. */
  @Test
  public void testCompareTo_Unordered() {
    Sequence s1 = Sequence.unordered(ls("1", "2"));
    Sequence s2 = Sequence.unordered(ls("1", "2"));
    Sequence s3 = Sequence.unordered(ls("1"));
    Sequence s4 = Sequence.unordered(ls("1", "2", "3"));
    Sequence s5 = Sequence.unordered(ls("1", "3"));
    Sequence s6 = Sequence.unordered(ls("1", "1"));
    Sequence s7 = Sequence.unordered(ls("0", "3"));
    Sequence s8 = Sequence.unordered(ls("2", "1"));
    Terminal v1 = Terminal.of("12");
    Sequence v2 = Sequence.ordered(ls("1", "2"));
    Record v3 = Record.of(Arrays.<Entry>asList());

    // test is not an unordered list
    assertThat(s1.compareTo(v1), greaterThan(0));
    assertThat(s1.compareTo(v2), lessThan(0));
    assertThat(s1.compareTo(v3), lessThan(0));

    // entity
    assertThat(s1.compareTo(s1), is(0));
    assertThat(s1.compareTo(s2), is(0));
    assertThat(s1.compareTo(s3), greaterThan(0));
    assertThat(s1.compareTo(s4), lessThan(0));
    assertThat(s1.compareTo(s5), lessThan(0));
    assertThat(s1.compareTo(s6), greaterThan(0));
    assertThat(s1.compareTo(s7), greaterThan(0));
    assertThat(s1.compareTo(s8), is(0));
  }
Esempio n. 2
0
  /** Test method for {@link Sequence#equals(java.lang.Object)}. */
  @Test
  public void testEquals_Unordered() {
    Sequence s1 = Sequence.unordered(ls("1", "2"));
    Sequence s2 = Sequence.unordered(ls("1", "2"));
    Sequence s3 = Sequence.unordered(ls("2", "1"));
    Sequence s4 = Sequence.unordered(ls("1", "3"));
    Sequence s5 = Sequence.ordered(ls("1", "2"));

    assertThat(s1.equals(s1), is(true));
    assertThat(s1.equals(s2), is(true));
    assertThat(s1.equals(s3), is(true));
    assertThat(s1.equals(s4), is(false));
    assertThat(s1.equals(s5), is(false));
    assertThat(s1.equals(ls("1", "2")), is(false));
    assertThat(s1.equals(null), is(false));
  }
Esempio n. 3
0
 /** Test method for {@link Sequence#unordered(java.util.List)}. */
 @Test(expected = NullPointerException.class)
 public void testUnordered_Null() {
   Sequence.unordered(null);
 }
Esempio n. 4
0
 /** Test method for {@link Sequence#unordered(java.util.List)}. */
 @Test
 public void testUnordered() {
   Sequence s = Sequence.unordered(ls("1", "2", "3", "1", "2"));
   assertThat(s.getValues(), is(ls("1", "1", "2", "2", "3")));
   assertThat(s.getKind(), is(Value.Kind.UNORDERED_LIST));
 }