-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added copy support for Scala serializers
- Loading branch information
1 parent
c31c402
commit 8bdfa1a
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
scala/src/test/scala/org/apache/fury/serializer/scala/SerializerTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class SerializerTest extends AnyFlatSpec with Matchers { | ||
"ScalaCollectionSerializer" should "copy collections correctly" in { | ||
val fury = new Fury() | ||
val original = Seq(1, 2, 3) | ||
val serializer = new ScalaCollectionSerializer[Int, Seq[Int]](fury, classOf[Seq[Int]]) | ||
|
||
val copy = serializer.copy(original) | ||
copy shouldEqual original | ||
copy should not be theSameInstanceAs (original) | ||
} | ||
|
||
"ScalaMapSerializer" should "copy maps correctly" in { | ||
val fury = new Fury() | ||
val original = Map("a" -> 1, "b" -> 2) | ||
val serializer = new ScalaMapSerializer[String, Int, Map[String, Int]](fury, classOf[Map[String, Int]]) | ||
|
||
val copy = serializer.copy(original) | ||
copy shouldEqual original | ||
copy should not be theSameInstanceAs (original) | ||
} | ||
} |