-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKataTest.java
More file actions
47 lines (40 loc) · 1.33 KB
/
KataTest.java
File metadata and controls
47 lines (40 loc) · 1.33 KB
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
46
47
package com.example.testing.junit;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import static org.assertj.core.api.Assertions.assertThat;
class KataTest {
@Nested
class Fibonacci {
@Test
@DisplayName("Can calculate fibonacci sequence")
void test() {
var expected = new int[]{ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 };
var actual = new Kata().fibonacci(10);
assertThat(actual).isEqualTo(expected);
}
}
@Nested
class Palindrome {
@Test
void test() {
var kata = new Kata();
assertThat(kata.isPalindrome("racecar"))
.isTrue();
assertThat(kata.isPalindrome("car"))
.isFalse();
assertThat(kata.isPalindrome("abcdcba"))
.isTrue();
}
@DisplayName("Can detect palindromes")
@ParameterizedTest
@CsvSource({"car, false", "racecar, true", "abcdcba, true"})
void param_test(String input, boolean expected) {
var kata = new Kata();
assertThat(kata.isPalindrome(input))
.isEqualTo(expected);
}
}
}