Skip to content

Commit

Permalink
Add test for native - not sure this is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
ekrich committed Sep 26, 2024
1 parent 91cdf26 commit bc9a7fd
Show file tree
Hide file tree
Showing 3 changed files with 1,065 additions and 7 deletions.
12 changes: 5 additions & 7 deletions sconfig/native/src/main/scala/java/net/URLConnection.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package java.net

import scalanative.annotation.stub

class URLConnection {
@stub

def getLastModified(): scala.Long = ???
@stub

def connect(): Unit = ???
@stub

def getContentType(): String = ???
@stub

def getInputStream(): java.io.InputStream = ???
@stub

def setRequestProperty(key: String, value: String): Unit = ???
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.ekrich.config.impl

import java.io.{BufferedReader, FileReader}

import org.ekrich.config.parser._
import org.junit.Assert._
import org.junit.Test

import FileUtils._

class ConfigDocumentFactoryJvmTest extends TestUtils {

@Test
def configDocumentFileParse: Unit = {
val configDocument =
ConfigDocumentFactory.parseFile(resourceFile("/test03.conf"))
val fileReader = new BufferedReader(
new FileReader("src/test/resources/test03.conf")
)
var line = fileReader.readLine()
val sb = new StringBuilder()
while (line != null) {
sb.append(line)
sb.append("\n")
line = fileReader.readLine()
}
fileReader.close()
val fileText = sb.toString()
assertEquals(fileText, defaultLineEndingsToUnix(configDocument.render))
}

private def defaultLineEndingsToUnix(s: String): String =
s.replaceAll(System.lineSeparator(), "\n")

@Test
def configDocumentReaderParse: Unit = {
val configDocument = ConfigDocumentFactory.parseReader(
new FileReader(resourceFile("/test03.conf"))
)
val configDocumentFile =
ConfigDocumentFactory.parseFile(resourceFile("/test03.conf"))
assertEquals(configDocumentFile.render, configDocument.render)
}
}
Loading

0 comments on commit bc9a7fd

Please sign in to comment.