IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 8ffafdb2 authored by ralfulrich's avatar ralfulrich
Browse files

fix the non-boost case, and tests

parent 264edd6a
No related branches found
No related tags found
No related merge requests found
find_package (Boost OPTIONAL_COMPONENTS iostreams)
if (Boost_iostreams_FOUND)
if (Boost_IOSTREAMS_FOUND)
set (
files
source/Interface.boost.cc
)
else (Boost_iostreams_FOUND)
else (Boost_IOSTREAMS_FOUND)
message (STATUS "Boost::iostreams not found, data tables need to be unpacked with bunzip2 manually!")
set (
files
source/Interface.dummy.cc
)
endif (Boost_iostreams_FOUND)
endif (Boost_IOSTREAMS_FOUND)
add_library (CorsikaData STATIC ${files})
if (Boost_iostreams_FOUND)
if (Boost_IOSTREAMS_FOUND)
target_link_libraries (CorsikaData PUBLIC Boost::iostreams)
endif (Boost_iostreams_FOUND)
endif (Boost_IOSTREAMS_FOUND)
set_target_properties (
CorsikaData
......@@ -43,9 +43,9 @@ install (
if (COMMAND CORSIKA_ADD_TEST)
CORSIKA_ADD_TEST (testData SOURCES source/testData.cc)
set (TEST_WITH_BOOST "")
if (Boost_iostreams_FOUND)
if (Boost_IOSTREAMS_FOUND)
set (TEST_WITH_BOOST "TEST_WITH_BOOST")
endif (Boost_iostreams_FOUND)
endif (Boost_IOSTREAMS_FOUND)
target_compile_definitions (
testData
......
......@@ -13,28 +13,24 @@
namespace corsika_data {
// the c++ interface functions
// void CorDataOpenFile(const char*) {
// std::runtime_error("Cannot read compressed data files with dummy library.");
//}
void CorDataOpenFile(const std::string&) {
std::runtime_error("Cannot read compressed data files with dummy library.");
throw std::runtime_error("Cannot read compressed data files with dummy library.");
}
void CorDataFillArray(double*, const int&) {
std::runtime_error("Cannot read compressed data files with dummy library.");
throw std::runtime_error("Cannot read compressed data files with dummy library.");
}
void CorDataCloseFile() {
std::runtime_error("Cannot read compressed data files with dummy library.");
throw std::runtime_error("Cannot read compressed data files with dummy library.");
}
double CorDataNextNumber() {
std::runtime_error("Cannot read compressed data files with dummy library.");
throw std::runtime_error("Cannot read compressed data files with dummy library.");
return 0;
}
void CorDataNextText(std::string&) {
std::runtime_error("Cannot read compressed data files with dummy library.");
throw std::runtime_error("Cannot read compressed data files with dummy library.");
}
void CorDataNextText(char*, int) {
std::runtime_error("Cannot read compressed data files with dummy library.");
throw std::runtime_error("Cannot read compressed data files with dummy library.");
}
bool CorDataCanDeCompress() { return false; }
......@@ -47,7 +43,7 @@ namespace corsika_data {
void cordataclosefile_() { CorDataCloseFile(); }
double cordatanextnumber_() { return CorDataNextNumber(); }
void cordatanexttext_(char*, int) {
std::runtime_error("Cannot read compressed data files with dummy library.");
throw std::runtime_error("Cannot read compressed data files with dummy library.");
}
int cordatacandecompress_() { return 0; }
}
......
......@@ -13,6 +13,7 @@
#include <corsika_data/Interface.h>
#include <array>
#include <string>
#include <iostream>
using namespace std;
......@@ -33,7 +34,7 @@ TEST_CASE("Data", "[data]") {
#ifdef TEST_WITH_BOOST
auto file = GENERATE(fileName, fileNameBZ2);
auto file = GENERATE(as<std::string>{}, fileName, fileNameBZ2);
SECTION(std::string("c++,") + file) {
bool b = CorDataCanDeCompress();
......@@ -104,8 +105,8 @@ TEST_CASE("Data", "[data]") {
CHECK_THROWS( cordataclosefile_());
double d = 0;
CHECK_THROWS( d = cordatanextnumber_());
std::string str(" ");
CHECK_THROWS( cordatanexttext_(str.c_str(), 0));
char* buf = 0;
CHECK_THROWS( cordatanexttext_(buf, 0));
CHECK( cordatacandecompress_() == 0);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment