From c07c1b302ca3f9bfec2d0b0371ce9be79dcc1e57 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Fri, 18 Dec 2020 14:50:31 +0100
Subject: [PATCH] Small fixes to the neutrino unit test

---
 .gitignore                    | 1 +
 tests/Makefile.am             | 3 ++-
 tests/testNeutrinoCosmology.c | 4 +++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index f2e5dac691..a6b0a250fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -171,6 +171,7 @@ tests/testFormat.sh
 tests/testCooling
 tests/testComovingCooling
 tests/testHashmap
+tests/testNeutrinoCosmology
 tests/*.png
 tests/*.txt
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c1b3e97570..559ea10686 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -162,4 +162,5 @@ EXTRA_DIST = testReading.sh makeInput.py testActivePair.sh \
              output_list_params.yml output_list_time.txt output_list_redshift.txt \
              output_list_scale_factor.txt testEOS.sh testEOS_plot.sh \
 	     test27cellsStars.sh test27cellsStarsPerturbed.sh star_tolerance_27_normal.dat \
-	     star_tolerance_27_perturbed.dat star_tolerance_27_perturbed_h.dat star_tolerance_27_perturbed_h2.dat
+	     star_tolerance_27_perturbed.dat star_tolerance_27_perturbed_h.dat star_tolerance_27_perturbed_h2.dat \
+	     testNeutrinoCosmology.dat
diff --git a/tests/testNeutrinoCosmology.c b/tests/testNeutrinoCosmology.c
index 38b2db49ba..fc2cff5752 100644
--- a/tests/testNeutrinoCosmology.c
+++ b/tests/testNeutrinoCosmology.c
@@ -104,6 +104,7 @@ int main(int argc, char *argv[]) {
   const int cols = 3;
   double CLASS_table[rows * cols];
   FILE *stream = fopen("testNeutrinoCosmology.dat", "r");
+  if (stream == NULL) error("Could not open reference solution file!");
   char line[1024];
   int row = 0;
   while (fgets(line, 1024, stream)) {
@@ -182,7 +183,8 @@ int main(int argc, char *argv[]) {
         double time2 = CLASS_table[1 + 3 * j];
         double Onu2 = CLASS_table[2 + 3 * j];
 
-        /* Class defines years as 365.25 days, we use 365 days. */
+        /* Class defines years as 365.25 days, we use 365 days (in this test).
+         */
         time2 *= 365.25 / 365.0;
 
         assert(fabs(a1 - a2) / (a1 + a2) < EXTERNAL_TOLERANCE);
-- 
GitLab