From ea6525a260640eba851a6e7212ed1b35b70349eb Mon Sep 17 00:00:00 2001 From: Vindaar Date: Fri, 8 Nov 2024 12:49:04 +0100 Subject: [PATCH] [tests] test for `[]` for attributes taking only string (data kind) --- tests/tattributes.nim | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/tattributes.nim b/tests/tattributes.nim index d1ef488..05ec5c0 100644 --- a/tests/tattributes.nim +++ b/tests/tattributes.nim @@ -32,19 +32,20 @@ proc write_attrs(grp: var H5Group) = grp.attrs["ComplexNamedSeqTuple"] = NamedTupSeqComplexAttr proc assert_attrs(grp: var H5Group) = - template readAndCheck(arg, typ, exp): untyped = + template readAndCheck(arg, typ, exp, kind): untyped = let data = grp.attrs[arg, typ] echo "Read: ", data doAssert data == exp, "Mismatch, was = " & $data & ", but expected = " & $exp - - readAndCheck("Time", string, TimeStr) - readAndCheck("Counter", int, Counter) - readAndCheck("Seq", seq[int], SeqAttr) - readAndCheck("SeqStr", seq[string], SeqStrAttr) - readAndCheck("Tuple", (float, int), TupAttr) - readAndCheck("NamedTuple", tuple[foo: float, bar: int], NamedTupAttr) - readAndCheck("ComplexNamedTuple", tuple[foo: string, bar: float], NamedTupStrAttr) - readAndCheck("ComplexNamedSeqTuple", seq[tuple[foo: string, bar: float]], NamedTupSeqComplexAttr) + doAssert grp.attrs[arg] == kind, "Mismatch, was = " & $grp.attrs[arg] & ", but expected = " & $kind + + readAndCheck("Time", string, TimeStr, dkString) + readAndCheck("Counter", int, Counter, dkInt64) + readAndCheck("Seq", seq[int], SeqAttr, dkSequence) + readAndCheck("SeqStr", seq[string], SeqStrAttr, dkSequence) + readAndCheck("Tuple", (float, int), TupAttr, dkObject) + readAndCheck("NamedTuple", tuple[foo: float, bar: int], NamedTupAttr, dkObject) + readAndCheck("ComplexNamedTuple", tuple[foo: string, bar: float], NamedTupStrAttr, dkObject) + readAndCheck("ComplexNamedSeqTuple", seq[tuple[foo: string, bar: float]], NamedTupSeqComplexAttr, dkSequence) doAssert("Time" in grp.attrs) doAssert("NoTime" notin grp.attrs)