| 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 | for (const auto &da : block.dataArrays()) { |
| 17 | expname = "data_" + nix::util::numToStr(idx); |
| 18 | if (idx%2==0){ |
| 19 | errcount += compare(*da.expansionOrigin() , 100.0); |
| 20 | const auto &group = block.getGroup("test_group"); |
| 21 | size_t z = idx/2; |
| 22 | errcount += compare(group.getDataArray(z).name(), da.name()); |
| 23 | errcount += compare(group.getDataArray(z).id(), block.getDataArray(idx).id()); |
| 24 | } |
| 25 | if (idx%3 == 0){ |
| 26 | std::vector<double> tmpPoly = {0.1, 0.2, 0.3}; |
| 27 | errcount += compare(da.polynomCoefficients(), tmpPoly); |
| 28 | } else{ |
| 29 | errcount += compare(static_cast<int>(da.polynomCoefficients().size()), 0); |
| 30 | } |
| 31 | // dimensions |
| 32 | if (idx == 5){ |
| 33 | auto rd = da.getDimension(1); |
| 34 | errcount += compare(rd.dimensionType(), nix::DimensionType::Range); |
| 35 | nix::RangeDimension rangeDim; |
| 36 | rangeDim = rd; |
| 37 | std::string u = "ms"; |
| 38 | errcount += compare(*rangeDim.unit(), u); |
| 39 | errcount += compare(rangeDim.ticks(), {1.2 ,2.4}); |
| 40 | errcount += compare(*da.unit(), "mV"); |
| 41 | } else if (idx == 6){ |
| 42 | auto setd = da.getDimension(1); |
| 43 | auto sampled = da.getDimension(2); |
| 44 | errcount += compare(setd.dimensionType(), nix::DimensionType::Set); |
| 45 | errcount += compare(sampled.dimensionType(), nix::DimensionType::Sample); |
| 46 | nix::SetDimension setDim; |
| 47 | setDim = setd; |
| 48 | nix::SampledDimension sampledDim; |
| 49 | sampledDim = sampled; |
| 50 | errcount += compare(*sampledDim.unit(), "s"); |
| 51 | errcount += compare(*sampledDim.label(), "dim_label"); |
| 52 | errcount += compare(sampledDim.samplingInterval(), 1.0); |
| 53 | errcount += compare(*sampledDim.offset(), 1.0); |
| 54 | errcount += compare(setDim.labels(), {"a", "b"}); |
| 55 | } |
| 56 | |
| 57 | expdef = "da definition " + nix::util::numToStr(idx++); |
| 58 | errcount += compare(expname, da.name()); |
| 59 | errcount += compare(expdef, da.definition()); |
| 60 | } |
| 61 | return errcount; |
| 62 | } |