From 23f8a070b3bf2e628e47fbbdc32900f42c6ca4fd Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 12 Dec 2019 09:08:06 -0500 Subject: [PATCH] unit tests: don't try to close a NULL outfp_ --- tests/cell.cpp | 4 +++- tests/fade.cpp | 4 +++- tests/libav.cpp | 4 +++- tests/ncplane.cpp | 4 +++- tests/notcurses.cpp | 4 +++- tests/panelreel.cpp | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/cell.cpp b/tests/cell.cpp index e213f1aa2..a489f89c1 100644 --- a/tests/cell.cpp +++ b/tests/cell.cpp @@ -23,7 +23,9 @@ class CellTest : public :: testing::Test { if(nc_){ EXPECT_EQ(0, notcurses_stop(nc_)); } - fclose(outfp_); + if(outfp_){ + fclose(outfp_); + } } struct notcurses* nc_{}; diff --git a/tests/fade.cpp b/tests/fade.cpp index d5084c151..1b2b0eb0a 100644 --- a/tests/fade.cpp +++ b/tests/fade.cpp @@ -41,7 +41,9 @@ class FadeTest : public :: testing::Test { if(nc_){ EXPECT_EQ(0, notcurses_stop(nc_)); } - fclose(outfp_); + if(outfp_){ + fclose(outfp_); + } } struct notcurses* nc_{}; diff --git a/tests/libav.cpp b/tests/libav.cpp index 375db77ca..2a16f13c7 100644 --- a/tests/libav.cpp +++ b/tests/libav.cpp @@ -22,7 +22,9 @@ class LibavTest : public :: testing::Test { if(nc_){ EXPECT_EQ(0, notcurses_stop(nc_)); } - fclose(outfp_); + if(outfp_){ + fclose(outfp_); + } } notcurses* nc_{}; diff --git a/tests/ncplane.cpp b/tests/ncplane.cpp index 9ea91edfe..5efc13117 100644 --- a/tests/ncplane.cpp +++ b/tests/ncplane.cpp @@ -24,7 +24,9 @@ class NcplaneTest : public :: testing::Test { if(nc_){ EXPECT_EQ(0, notcurses_stop(nc_)); } - fclose(outfp_); + if(outfp_){ + fclose(outfp_); + } } struct notcurses* nc_{}; diff --git a/tests/notcurses.cpp b/tests/notcurses.cpp index 41f786952..da328eea3 100644 --- a/tests/notcurses.cpp +++ b/tests/notcurses.cpp @@ -23,7 +23,9 @@ class NotcursesTest : public :: testing::Test { if(nc_){ EXPECT_EQ(0, notcurses_stop(nc_)); } - fclose(outfp_); + if(outfp_){ + fclose(outfp_); + } } struct notcurses* nc_{}; diff --git a/tests/panelreel.cpp b/tests/panelreel.cpp index 86b0d3f67..658312cc4 100644 --- a/tests/panelreel.cpp +++ b/tests/panelreel.cpp @@ -23,7 +23,9 @@ class PanelReelTest : public :: testing::Test { if(nc_){ EXPECT_EQ(0, notcurses_stop(nc_)); } - fclose(outfp_); + if(outfp_){ + fclose(outfp_); + } } struct notcurses* nc_{};