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.0.8.17 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.16 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.15 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.14 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.13 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.12 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.11 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.10 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.9 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.8 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.7 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.6 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.5 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.4 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.3 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.2 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.8.1 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.7.0 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.6.44 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java
trackler-2.0.6.43 tracks/java/exercises/accumulate/src/test/java/AccumulateTest.java