Skip to content

Commit 15f94a5

Browse files
PatilShreyastschuchortdev
authored andcommitted
#364 | Add tests for validating encoding utility
1 parent fc6bb34 commit 15f94a5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.tschuchort.compiletesting
2+
3+
import junit.framework.TestCase.assertEquals
4+
import org.junit.Test
5+
6+
class EncodingUtilsTest {
7+
@Test
8+
fun encodePath_returnsSamePath_whenPathAlreadyValidEncoded() {
9+
// Given: A valid path
10+
val path = "file://users/johndoe/.gradle/something/somewhere/kotlin-compiler.jar"
11+
12+
// When: Path is encoded
13+
val actualPath = encodePath(path)
14+
15+
// Then: The same path should be returned
16+
assertEquals(path, actualPath)
17+
}
18+
19+
@Test
20+
fun encodePath_returnsEncodedPath_whenPathIsNotAlreadyValidEncoded() {
21+
// Given: A path having whitespace in it
22+
val path = "file://users/john doe/.gradle/something/somewhere/kotlin-compiler.jar"
23+
24+
// When: Path is encoded
25+
val actualPath = encodePath(path)
26+
27+
// Then: The valid encoded path should be returned
28+
val expectedPath = "file://users/john%20doe/.gradle/something/somewhere/kotlin-compiler.jar"
29+
assertEquals(expectedPath, actualPath)
30+
}
31+
}

0 commit comments

Comments
 (0)