diff --git a/editor/editor_tests/opening_hours_ui_test.cpp b/editor/editor_tests/opening_hours_ui_test.cpp index 7298f6b38c..b1972f3ca9 100644 --- a/editor/editor_tests/opening_hours_ui_test.cpp +++ b/editor/editor_tests/opening_hours_ui_test.cpp @@ -48,7 +48,7 @@ UNIT_TEST(TestTimeTable_ExcludeTime) tt.SetOpeningTime({8_h + 15_min, 18_h + 30_min}); TEST(tt.AddExcludeTime({10_h, 12_h}), ()); - TEST(!tt.AddExcludeTime({11_h, 13_h}), ()); + TEST(tt.AddExcludeTime({11_h, 13_h}), ()); TEST(tt.AddExcludeTime({15_h, 17_h}), ()); TEST_EQUAL(tt.GetExcludeTime().size(), 2, ()); } @@ -94,12 +94,6 @@ UNIT_TEST(TestTimeTable_ExcludeTime) tt.SetOpeningTime({8_h + 15_min, 15_h + 30_min}); TEST(!tt.AddExcludeTime({10_h, 16_h}), ()); - } - { - auto tt = TimeTable::GetPredefinedTimeTable(); - tt.SetTwentyFourHours(false); - - tt.SetOpeningTime({8_h + 15_min, 15_h + 30_min}); TEST(!tt.AddExcludeTime({7_h, 14_h}), ()); } { @@ -111,8 +105,12 @@ UNIT_TEST(TestTimeTable_ExcludeTime) TEST(tt.AddExcludeTime({12_h, 13_h}), ()); TEST(tt.AddExcludeTime({15_h, 17_h}), ()); TEST(tt.ReplaceExcludeTime({13_h, 14_h}, 1), ()); - TEST(!tt.ReplaceExcludeTime({10_h + 30_min, 14_h}, 1), ()); - TEST_EQUAL(tt.GetExcludeTime().size(), 3, ()); + TEST(tt.ReplaceExcludeTime({10_h + 30_min, 14_h}, 1), ()); + TEST_EQUAL(tt.GetExcludeTime().size(), 2, ()); + TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 10, ()); + TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 14, ()); + TEST_EQUAL(tt.GetExcludeTime()[1].GetStart().GetHourMinutes().GetHoursCount(), 15, ()); + TEST_EQUAL(tt.GetExcludeTime()[1].GetEnd().GetHourMinutes().GetHoursCount(), 17, ()); } { auto tt = TimeTable::GetPredefinedTimeTable(); diff --git a/editor/opening_hours_ui.cpp b/editor/opening_hours_ui.cpp index a636f5c339..7f9001a232 100644 --- a/editor/opening_hours_ui.cpp +++ b/editor/opening_hours_ui.cpp @@ -43,7 +43,7 @@ bool FixTimeSpans(osmoh::TTimespans & spans, osmoh::Timespan const & openingTime for (auto i = 1, j = 0; i < spans.size(); ++i) { auto const start2 = spans[i].GetStart().GetHourMinutes().GetDuration(); - auto const end1 = spans[i - 1].GetEnd().GetHourMinutes().GetDuration(); + auto const end1 = spans[j].GetEnd().GetHourMinutes().GetDuration(); auto const end2 = spans[i].GetEnd().GetHourMinutes().GetDuration(); // The first one includes the second. @@ -52,12 +52,7 @@ bool FixTimeSpans(osmoh::TTimespans & spans, osmoh::Timespan const & openingTime continue; } // Two spans have non-empty intersection. - else if (start2 < end1) - { - return false; - } - // The second span continue the first one. - else if(start2 == end1) + else if (start2 <= end1) { result.back().SetEnd(spans[i].GetEnd()); }