diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index a5ac9008e0..2a48f96199 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -34,20 +34,11 @@ namespace openspace::globebrowsing { -/*TimeQuantizer::TimeQuantizer(const std::string& start, const std::string& end, - double resolution) - : _start(start) - , _resolution(resolution) - , _timerange(start, end) -{ - //setStartEndRange(start, end); -}*/ TimeQuantizer::TimeQuantizer(const std::string& start, const std::string& end, const std::string& resolution) : _start(start) , _timerange(start, end) - //TimeQuantizer(start, end, parseTimeResolutionStr(resolution)) { verifyStartTimeRestrictions(); _resolution = parseTimeResolutionStr(resolution); diff --git a/modules/globebrowsing/src/timequantizer.h b/modules/globebrowsing/src/timequantizer.h index c51f7c1c1c..14fb6aa6d9 100644 --- a/modules/globebrowsing/src/timequantizer.h +++ b/modules/globebrowsing/src/timequantizer.h @@ -328,18 +328,6 @@ private: class TimeQuantizer { public: TimeQuantizer() = default; - /* - * Constructor that initializes with formatted strings for start & ends date/times, - * and a time resolution within that range - * - * \params start the ISO8601 date/time string (YYYY-MM-DDTHH:mm:ss) for start - * limitations on values include: day of month in range of 1 - 28, - * and hour, minute, second values must be 0. - * \params end the ISO8601 date/time string (YYYY-MM-DDTHH:mm:ss) for end - * \params resolution the number of seconds between the temporal data set updates - */ - //TimeQuantizer(const std::string& start, const std::string& end, double resolution); - /* * Constructor that initializes with formatted strings for start & ends date/times, * and a time resolution within that range diff --git a/tests/test_timequantizer.inl b/tests/test_timequantizer.inl index 71cd99aae4..bf8a099753 100644 --- a/tests/test_timequantizer.inl +++ b/tests/test_timequantizer.inl @@ -99,6 +99,46 @@ static void singleResolutionTest(openspace::globebrowsing::TimeQuantizer& tq, } } +static void singleStartTimeTest1(openspace::globebrowsing::TimeQuantizer& tq, + std::string startTime, std::string expectedErrSubstring, + bool expectFailure) +{ + std::string res; + try { + tq.setStartEndRange(startTime, startTime); + } + catch (const ghoul::RuntimeError& e) { + res = e.message; + } + + if (expectFailure) { + EXPECT_TRUE(res.find(expectedErrSubstring) != std::string::npos); + } + else { + EXPECT_TRUE(res.find(expectedErrSubstring) == std::string::npos); + } +} + +static void singleStartTimeTest2(std::string startTime, std::string expectedErrSubstring, + bool expectFailure) +{ + using namespace openspace::globebrowsing; + std::string res; + try { + TimeQuantizer tq(startTime, startTime, "1d"); + } + catch (const ghoul::RuntimeError& e) { + res = e.message; + } + + if (expectFailure) { + EXPECT_TRUE(res.find(expectedErrSubstring) != std::string::npos); + } + else { + EXPECT_TRUE(res.find(expectedErrSubstring) == std::string::npos); + } +} + static void LoadSpiceKernel () { loadLSKKernel(); // naif0008.tls is a text file, check if loaded. @@ -279,3 +319,25 @@ TEST_F(TimeQuantizerTest, TestResolutionError) { singleResolutionTest(t1, "31m", "(m)inute option.", true); singleResolutionTest(t1, "10s", "unit format", true); } + +TEST_F(TimeQuantizerTest, TestStartTimeError1) { + LoadSpiceKernel(); + using namespace openspace::globebrowsing; + TimeQuantizer t1; + + singleStartTimeTest1(t1, "2017-01-20T00:00:00", "Invalid start", false); + singleStartTimeTest1(t1, "2017-01-29T00:00:00", "Invalid start day value", true); + singleStartTimeTest1(t1, "2017-01-28T12:00:00", "Invalid start time value", true); + singleStartTimeTest1(t1, "2017-01-28T00:01:00", "Invalid start time value", true); + singleStartTimeTest1(t1, "2017-01-28T00:00:01", "Invalid start time value", true); +} + +TEST_F(TimeQuantizerTest, TestStartTimeError2) { + LoadSpiceKernel(); + + singleStartTimeTest2("2017-01-20T00:00:00", "Invalid start", false); + singleStartTimeTest2("2017-01-29T00:00:00", "Invalid start day value", true); + singleStartTimeTest2("2017-01-28T12:00:00", "Invalid start time value", true); + singleStartTimeTest2("2017-01-28T00:01:00", "Invalid start time value", true); + singleStartTimeTest2("2017-01-28T00:00:01", "Invalid start time value", true); +}