summaryrefslogtreecommitdiff
path: root/src/test/java/org/javacs/PrunerTest.java
blob: 3b6f017df06a1ea73395a1c7762d6734413e7d78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.javacs;

import static org.hamcrest.Matchers.*;
import static org.javacs.JavaCompilerServiceTest.*;
import static org.junit.Assert.*;

import org.junit.Test;

public class PrunerTest {

    @Test
    public void pruneMethods() {
        var actual = Pruner.prune(resourceUri("PruneMethods.java"), 6, 19);
        var expected = contents("PruneMethods_erased.java");
        assertThat(actual, equalToIgnoringWhiteSpace(expected));
    }

    @Test
    public void pruneToEndOfBlock() {
        var actual = Pruner.prune(resourceUri("PruneToEndOfBlock.java"), 4, 18);
        var expected = contents("PruneToEndOfBlock_erased.java");
        assertThat(actual, equalToIgnoringWhiteSpace(expected));
    }

    @Test
    public void pruneMiddle() {
        var actual = Pruner.prune(resourceUri("PruneMiddle.java"), 4, 12);
        var expected = contents("PruneMiddle_erased.java");
        assertThat(actual, equalToIgnoringWhiteSpace(expected));
    }

    @Test
    public void pruneDot() {
        var actual = Pruner.prune(resourceUri("PruneDot.java"), 3, 11);
        var expected = contents("PruneDot_erased.java");
        assertThat(actual, equalToIgnoringWhiteSpace(expected));
    }

    @Test
    public void pruneWords() {
        var actual = Pruner.prune(resourceUri("PruneWords.java"), "word");
        var expected = contents("PruneWords_erased.java");
        assertThat(actual, equalToIgnoringWhiteSpace(expected));
    }
}