예제 #1
0
  @Test
  public void testBasicSimilarity() {

    TestCase test1 = new DefaultTestCase();
    TestCase test2 = new DefaultTestCase();

    PrimitiveStatement<?> aInt = new IntPrimitiveStatement(test1, 42);
    test1.addStatement(aInt);

    PrimitiveStatement<?> bInt = new IntPrimitiveStatement(test2, 42);
    test2.addStatement(bInt);

    double score = DiversityObserver.getNeedlemanWunschScore(test1, test2);
    Assert.assertTrue(score > 0);
  }
예제 #2
0
  @Test
  public void testSelfSimilarity() {

    TestCase test = new DefaultTestCase();

    PrimitiveStatement<?> aInt = new IntPrimitiveStatement(test, 42);
    test.addStatement(aInt);

    double score = DiversityObserver.getNeedlemanWunschScore(test, test);
    Assert.assertTrue(score > 0);
  }
예제 #3
0
  @Test
  public void testBasicSimilarityDifferentTypes2() {

    TestCase test1 = new DefaultTestCase();
    TestCase test2 = new DefaultTestCase();

    PrimitiveStatement<?> aInt = new LongPrimitiveStatement(test1, 42L);
    test1.addStatement(aInt);
    PrimitiveStatement<?> aInt2 = new IntPrimitiveStatement(test1, 42);
    test1.addStatement(aInt2);

    PrimitiveStatement<?> bInt = new IntPrimitiveStatement(test2, 42);
    test2.addStatement(bInt);
    Constructor<?> c = Object.class.getConstructors()[0];
    ConstructorStatement cs =
        new ConstructorStatement(
            test2, new GenericConstructor(c, Object.class), new ArrayList<VariableReference>());
    test2.addStatement(cs);

    double score = DiversityObserver.getNeedlemanWunschScore(test1, test2);
    Assert.assertTrue(score <= 0);
  }