mirror of https://github.com/sbt/sbt.git
Test FilesInfo brokenness
This commit is contained in:
parent
71d104da3d
commit
c6e793b03c
|
|
@ -0,0 +1,23 @@
|
|||
package sbt.internal.util
|
||||
|
||||
import scala.json.ast.unsafe._
|
||||
import sjsonnew._, support.scalajson.unsafe._
|
||||
|
||||
class FileInfoSpec extends UnitSpec {
|
||||
val file = new java.io.File(".")
|
||||
val fileInfo: ModifiedFileInfo = FileModified(file, file.lastModified())
|
||||
val filesInfo = FilesInfo(Set(fileInfo))
|
||||
|
||||
it should "round trip" in assertRoundTrip(filesInfo)
|
||||
|
||||
def assertRoundTrip[A: JsonWriter: JsonReader](x: A) = {
|
||||
val jsonString: String = toJsonString(x)
|
||||
val jValue: JValue = Parser.parseUnsafe(jsonString)
|
||||
val y: A = Converter.fromJson[A](jValue).get
|
||||
assert(x === y)
|
||||
}
|
||||
|
||||
def assertJsonString[A: JsonWriter](x: A, s: String) = assert(toJsonString(x) === s)
|
||||
|
||||
def toJsonString[A: JsonWriter](x: A): String = CompactPrinter(Converter.toJson(x).get)
|
||||
}
|
||||
Loading…
Reference in New Issue