SDDS ToolKit Programs and Libraries for C and Python
Loading...
Searching...
No Matches
test_sdds3_differential.cc File Reference

Detailed Description

Differential serial-format tests between the C and C++ SDDS libraries.

Writes representative files with each implementation and verifies that the other implementation reads the same layout and values.

License
This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.

Definition in file test_sdds3_differential.cc.

#include "SDDS.hpp"
#include "SDDS.h"
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <filesystem>
#include <fstream>
#include <string>
#include <vector>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 312 of file test_sdds3_differential.cc.

312 {
313#if defined(_WIN32)
314 _putenv_s("SDDS_LONGDOUBLE_64BITS", "1");
315#endif
316 if (argc != 2) return 2;
317 const std::filesystem::path directory(argv[1]);
318 std::filesystem::create_directories(directory);
319 const auto cOutput = directory / "c-to-cpp.sdds";
320 cWrite(cOutput);
321 cppRead(cOutput);
322 for (const auto mode : {sdds::DataMode::Ascii, sdds::DataMode::Binary}) {
323 for (const auto major : {sdds::MajorOrder::Row, sdds::MajorOrder::Column}) {
324 if (mode == sdds::DataMode::Ascii && major == sdds::MajorOrder::Column) continue;
325 for (const auto order : {sdds::ByteOrder::Little, sdds::ByteOrder::Big}) {
326 const auto path = directory / (std::string(mode == sdds::DataMode::Ascii ? "ascii" : "binary") +
327 (major == sdds::MajorOrder::Row ? "-row" : "-column") +
328 (order == sdds::ByteOrder::Little ? "-little.sdds" :
329 "-big.sdds"));
330 cppWrite(path, mode, major, order);
331 cRead(path);
332 }
333 }
334 }
335 for (const auto compression : {sdds::Compression::Gzip, sdds::Compression::Xz,
336 sdds::Compression::Lzma}) {
337 const char *extension = compression == sdds::Compression::Gzip ? ".sdds.gz" :
338 compression == sdds::Compression::Xz ? ".sdds.xz" : ".sdds.lzma";
339 const auto path = directory / (std::string("compressed") + extension);
340 cppWrite(path, sdds::DataMode::Binary, sdds::MajorOrder::Row,
341 sdds::ByteOrder::Little, compression);
342 cRead(path);
343 }
344 versionMatrix(directory);
345 rowCountMatrix(directory);
346 includeMatrix(directory);
347 return 0;
348}