Skip to content

Commit

Permalink
Read language-tagged string as a literal string.
Browse files Browse the repository at this point in the history
  • Loading branch information
ovstetun committed Oct 23, 2017
1 parent aeed4f1 commit d346ac2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ class CommonBindersTest[Rdf <: RDF](implicit ops: RDFOps[Rdf]) extends WordSpec
pg123.toPG.as[Int] shouldEqual Success(123)
}

"serializing and deserializing a String" in {
val pgString = "abc".toPG
pgString.pointer shouldEqual (Literal("abc", xsd.string))
pgString.graph shouldEqual (Graph.empty)
pgString.toPG.as[String] shouldEqual (Success("abc"))

val taggedLiteral = makeLangTaggedLiteral("abcEng", Lang("en")).toPG
taggedLiteral.pointer shouldEqual (Literal.tagged("abcEng", Lang("en")))
taggedLiteral.graph shouldEqual (Graph.empty)
taggedLiteral.toPG.as[String] shouldEqual (Success("abcEng"))
}

"serializing and deserializing a List of simple nodes" in {
val bn1 = BNode()
val bn2 = BNode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object FromLiteral {
import ops._
def fromLiteral(literal: Rdf#Literal): Try[String] = {
val Literal(lexicalForm, datatype, _) = literal
if (datatype == xsd.string)
if (datatype == xsd.string || datatype == rdf.langString)
Success(lexicalForm)
else
Failure(FailedConversion(s"${literal} is not an xsd:string"))
Expand Down

0 comments on commit d346ac2

Please sign in to comment.