Skip to content
This repository was archived by the owner on Feb 20, 2019. It is now read-only.

Commit 00a198d

Browse files
committed
Add tests for Tuple2 (normal and specialized)
Now, we support pickling and unpickling specialized tuples. It's necessary to add a special method to check class equality since the specialized classes are implemented as subclasses and therefore have its own class name, failing a simple class equality.
1 parent 34fa143 commit 00a198d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package scala.pickling.generation.pickler
2+
3+
import org.scalatest.FunSuite
4+
5+
import scala.pickling._
6+
import Defaults._
7+
import json._
8+
import scala.pickling.util.ClassMapper
9+
import static._
10+
11+
class Tuple2Pickler extends FunSuite {
12+
13+
test("pickle/unpickle (Int, String)") {
14+
val t = (1, "")
15+
val t2 = t.pickle.unpickle[(Int, String)]
16+
assert(t === t2)
17+
}
18+
19+
test("pickle/unpickle any specialized tuple like (Int, Int)") {
20+
val t = (1, 2)
21+
val clz = classOf[(Int, Int)]
22+
val clzT = t.getClass
23+
println(ClassMapper.areSameClasses(clzT, clz))
24+
val t2 = t.pickle.unpickle[(Int, Int)]
25+
assert(t === t2)
26+
}
27+
28+
}

0 commit comments

Comments
 (0)