import java.util.Arrays; public class Adder { public static int AddAllContent(int[] numbersToAdd) { return Arrays.stream(numbersToAdd).sum(); } }
import java.util.stream.IntStream;- import java.util.Arrays;
- public class Adder
- {
- public static int AddAllContent(int[] numbersToAdd)
- {
int sum = IntStream.of(numbersToAdd).sum();return sum;- return Arrays.stream(numbersToAdd).sum();
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void testSomething() { int[] numbers = {1,2,3}; assertEquals(Adder.AddAllContent(numbers), 6); } @Test void testSomethingElse() { int[] numbers = {1,2,3, 10}; assertEquals(Adder.AddAllContent(numbers), 16); } @Test void testSomethingMore() { int[] numbers = {4,7,6,10}; assertEquals(Adder.AddAllContent(numbers), 27); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
- void testSomething() {
- int[] numbers = {1,2,3};
- assertEquals(Adder.AddAllContent(numbers), 6);
- }
- @Test
- void testSomethingElse() {
- int[] numbers = {1,2,3, 10};
- assertEquals(Adder.AddAllContent(numbers), 16);
- }
- @Test
- void testSomethingMore() {
- int[] numbers = {4,7,6,10};
- assertEquals(Adder.AddAllContent(numbers), 27);
- }
- }