From 7bf383e04c6e8c1aa98faaa316aae37c4f48d63d Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Thu, 4 Jun 2020 13:26:51 +0200 Subject: [PATCH] Add test for n_steps verification --- sf-writer/test/test_JFH5Writer.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sf-writer/test/test_JFH5Writer.cpp b/sf-writer/test/test_JFH5Writer.cpp index 04de282..3f78da2 100644 --- a/sf-writer/test/test_JFH5Writer.cpp +++ b/sf-writer/test/test_JFH5Writer.cpp @@ -109,3 +109,25 @@ TEST(JFH5Writer, test_writing) ASSERT_EQ(is_good_frame_data[pulse_id - start_pulse_id], 1); } } + +TEST(JFH5Writer, test_step_pulse_id) +{ + // Start pulse id (5) larger than stop pulse id (4). + ASSERT_THROW(JFH5Writer writer("ignore.h5", 1, + 5, 4, 1), runtime_error); + + // Start pulse id (5) is equal to stop pulse id (5). + ASSERT_NO_THROW(JFH5Writer writer("ignore.h5", 1, 5, 5, 1)); + + // The step is exactly on start nad stop pulse id. + ASSERT_NO_THROW(JFH5Writer writer("ignore.h5", 1, 5, 5, 5)); + + // No pulses in given range with step = 10 + ASSERT_THROW(JFH5Writer writer("ignore.h5", 1, 1, 9, 10), runtime_error); + + // Stop pulse id is divisible by step. + ASSERT_NO_THROW(JFH5Writer writer("ignore.h5", 1, 5, 10, 10)); + + // Start pulse id is divisible by step. + ASSERT_NO_THROW(JFH5Writer writer("ignore.h5", 1, 10, 19, 10)); +} \ No newline at end of file