diff --git a/Overlap/Tests/test_overlap.f90 b/Overlap/Tests/test_overlap.f90
index 9108a49410e062e27f7e96c13f1db2c7205b8d5e..a98d174ae813945d60e475231d080ca127a31238 100644
--- a/Overlap/Tests/test_overlap.f90
+++ b/Overlap/Tests/test_overlap.f90
@@ -22,7 +22,7 @@ program test_overlap
   character(len = :), allocatable:: shpc_dir
   integer d_init
   integer:: k_test_1 = 0, k_test_2 = 1
-  integer unit, i, copy, rank, n_proc
+  integer unit, i, copy, rank, n_proc, n_dates
   integer, allocatable:: ishape_last(:)
   type(snapshot), allocatable:: flow(:) ! (max_delta + 1)
   TYPE(shpc) hshp
@@ -79,6 +79,9 @@ program test_overlap
   step = step_deg * deg_to_rad
   allocate(flow(max_delta + 1))
   call read_column(ishape_last, file = trim(shpc_dir) // "/ishape_last.txt")
+  n_dates = size(ishape_last)
+  call assert(0 <= [k_test_1, k_test_2] .and. [k_test_1, k_test_2] < n_dates, &
+       "test_overlap k_test_1, k_test_2")
   e_overestim = maxval([ishape_last(1) + 1, ediff1d(ishape_last)])
   call shpc_open(hshp, trim(shpc_dir), rank = 0)
   call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, ishape = 0)