Debian Codegraph @

nixio/test/xcompat/readtags.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, errcount = 0;
14 std::string expname, expdef;
15 const auto &block = nf.getBlock("test_block");
16 errcount += compare(static_cast<int>(block.tagCount()), 8);
17 for (const auto &tag : block.tags()) {
18 expname = "tag_" + nix::util::numToStr(idx);
19 errcount += compare(tag.type(), "atag");
20 errcount += compare(expname, tag.name());
21 std::vector<std::string> units;
22 if (idx == 0){
23 units = {"V", "ms"};
24 } else{
25 units = {"mV", "s"};
26 }
27 errcount += compare(tag.units(), units);
28 int positionLen = idx*2;
29 if (idx == 2) {
30 positionLen = 5;
31 }
32 errcount += compare(positionLen, static_cast<int>(tag.position().size()));
33 errcount += compare(positionLen, static_cast<int>(tag.extent().size()));
34 if (idx == 5){
35 errcount += compare(1, static_cast<int>(tag.featureCount()));
36 } else {
37 errcount += compare(0, static_cast<int>(tag.featureCount()));
38 }
39 expdef = "tag def " + nix::util::numToStr(1*idx++);
40 errcount += compare(expdef, tag.definition());
41 }
42 const auto &grp = block.getGroup("test_group");
43 nix::ndsize_t bidx = 3, gidx = 1;
44 errcount += compare(grp.getTag(gidx).id(), block.getTag(bidx).id());
45 return errcount;
46 }