From 8ffafdb21149c05ce1173511d967709b9a3f2636 Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Wed, 15 Jul 2020 14:34:06 +0200
Subject: [PATCH] fix the non-boost case, and tests

---
 readLib/CMakeLists.txt            | 14 +++++++-------
 readLib/source/Interface.dummy.cc | 18 +++++++-----------
 readLib/source/testData.cc        |  7 ++++---
 3 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/readLib/CMakeLists.txt b/readLib/CMakeLists.txt
index c62d4fc..313d20b 100644
--- a/readLib/CMakeLists.txt
+++ b/readLib/CMakeLists.txt
@@ -1,23 +1,23 @@
 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
diff --git a/readLib/source/Interface.dummy.cc b/readLib/source/Interface.dummy.cc
index 5f851ea..d8504ac 100644
--- a/readLib/source/Interface.dummy.cc
+++ b/readLib/source/Interface.dummy.cc
@@ -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; }
   }
diff --git a/readLib/source/testData.cc b/readLib/source/testData.cc
index c5a0a9c..d4002d9 100644
--- a/readLib/source/testData.cc
+++ b/readLib/source/testData.cc
@@ -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);
   }
 
-- 
GitLab