import java.util.List; import java.util.ArrayList; public class FizzBuzz { public static List<String> evaluate(int input) { List<String> listOfString = new ArrayList<>(); for (int i = 1; i < input + 1; i++) { listOfString.add(Integer.toString(i)); } return listOfString; } }
- import java.util.List;
- import java.util.ArrayList;
- public class FizzBuzz {
public static String evaluate(String input) {return input;}- public static List<String> evaluate(int input) {
return List.of(evaluate(Integer.toString(input)));- List<String> listOfString = new ArrayList<>();
- for (int i = 1; i < input + 1; i++) {
- listOfString.add(Integer.toString(i));
- }
- return listOfString;
- }
- }
import org.junit.jupiter.api.Test; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void shouldAcceptInt() { assertEquals(List.of("1"), FizzBuzz.evaluate(1)); } @Test void inputOfTwo() { assertEquals(List.of("1", "2"), FizzBuzz.evaluate(2)); } }
- import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;- import java.util.List;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
void emptyString() {assertEquals("", FizzBuzz.evaluate(""));- void shouldAcceptInt() {
- assertEquals(List.of("1"), FizzBuzz.evaluate(1));
- }
- @Test
void shouldAcceptInt() {assertEquals(List.of("1"), FizzBuzz.evaluate(1));- void inputOfTwo() {
- assertEquals(List.of("1", "2"), FizzBuzz.evaluate(2));
- }
- }