Skip to content

Commit c2958c4

Browse files
committed
1 parent 2c1988a commit c2958c4

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# [Substituting Variables Into Strings: Padded Numbers](https://www.codewars.com/kata/substituting-variables-into-strings-padded-numbers "https://www.codewars.com/kata/51c89385ee245d7ddf000001")
22

3-
Complete the solution so that it returns a formatted string. The return value should equal "Value is VALUE" where value is a 5 digit padded number.
3+
Complete the solution so that it returns a formatted string. The return value should equal "Value is VALUE" where value is a 5 digit padded
4+
number.
45

56
Example:
67

78
```
89
solution(5); // should return "Value is 00005"
9-
```
10+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Kata {
2+
static String solution(int value) {
3+
return String.format("Value is %05d", value);
4+
}
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import org.junit.jupiter.params.ParameterizedTest;
4+
import org.junit.jupiter.params.provider.CsvSource;
5+
6+
class Tests {
7+
@ParameterizedTest
8+
@CsvSource(textBlock = """
9+
0, Value is 00000
10+
5, Value is 00005
11+
109, Value is 00109
12+
1204 Value is 01204
13+
""")
14+
void sample(int n, String expected) {
15+
assertEquals(expected, Kata.solution(n));
16+
}
17+
}

0 commit comments

Comments
 (0)