forked from Kotlin-Polytech/FromKotlinToJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecoderTest.kt
More file actions
32 lines (26 loc) · 1020 Bytes
/
Copy pathRecoderTest.kt
File metadata and controls
32 lines (26 loc) · 1020 Bytes
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
package part2.recode.java
import org.junit.Test
import org.junit.Assert.*
import java.io.File
import java.nio.charset.Charset
class RecoderTest {
private fun assertFileContent(name: String, expectedContent: String, encoding: String) {
val file = File(name)
val content = file.readLines(Charset.forName(encoding)).joinToString("\n")
assertEquals(expectedContent, content)
}
@Test
fun recode() {
val recoder = Recoder("UTF8", "CP1251")
recoder.recode("files/text1.txt", "files/temp.txt")
assertFileContent("files/temp.txt", "А роза упала на лапу Азора...", "CP1251")
File("files/temp.txt").delete()
}
@Test
fun recodeKotlin() {
val recoder = part2.recode.kotlin.Recoder("UTF8", "CP1251")
recoder.recode("files/text1.txt", "files/temp.txt")
assertFileContent("files/temp.txt", "А роза упала на лапу Азора...", "CP1251")
File("files/temp.txt").delete()
}
}