Permalink
Browse files

Changed maven groupId, added a serialization round-trip test, and a n…

…ewline at end of N-Triple output.
  • Loading branch information...
LeifW committed Dec 31, 2010
1 parent f77dd44 commit e0a7d7114bea01462cd21ec880583a1fb0c7b753
View
@@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>net.croz.scardf</groupId>
+ <groupId>org.scardf</groupId>
<artifactId>scardf</artifactId>
<name>Scardf</name>
<version>0.5-SNAPSHOT</version>
@@ -10,7 +10,9 @@ import java.io.Reader
object Parse {
val space = 32
val tab = 9
+ //val hexDigits4 = Stream.iterate(1)(_*16).take(4).reverse
val hexDigits4 = Array(4096, 256, 16, 1)
+ //val hexDigits6 = Stream.iterate(1)(_*16).take(6).reverse
val hexDigits6 = Array(1048576, 65536, 4096, 256, 16, 1)
def fromHex(c:Int) = c match {
case l if Character.isLetter(l) => l - 55
@@ -211,7 +211,7 @@ class Serializator( sf: SerializationFormat ) {
}
def write( g: Graph, w: java.io.Writer ): Unit = sf match {
- case NTriple => w write g.triples.map{ _.rend }.mkString( "\n" )
+ case NTriple => w write (g.triples.map{ _.rend }.mkString( "\n" ) + '\n')
case _ => throw new UnsupportedOperationException()
}
@@ -0,0 +1,20 @@
+package org.scardf
+
+import org.specs._
+import org.specs.runner.JUnit4
+import java.io.{CharArrayReader, CharArrayWriter}
+
+class SerializerSpecsTest extends JUnit4(SerializerSpecs)
+
+object SerializerSpecs extends Specification {
+ val g = Doe.graph
+ "Graph serialization / deserialization" should {
+ "be round-tripable" in {
+ val s = new Serializator( NTriple )
+ val w = new CharArrayWriter
+ s.write(g, w)
+ val r = new CharArrayReader( w.toCharArray )
+ s.readFrom(r) mustVerify( _ =~ g )
+ }
+ }
+}

0 comments on commit e0a7d71

Please sign in to comment.