2019-08-14 12:25:02 +03:00
|
|
|
import
|
2019-08-14 17:33:14 +02:00
|
|
|
typetraits, unittest,
|
2020-07-08 00:31:20 +03:00
|
|
|
stew/shims/macros, stew/objects,
|
2019-08-14 12:25:02 +03:00
|
|
|
../serialization/object_serialization,
|
|
|
|
../serialization/testing/generic_suite
|
|
|
|
|
2021-01-06 15:27:28 +02:00
|
|
|
suite "object serialization":
|
2021-02-18 23:07:52 +02:00
|
|
|
setup:
|
|
|
|
var fieldsList = newSeq[string]()
|
|
|
|
|
2021-01-06 15:27:28 +02:00
|
|
|
test "custom fields order":
|
2021-02-18 23:07:52 +02:00
|
|
|
enumAllSerializedFields(Simple):
|
|
|
|
fieldsList.add(name(FieldType) & " " & fieldName & fieldCaseDiscriminator)
|
2019-08-14 17:33:14 +02:00
|
|
|
|
2021-02-18 23:07:52 +02:00
|
|
|
check fieldsList == @["Meter distance", "int x", "string y"]
|
2021-01-06 15:27:28 +02:00
|
|
|
|
2021-02-18 23:07:52 +02:00
|
|
|
test "tuples handling":
|
2019-08-14 17:33:14 +02:00
|
|
|
enumAllSerializedFields(HoldsTuples):
|
|
|
|
fieldsList.add(fieldName & ": " & $isTuple(FieldType))
|
|
|
|
|
|
|
|
check fieldsList == @["t1: true", "t2: true", "t3: true"]
|
|
|
|
|