Sha256: 644ecf82bb887945088d308e58164f600c77bf2b52b769c9ce352cc065d00eef

Contents?: true

Size: 1.9 KB

Versions: 158

Compression:

Stored size: 1.9 KB

Contents

import org.junit.Test;
import org.junit.Ignore;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

import static org.junit.Assert.assertEquals;

public class AccumulateTest {


    @Test
    public void emptyAccumulateProducesEmptyAccumulation() {
        List<Integer> input = new LinkedList<>();
        List<Integer> expectedOutput = new LinkedList<>();
        assertEquals(expectedOutput, Accumulate.accumulate(input, x -> x * x));
    }

    @Ignore
    @Test
    public void accumulateSquares() {
        List<Integer> input = Arrays.asList(1, 2, 3);
        List<Integer> expectedOutput = Arrays.asList(1, 4, 9);
        assertEquals(expectedOutput, Accumulate.accumulate(input, x -> x * x));
    }

    @Ignore
    @Test
    public void accumulateUpperCases() {
        List<String> input = Arrays.asList("hello", "world");
        List<String> expectedOutput = Arrays.asList("HELLO", "WORLD");
        assertEquals(expectedOutput, Accumulate.accumulate(input, x -> x.toUpperCase()));
    }

    @Ignore
    @Test
    public void accumulateReversedStrings() {
        List<String> input = Arrays.asList("the quick brown fox etc".split(" "));
        List<String> expectedOutput = Arrays.asList("eht kciuq nworb xof cte".split(" "));
        assertEquals(expectedOutput, Accumulate.accumulate(input, this::reverse));
    }

    private String reverse(String input) {
        return new StringBuilder(input).reverse().toString();
    }

    @Ignore
    @Test
    public void accumulateWithinAccumulate() {
        List<String> input1 = Arrays.asList("a", "b", "c");
        List<String> input2 = Arrays.asList("1", "2", "3");
        List<String> expectedOutput = Arrays.asList("a1 a2 a3", "b1 b2 b3", "c1 c2 c3");
        assertEquals(expectedOutput, Accumulate.accumulate(
                input1, c ->
                        String.join(" ", Accumulate.accumulate(input2, d -> c + d))
        ));
    }
}

Version data entries

158 entries across 158 versions & 1 rubygems

Version Path
trackler-2.1.0.2 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.1.0.1 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.1.0.0 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.55 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.54 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.53 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.52 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.51 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.50 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.49 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.48 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.47 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.46 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.45 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.44 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.43 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.42 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.41 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.40 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.39 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java