Skip to content

Commit f56d425

Browse files
committed
Refactor ConfigFactoryDocumentTest to Shared and JVM - JS and Native tests from 318 to 346
1 parent ee20423 commit f56d425

19 files changed

+60
-566
lines changed

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ lazy val sconfig = crossProject(JVMPlatform, NativePlatform, JSPlatform)
163163
.nativeConfigure(_.enablePlugins(ScalaNativeJUnitPlugin))
164164
.nativeSettings(
165165
crossScalaVersions := versions,
166-
nativeConfig ~= (
166+
Test / nativeConfig ~= (
167167
_.withEmbedResources(true)
168168
),
169169
logLevel := Level.Info, // Info or Debug

sconfig/jvm/src/main/scala/org/ekrich/config/ConfigParseOptions.scala

-259
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.ekrich.config.impl
2+
3+
import java.io.{BufferedReader, FileReader}
4+
5+
import org.ekrich.config.parser._
6+
import org.junit.Assert._
7+
import org.junit.Test
8+
9+
import FileUtils._
10+
11+
class ConfigDocumentFactoryJvmTest extends TestUtils {
12+
13+
@Test
14+
def configDocumentFileParse: Unit = {
15+
val configDocument =
16+
ConfigDocumentFactory.parseFile(resourceFile("/test03.conf"))
17+
val fileReader = new BufferedReader(
18+
new FileReader("src/test/resources/test03.conf")
19+
)
20+
var line = fileReader.readLine()
21+
val sb = new StringBuilder()
22+
while (line != null) {
23+
sb.append(line)
24+
sb.append("\n")
25+
line = fileReader.readLine()
26+
}
27+
fileReader.close()
28+
val fileText = sb.toString()
29+
assertEquals(fileText, defaultLineEndingsToUnix(configDocument.render))
30+
}
31+
32+
private def defaultLineEndingsToUnix(s: String): String =
33+
s.replaceAll(System.lineSeparator(), "\n")
34+
35+
@Test
36+
def configDocumentReaderParse: Unit = {
37+
val configDocument = ConfigDocumentFactory.parseReader(
38+
new FileReader(resourceFile("/test03.conf"))
39+
)
40+
val configDocumentFile =
41+
ConfigDocumentFactory.parseFile(resourceFile("/test03.conf"))
42+
assertEquals(configDocumentFile.render, configDocument.render)
43+
}
44+
}

0 commit comments

Comments
 (0)