| 1 | #include "testutil.hpp" |
| 2 | #include <nix.hpp> |
| 3 | |
| 4 | |
| 5 | std::vector<nix::DataType> dtypes = { |
| 6 | nix::DataType::UInt8, |
| 7 | nix::DataType::UInt16, |
| 8 | nix::DataType::UInt32, |
| 9 | nix::DataType::UInt64, |
| 10 | nix::DataType::Int8, |
| 11 | nix::DataType::Int16, |
| 12 | nix::DataType::Int32, |
| 13 | nix::DataType::Int64, |
| 14 | nix::DataType::Float, |
| 15 | nix::DataType::Double, |
| 16 | nix::DataType::String, |
| 17 | nix::DataType::Bool |
| 18 | }; |
| 19 | |
| 20 | |
| 21 | int checkChildrenCounts(const nix::Block &bl, size_t ngrp, size_t nda, size_t nt, size_t nmt) { |
| 22 | int errcount = 0; |
| 23 | errcount += testassert(ngrp == bl.groupCount(), "Group count mismatch in Block " + bl.name()); |
| 24 | errcount += testassert(nda == bl.dataArrayCount(), "DataArray count mismatch in Block " + bl.name()); |
| 25 | errcount += testassert(nt == bl.tagCount(), "Tag count mismatch in Block " + bl.name()); |
| 26 | errcount += testassert(nmt == bl.multiTagCount(), "MultiTag count mismatch in Block " + bl.name()); |
| 27 | |
| 28 | return errcount; |
| 29 | } |
| 30 | |
| 31 | int checkChildrenCounts(const nix::Group &grp, size_t nda, size_t nt, size_t nmt) { |
| 32 | int errcount = 0; |
| 33 | errcount += testassert(nda == grp.dataArrayCount(), "DataArray count mismatch in Group " + grp.name()); |
| 34 | errcount += testassert(nt == grp.tagCount(), "Tag count mismatch in Group " + grp.name()); |
| 35 | errcount += testassert(nmt == grp.multiTagCount(), "MultiTag count mismatch in Group " + grp.name()); |
| 36 | |
| 37 | return errcount; |
| 38 | } |
| 39 | |
| 40 | int checkObjectCounts(const nix::File &nf) { |
| 41 | int errcount = 0; |
| 42 | // Check object counts (Group, DataArray, Tag, MultiTag) |
| 43 | errcount += testassert(4 == nf.blockCount(), "Block count mismatch"); |
| 44 | |
| 45 | errcount += checkChildrenCounts(nf.getBlock(0), 2, 4, 1, 1); |
| 46 | errcount += checkChildrenCounts(nf.getBlock(1), 2, 2, 0, 0); |
| 47 | errcount += checkChildrenCounts(nf.getBlock(2), 2, 3, 1, 1); |
| 48 | errcount += checkChildrenCounts(nf.getBlock(3), 0, 13, 0, 0); |
| 49 | |
| 50 | errcount += checkChildrenCounts(nf.getBlock(0).getGroup(0), 1, 1, 0); |
| 51 | errcount += checkChildrenCounts(nf.getBlock(0).getGroup(1), 0, 0, 0); |
| 52 | |
| 53 | errcount += checkChildrenCounts(nf.getBlock(1).getGroup(0), 0, 0, 0); |
| 54 | errcount += checkChildrenCounts(nf.getBlock(1).getGroup(1), 0, 0, 0); |
| 55 | |
| 56 | errcount += checkChildrenCounts(nf.getBlock(2).getGroup(0), 0, 1, 1); |
| 57 | errcount += checkChildrenCounts(nf.getBlock(2).getGroup(1), 0, 0, 0); |
| 58 | |
| 59 | return errcount; |
| 60 | } |
| 61 | |
| 62 | int main(int argc, char* argv[]) { |
| 63 | if (argc != 2) { |
| 64 | std::cerr << "Please specify a nix file (and nothing else)" << std::endl; |
| 65 | return 1; |
| 66 | } |
| 67 | std::string fname = argv[1]; |
| 68 | nix::File nf = nix::File::open(fname, nix::FileMode::ReadOnly); |
| 69 | |
| 70 | int errcount = 0; |
| 71 | errcount += checkObjectCounts(nf); |
| 72 | |
| 73 | auto block = nf.getBlock(0); |
| 74 | // Check first block attrs before descending |
| 75 | errcount += compare("blockyblock", block.name()); |
| 76 | errcount += compare("ablocktype of thing", block.type()); |
| 77 | errcount += compare("I am a test block", block.definition()); |
| 78 | |
| 79 | block = nf.getBlock(1); |
| 80 | // Check second block attrs (no children) |
| 81 | errcount += compare("I am another block", block.name()); |
| 82 | errcount += compare("void", block.type()); |
| 83 | errcount += compare("Void block of stuff", block.definition()); |
| 84 | |
| 85 | std::string expname, expdef; |
| 86 | size_t bidx = 0, gidx = 0; |
| 87 | for (auto block : nf.blocks()) { |
| 88 | for (const auto &group : block.groups()) { |
| 89 | expname = "grp0" + nix::util::numToStr(bidx) + nix::util::numToStr(gidx); |
| 90 | expdef = expname + "-grp"; |
| 91 | errcount += compare(expname, group.name()); |
| 92 | errcount += compare("grp", group.type()); |
| 93 | errcount += compare(expdef, group.definition()); |
| 94 | errcount += compare(block.createdAt(), group.createdAt()); |
| 95 | gidx++; |
| 96 | } |
| 97 | bidx++; |
| 98 | gidx = 0; |
| 99 | } |
| 100 | |
| 101 | // DataArray |
| 102 | block = nf.getBlock(0); |
| 103 | auto group = block.getGroup(0); |
| 104 | |
| 105 | auto da = block.getDataArray(0); |
| 106 | errcount += compare(da.id(), group.getDataArray(0).id()); |
| 107 | errcount += compare("bunchodata", da.name()); |
| 108 | errcount += compare("recordings", da.type()); |
| 109 | errcount += compare("A silly little data array", da.definition()); |
| 110 | |
| 111 | // Data |
| 112 | std::vector<float_t> dadata(2*3, 1); |
| 113 | da.getData(nix::DataType::Float, dadata.data(), {2, 3}, {}); |
| 114 | errcount += compare({1, 2, 10, 9, 1, 3}, dadata); |
| 115 | errcount += compare({2, 3}, da.dataExtent()); |
| 116 | errcount += testassert(da.dataType() == nix::DataType::Double, "Array dataType mismatch"); |
| 117 | |
| 118 | // DataArray dimensions |
| 119 | auto dim = da.getDimension(1); |
| 120 | errcount += testassert(dim.dimensionType() == nix::DimensionType::Sample, "Dimension 1 should be Sample type"); |
| 121 | nix::SampledDimension smpldim; |
| 122 | smpldim = dim; |
| 123 | errcount += compare(0.1, smpldim.samplingInterval()); |
| 124 | errcount += compare("ms", smpldim.unit()); |
| 125 | errcount += compare("time", smpldim.label()); |
| 126 | |
| 127 | dim = da.getDimension(2); |
| 128 | errcount += testassert(dim.dimensionType() == nix::DimensionType::Set, "Dimension 2 should be Set type"); |
| 129 | nix::SetDimension setdim; |
| 130 | setdim = dim; |
| 131 | errcount += compare({"a", "b"}, setdim.labels()); |
| 132 | |
| 133 | // DataFrame |
| 134 | auto df = block.getDataFrame(0); |
| 135 | size_t n = 3; |
| 136 | std::vector<float_t> dou_out(n); |
| 137 | std::vector<std::string> str_out(n); |
| 138 | errcount += compare("adataframe", df.name()); |
| 139 | errcount += compare("4-column df", df.type()); |
| 140 | errcount += compare(nix::ndsize_t{n}, df.rows()); |
| 141 | errcount += compare(df.readRow(nix::ndsize_t{0}), {nix::Variant("Bob"), |
| 142 | nix::Variant(int64_t(9)), nix::Variant(11.28), nix::Variant(false)}); |
| 143 | df.readColumn(0, str_out); |
| 144 | errcount += compare(str_out, {"Bob", "Jane", "Alice"}); |
| 145 | df.readColumn(2, dou_out); |
| 146 | errcount += compare(dou_out, {11.28, 14.37, 3.7}); |
| 147 | nix::ndsize_t rown = 1; |
| 148 | std::vector<nix::Cell> cells = df.readCells(rown, {"name", "Adjusted"}); |
| 149 | std::vector<nix::Cell> def_cells = { |
| 150 | {"name", nix::Variant{"Jane"}}, |
| 151 | {"Adjusted", nix::Variant{true}} |
| 152 | }; |
| 153 | errcount += compare(cells, def_cells); |
| 154 | std::vector<nix::Column> cols = df.columns(); |
| 155 | for(size_t i = 0; i < cols.size(); i++){ |
| 156 | errcount += compare("", cols[i].unit); |
| 157 | } |
| 158 | |
| 159 | // Tag |
| 160 | auto tag = block.getTag(0); |
| 161 | errcount += compare("tagu", tag.name()); |
| 162 | errcount += compare("tagging", tag.type()); |
| 163 | errcount += compare("tags ahoy", tag.definition()); |
| 164 | errcount += compare({1, 0}, tag.position()); |
| 165 | errcount += compare({1, 10}, tag.extent()); |
| 166 | errcount += compare({"mV", "s"}, tag.units()); |
| 167 | errcount += compare(da.id(), tag.getReference(0).id()); |
| 168 | errcount += compare(group.getTag(0).id(), tag.id()); |
| 169 | auto feature = tag.getFeature("feat-da"); |
| 170 | errcount += compare(feature.linkType(), nix::LinkType::Untagged); |
| 171 | errcount += compare(feature.data().id(), block.getDataArray(1).id()); |
| 172 | errcount += compare("feat-da", feature.data().name()); |
| 173 | errcount += compare(nix::NDSize{6}, feature.data().dataExtent()); |
| 174 | std::vector<float_t> featdata(6); |
| 175 | feature.data().getData(nix::DataType::Float, featdata.data(), {6}, {}); |
| 176 | errcount += compare({0.4, 0.41, 0.49, 0.1, 0.1, 0.1}, featdata); |
| 177 | |
| 178 | // MultiTag |
| 179 | auto mtag = block.getMultiTag(0); |
| 180 | errcount += compare("mtagu", mtag.name()); |
| 181 | errcount += compare("multi tagging", mtag.type()); |
| 182 | errcount += compare("", mtag.definition()); |
| 183 | auto posmt = mtag.positions(); |
| 184 | auto extmt = mtag.extents(); |
| 185 | errcount += compare(block.getDataArray(posmt.name()).id(), posmt.id()); |
| 186 | errcount += compare(block.getDataArray(extmt.name()).id(), extmt.id()); |
| 187 | |
| 188 | // MultiTag data |
| 189 | errcount += compare("tag-data", posmt.name()); |
| 190 | errcount += compare("multi-tagger", posmt.type()); |
| 191 | errcount += compare("tag-extents", extmt.name()); |
| 192 | errcount += compare("multi-tagger", extmt.type()); |
| 193 | |
| 194 | errcount += compare(nix::NDSize{1, 3}, posmt.dataExtent()); |
| 195 | std::vector<float_t> posdata(3*1, 1); |
| 196 | posmt.getData(nix::DataType::Float, posdata.data(), {1, 3}, {}); |
| 197 | errcount += compare({0, 0.1, 10.1}, posdata); |
| 198 | errcount += testassert(posmt.dataType() == nix::DataType::Double, "Array dataType mismatch"); |
| 199 | |
| 200 | errcount += compare(nix::NDSize{1, 3}, extmt.dataExtent()); |
| 201 | std::vector<float_t> extdata(3*1, 1); |
| 202 | extmt.getData(nix::DataType::Float, extdata.data(), {1, 3}, {}); |
| 203 | errcount += compare({0.5, 0.5, 0.5}, extdata); |
| 204 | errcount += testassert(extmt.dataType() == nix::DataType::Double, "Array dataType mismatch"); |
| 205 | |
| 206 | // MultiTag Position and Extent dimensions |
| 207 | errcount += testassert(2 == posmt.dimensionCount(), "Dimension count mismatch in posmt"); |
| 208 | dim = posmt.getDimension(2); |
| 209 | errcount += testassert(dim.dimensionType() == nix::DimensionType::Set, "Dimension 2 should be Set type"); |
| 210 | |
| 211 | dim = posmt.getDimension(1); |
| 212 | errcount += testassert(dim.dimensionType() == nix::DimensionType::Sample, "Dimension 1 should be Sample type"); |
| 213 | smpldim = dim; |
| 214 | errcount += compare(0.01, smpldim.samplingInterval()); |
| 215 | errcount += compare("s", smpldim.unit()); |
| 216 | |
| 217 | errcount += testassert(2 == extmt.dimensionCount(), "Dimension count mismatch in extmt"); |
| 218 | dim = extmt.getDimension(2); |
| 219 | errcount += testassert(dim.dimensionType() == nix::DimensionType::Set, "Dimension 2 should be Set type"); |
| 220 | |
| 221 | dim = extmt.getDimension(1); |
| 222 | errcount += testassert(dim.dimensionType() == nix::DimensionType::Sample, "Dimension 1 should be Sample type"); |
| 223 | smpldim = dim; |
| 224 | errcount += compare(0.01, smpldim.samplingInterval()); |
| 225 | errcount += compare("s", smpldim.unit()); |
| 226 | |
| 227 | // Tag and MultiTag Block and Group membership |
| 228 | for (size_t idx = 1; idx < nf.blockCount(); idx++) { |
| 229 | errcount += testassert(!nf.getBlock(idx).hasTag(tag.id()), "Tag found in incorrect Block"); |
| 230 | errcount += testassert(!nf.getBlock(idx).hasMultiTag(mtag.id()), "MultiTag found in incorrect Block"); |
| 231 | } |
| 232 | |
| 233 | errcount += testassert(!group.hasMultiTag(mtag.id()), "MultiTag found in incorrect Group"); |
| 234 | for (size_t idx = 1; idx < block.groupCount(); idx++) { |
| 235 | errcount += testassert(!block.getGroup(idx).hasTag(tag.id()), "Tag found in incorrect Group"); |
| 236 | errcount += testassert(!block.getGroup(idx).hasMultiTag(mtag.id()), "MultiTag found in incorrect Group"); |
| 237 | } |
| 238 | |
| 239 | // Second Block DataArray |
| 240 | block = nf.getBlock(1); |
| 241 | da = block.getDataArray(0); |
| 242 | errcount += compare("FA001", da.name()); |
| 243 | errcount += compare("Primary data", da.type()); |
| 244 | errcount += testassert(nix::DataType::Int64 == da.dataType(), "Array DataType mismatch (Block 1; DataArray 0)"); |
| 245 | |
| 246 | // Sources |
| 247 | block = nf.getBlock(0); |
| 248 | errcount += testassert(1 == block.sourceCount(), "Source count mismatch (Block 0)"); |
| 249 | auto src = block.getSource("root-source"); |
| 250 | errcount += compare("top-level-source", src.type()); |
| 251 | for (auto da : block.dataArrays()) { |
| 252 | errcount += compare(da.getSource(0).id(), src.id()); |
| 253 | } |
| 254 | |
| 255 | errcount += testassert(2 == src.sourceCount(), "Source count mismatch (Block 0; Source 0)"); |
| 256 | errcount += compare("d1-source", src.getSource(0).name()); |
| 257 | errcount += compare("d1-source-2", src.getSource(1).name()); |
| 258 | errcount += compare("second-level-source", src.getSource(0).type()); |
| 259 | errcount += compare("second-level-source", src.getSource(1).type()); |
| 260 | |
| 261 | for (auto s : src.sources()) { |
| 262 | errcount += testassert(0 == s.sourceCount()); |
| 263 | } |
| 264 | |
| 265 | da = block.getDataArray(0); |
| 266 | errcount += testassert(2 == da.sourceCount(), "Source count mismatch (Block 0; DataArray 0)"); |
| 267 | errcount += compare(da.getSource(1).id(), block.getSource(0).getSource(0).id()); |
| 268 | |
| 269 | // Metadata |
| 270 | // 3 root sections |
| 271 | errcount += testassert(3 == nf.sectionCount(), "Section count mismatch (root)"); |
| 272 | errcount += compare(nf.getSection(0).name(), "mda"); |
| 273 | errcount += compare(nf.getSection(1).name(), "mdb"); |
| 274 | errcount += compare(nf.getSection(2).name(), "mdc"); |
| 275 | for (auto s : nf.sections()) { |
| 276 | errcount += compare("root-section", s.type()); |
| 277 | } |
| 278 | |
| 279 | auto mdc = nf.getSection(2); |
| 280 | errcount += testassert(6 == mdc.sectionCount(), "Section count mismatch (mdc)"); |
| 281 | char name [7]; |
| 282 | for (int idx = 0; idx < 6; idx++) { |
| 283 | sprintf(name, "%03d-md", idx); |
| 284 | errcount += compare("d1-section", mdc.getSection(name).type()); |
| 285 | } |
| 286 | |
| 287 | auto mdb = nf.getSection(1); |
| 288 | errcount += compare(nf.getBlock(0).metadata().id(), mdb.id()); |
| 289 | errcount += compare(nf.getBlock(2).metadata().id(), mdb.id()); |
| 290 | |
| 291 | errcount += compare(nf.getBlock(1).getDataArray(0).metadata().id(), nf.getSection("mda").id()); |
| 292 | errcount += compare(nf.getBlock(0).getTag(0).metadata().id(), nf.getSection("mdc").getSection(3).id()); |
| 293 | |
| 294 | block = nf.getBlock(2); |
| 295 | tag = block.getTag(0); |
| 296 | errcount += compare("POI", tag.name()); |
| 297 | errcount += compare("TAG", tag.type()); |
| 298 | errcount += compare({0, 0}, tag.position()); |
| 299 | errcount += compare({1920, 1080}, tag.extent()); |
| 300 | errcount += compare({"mm", "mm"}, tag.units()); |
| 301 | errcount += compare(tag.id(), block.getGroup(0).getTag(0).id()); |
| 302 | |
| 303 | feature = tag.getFeature("some-sort-of-image?"); |
| 304 | errcount += compare(feature.linkType(), nix::LinkType::Indexed); |
| 305 | errcount += compare(feature.data().id(), block.getDataArray(0).id()); |
| 306 | errcount += compare("some-sort-of-image?", feature.data().name()); |
| 307 | errcount += compare(nix::NDSize{3840, 2160}, feature.data().dataExtent()); |
| 308 | |
| 309 | mtag = block.getMultiTag(0); |
| 310 | errcount += compare("nu-mt", mtag.name()); |
| 311 | errcount += compare("multi-tag (new)", mtag.type()); |
| 312 | posmt = mtag.positions(); |
| 313 | errcount += compare("nu-pos", posmt.name()); |
| 314 | errcount += compare("multi-tag-positions", posmt.type()); |
| 315 | errcount += compare({10, 3}, posmt.dataExtent()); |
| 316 | errcount += testassert(nix::DataType::Double == posmt.dataType(), "DataType mismatch in nu-pos DataArray"); |
| 317 | errcount += compare(posmt.id(), block.getDataArray(1).id()); |
| 318 | errcount += compare(mtag.id(), block.getGroup(0).getMultiTag(0).id()); |
| 319 | |
| 320 | // Data with range dimension |
| 321 | block = nf.getBlock(2); |
| 322 | da = block.getDataArray("the ticker"); |
| 323 | std::vector<int32_t> tickerdata(3); |
| 324 | da.getData(nix::DataType::Int32, tickerdata.data(), nix::NDSize{3}, nix::NDSize{0}); |
| 325 | errcount += compare({0, 1, 23}, tickerdata); |
| 326 | errcount += compare({3}, da.dataExtent()); |
| 327 | errcount += compare("range-dim-array", da.type()); |
| 328 | errcount += compare("uA", da.unit()); |
| 329 | errcount += testassert(da.dataType() == nix::DataType::Int32, "Array DataType mismatch"); |
| 330 | dim = da.getDimension(1); |
| 331 | nix::RangeDimension rdim; |
| 332 | rdim = dim; |
| 333 | errcount += testassert(rdim.dimensionType() == nix::DimensionType::Range, "Dimension 1 should be Range type"); |
| 334 | |
| 335 | auto tickdata = rdim.ticks(); |
| 336 | errcount += compare(size_t{50}, tickdata.size()); |
| 337 | errcount += compare("a range dimension", rdim.label()); |
| 338 | errcount += compare("s", rdim.unit()); |
| 339 | |
| 340 | // Alias range dimension |
| 341 | block = nf.getBlock(1); |
| 342 | da = block.getDataArray("alias da"); |
| 343 | errcount += compare("dimticks", da.type()); |
| 344 | errcount += compare("F", da.unit()); |
| 345 | errcount += compare("alias dimension label", da.label()); |
| 346 | errcount += compare({24}, da.dataExtent()); |
| 347 | std::vector<double> aliasdata(24); |
| 348 | da.getData(nix::DataType::Double, aliasdata.data(), nix::NDSize{24}, nix::NDSize{0}); |
| 349 | dim = da.getDimension(1); |
| 350 | rdim = dim; |
| 351 | errcount += testassert(rdim.dimensionType() == nix::DimensionType::Range, "Dimension 1 should be Range type"); |
| 352 | errcount += testassert(rdim.alias(), "Dimension 1 should be alias Range dimension"); |
| 353 | |
| 354 | errcount += compare(aliasdata, rdim.ticks()); |
| 355 | |
| 356 | // Metadata types |
| 357 | mdb = nf.getSection("mdb"); |
| 358 | errcount += testassert(1 == mdb.sectionCount(), "mdb child section count mismatch"); |
| 359 | auto proptypesmd = mdb.getSection("prop-test-parent"); |
| 360 | errcount += compare("test metadata section", proptypesmd.type()); |
| 361 | errcount += testassert(2 == proptypesmd.sectionCount(), "prop-test-parent child section count mismatch"); |
| 362 | |
| 363 | auto numbermd = proptypesmd.getSection(0); |
| 364 | errcount += compare("numerical metadata", numbermd.name()); |
| 365 | errcount += compare("test metadata section", numbermd.type()); |
| 366 | errcount += compare(nix::ndsize_t{4}, numbermd.propertyCount()); |
| 367 | |
| 368 | auto prop = numbermd.getProperty("integer"); |
| 369 | errcount += compare(nix::ndsize_t{1}, prop.valueCount()); |
| 370 | errcount += compare({nix::Variant{int64_t(42)}}, prop.values()); |
| 371 | |
| 372 | prop = numbermd.getProperty("double"); |
| 373 | errcount += compare(nix::ndsize_t{1}, prop.valueCount()); |
| 374 | errcount += compare({nix::Variant{double(4.2)}}, prop.values()); |
| 375 | |
| 376 | prop = numbermd.getProperty("integers"); |
| 377 | errcount += compare(nix::ndsize_t{6}, prop.valueCount()); |
| 378 | std::vector<nix::Variant> values(6); |
| 379 | for (auto idx = 0; idx < 6; idx++) |
| 380 | values[idx] = nix::Variant{int64_t(40 + idx)}; |
| 381 | errcount += compare(values, prop.values()); |
| 382 | |
| 383 | prop = numbermd.getProperty("doubles"); |
| 384 | errcount += compare(nix::ndsize_t{2}, prop.valueCount()); |
| 385 | errcount += compare({nix::Variant{double(1.1)}, nix::Variant{double(10.10)}}, prop.values()); |
| 386 | |
| 387 | auto othermd = proptypesmd.getSection(1); |
| 388 | errcount += compare("other metadata", othermd.name()); |
| 389 | errcount += compare("test metadata section", othermd.type()); |
| 390 | errcount += compare(nix::ndsize_t{6}, othermd.propertyCount()); |
| 391 | |
| 392 | prop = othermd.getProperty("bool"); |
| 393 | errcount += compare(nix::ndsize_t{1}, prop.valueCount()); |
| 394 | errcount += compare({nix::Variant{true}}, prop.values()); |
| 395 | |
| 396 | prop = othermd.getProperty("false bool"); |
| 397 | errcount += compare(nix::ndsize_t{1}, prop.valueCount()); |
| 398 | errcount += compare({nix::Variant{false}}, prop.values()); |
| 399 | |
| 400 | prop = othermd.getProperty("bools"); |
| 401 | errcount += compare(nix::ndsize_t{3}, prop.valueCount()); |
| 402 | errcount += compare({nix::Variant{true}, nix::Variant{false}, nix::Variant{true}}, prop.values()); |
| 403 | |
| 404 | prop = othermd.getProperty("string"); |
| 405 | errcount += compare(nix::ndsize_t{1}, prop.valueCount()); |
| 406 | errcount += compare({nix::Variant{"I am a string. Rawr."}}, prop.values()); |
| 407 | |
| 408 | prop = othermd.getProperty("strings"); |
| 409 | errcount += compare(nix::ndsize_t{3}, prop.valueCount()); |
| 410 | errcount += compare({nix::Variant{"one"}, nix::Variant{"two"}, nix::Variant{"twenty"}}, prop.values()); |
| 411 | |
| 412 | prop = othermd.getProperty("unicode"); |
| 413 | errcount += compare(nix::ndsize_t{4}, prop.valueCount()); |
| 414 | errcount += compare({nix::Variant("Μπύρα"), nix::Variant("Bräu"), nix::Variant("啤酒"), nix::Variant("🍺")}, prop.values()); |
| 415 | |
| 416 | block = nf.getBlock("datablock"); |
| 417 | errcount += compare("block of data", block.type()); |
| 418 | |
| 419 | for (size_t idx = 0; idx < dtypes.size(); idx++) { |
| 420 | da = block.getDataArray(idx); |
| 421 | auto dt = dtypes[idx]; |
| 422 | errcount += compare(dt, da.dataType()); |
| 423 | errcount += compare({1}, da.dataExtent()); |
| 424 | } |
| 425 | |
| 426 | // Unicode data |
| 427 | auto unicodeda = block.getDataArray("unicodedata"); |
| 428 | std::vector<std::string> unicode_array(4); |
| 429 | unicodeda.getData(nix::DataType::String, unicode_array.data(), {4}, {}); |
| 430 | errcount += compare({"Καφές", "Café", "咖啡", "☕"}, unicode_array); |
| 431 | |
| 432 | return errcount; |
| 433 | } |