Package org.sonar.plugins.core.issue.tracking

Examples of org.sonar.plugins.core.issue.tracking.StringTextComparator


public class RollingHashSequenceTest {

  @Test
  public void test_hash() {
    StringText seq = new StringText("line0 \n line1 \n line2");
    StringTextComparator cmp = StringTextComparator.IGNORE_WHITESPACE;
    RollingHashSequence<StringText> seq2 = RollingHashSequence.wrap(seq, cmp, 1);
    RollingHashSequenceComparator<StringText> cmp2 = new RollingHashSequenceComparator<StringText>(cmp);

    assertThat(seq2.length()).isEqualTo(3);
    assertThat(cmp2.hash(seq2, 0)).isEqualTo(cmp.hash(seq, 0) * 31 + cmp.hash(seq, 1));
    assertThat(cmp2.hash(seq2, 1)).isEqualTo((cmp.hash(seq, 0) * 31 + cmp.hash(seq, 1)) * 31 + cmp.hash(seq, 2));
    assertThat(cmp2.hash(seq2, 2)).isEqualTo((cmp.hash(seq, 1) * 31 + cmp.hash(seq, 2)) * 31);
  }
View Full Code Here


    assertThat(cmp2.hash(seq2, 2)).isEqualTo((cmp.hash(seq, 1) * 31 + cmp.hash(seq, 2)) * 31);
  }

  @Test
  public void test_equals() {
    StringTextComparator baseCmp = StringTextComparator.IGNORE_WHITESPACE;
    RollingHashSequence<StringText> a = RollingHashSequence.wrap(new StringText("line0 \n line1 \n line2"), baseCmp, 1);
    RollingHashSequence<StringText> b = RollingHashSequence.wrap(new StringText("line0 \n line1 \n line2 \n line3"), baseCmp, 1);
    RollingHashSequenceComparator<StringText> cmp = new RollingHashSequenceComparator<StringText>(baseCmp);

    assertThat(cmp.equals(a, 0, b, 0)).isTrue();
View Full Code Here

public class StringTextComparatorTest {

  @Test
  public void testEquals() {
    StringTextComparator cmp = StringTextComparator.IGNORE_WHITESPACE;

    StringText a = new StringText("abc\nabc\na bc");
    StringText b = new StringText("abc\nabc d\nab c");

    assertThat(cmp.equals(a, 0, b, 0)).as("abc == abc").isTrue();
    assertThat(cmp.equals(a, 1, b, 1)).as("abc != abc d").isFalse();
    assertThat(cmp.equals(a, 2, b, 2)).as("a bc == ab c").isTrue();
    assertThat(cmp.hash(a, 0)).isEqualTo(cmp.hash(b, 0));
    assertThat(cmp.hash(a, 2)).isEqualTo(cmp.hash(b, 2));
  }
View Full Code Here

TOP

Related Classes of org.sonar.plugins.core.issue.tracking.StringTextComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.