Debian Codegraph @

nixio/test/xcompat/readmultitags.cpp

raw symbols SCIP
1 #include "testutil.hpp"
2 #include <nix.hpp>
3
4
5 int main(int argc, char* argv[]) {
6 if (argc != 2) {
7 std::cerr << "Please specify a nix file (and nothing else)" << std::endl;
8 return 1;
9 }
10 std::string fname = argv[1];
11 nix::File nf = nix::File::open(fname, nix::FileMode::ReadOnly);
12
13 int idx = 0, gidx = 0, errcount = 0;
14 std::string expname, expdef;
15 const auto &block = nf.getBlock("test_block");
16 const auto &grp = block.getGroup("test_group");
17 for (const auto &mt : block.multiTags()) {
18 expname = "mt_" + nix::util::numToStr(idx);
19 errcount += compare(expname, mt.name());
20 errcount += compare("some multi tag", mt.type());
21 //extent and positions
22 nix::NDSize extentSize = {idx*10};
23 if (idx == 1) {
24 errcount += compare(mt.positions().dataExtent(), extentSize);
25 } else if (idx == 5) {
26 extentSize = {5,5};
27 errcount += compare(mt.positions().dataExtent(), extentSize);
28 errcount += compare(mt.extents().dataExtent(), extentSize);
29 } else {
30 errcount += compare(mt.positions().dataExtent(), extentSize);
31 errcount += compare(extentSize, mt.extents().dataExtent());
32 }
33 //reference and unit
34 if (idx ==2){
35 errcount += compare(mt.units(), std::vector<std::string>{"ms"});
36 errcount += compare(static_cast<int>(mt.references().size()), 1);
37 nix::NDSize refSize = {13};
38 const auto &ref = mt.getReference("ref");
39 errcount += compare(ref.dataExtent(), refSize);
40 const auto &rdim = ref.dimensions()[0].asRangeDimension();
41 errcount += compare(*rdim.label(), "A");
42 errcount += compare(rdim.ticks(), std::vector<double>{0.1, 0.2, 0.3});
43 } else {
44 errcount += compare(mt.units(), std::vector<std::string>{"mV", "s", "Hz"});
45 errcount += compare(static_cast<int>(mt.references().size()), 0);
46 }
47 //feature
48 if (idx == 3) {
49 nix::NDSize feaSize = {200};
50 errcount += compare(mt.hasFeature("feature"), true);
51 const auto &fea = mt.getFeature("feature");
52 errcount += compare(fea.data().dataExtent(), feaSize);
53 } else {
54 errcount += compare(mt.hasFeature("feature"), false);
55 }
56 //group append
57 if(idx % 3 == 0) {
58 errcount += compare(grp.getMultiTag(gidx++).id(), mt.id());
59 }
60 expdef = "mt def " + nix::util::numToStr(10 * idx++);
61 errcount += compare(expdef, mt.definition());
62
63 }
64
65
66 return errcount;
67 }