2020-12-21 11:45:07 +00:00
|
|
|
import
|
2021-10-06 13:10:43 +00:00
|
|
|
typetraits, unittest2,
|
2020-12-21 11:45:07 +00:00
|
|
|
stew/shims/macros, stew/objects,
|
|
|
|
../serialization/object_serialization,
|
|
|
|
../serialization/testing/generic_suite
|
|
|
|
|
2021-10-06 13:10:43 +00:00
|
|
|
{.used.}
|
|
|
|
|
2021-02-02 11:46:38 +00:00
|
|
|
suite "object serialization":
|
2021-03-17 09:20:33 +00:00
|
|
|
setup:
|
|
|
|
var fieldsList = newSeq[string]()
|
|
|
|
|
2021-02-02 11:46:38 +00:00
|
|
|
test "custom fields order":
|
2021-03-17 09:20:33 +00:00
|
|
|
enumAllSerializedFields(Simple):
|
|
|
|
fieldsList.add(name(FieldType) & " " & fieldName & fieldCaseDiscriminator)
|
2020-12-21 11:45:07 +00:00
|
|
|
|
2021-03-17 09:20:33 +00:00
|
|
|
check fieldsList == @["Meter distance", "int x", "string y"]
|
2021-02-02 11:46:38 +00:00
|
|
|
|
2021-03-17 09:20:33 +00:00
|
|
|
test "tuples handling":
|
2020-12-21 11:45:07 +00:00
|
|
|
enumAllSerializedFields(HoldsTuples):
|
|
|
|
fieldsList.add(fieldName & ": " & $isTuple(FieldType))
|
|
|
|
|
|
|
|
check fieldsList == @["t1: true", "t2: true", "t3: true"]
|
|
|
|
|