-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix split for negative whole day deltas (#138)
* fix split for negative whole day deltas * mority's suggestion implemented #138 (comment)
- Loading branch information
1 parent
3b66452
commit e02e54c
Showing
2 changed files
with
35 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "gtest/gtest.h" | ||
|
||
#include "nigiri/common/delta_t.h" | ||
|
||
using namespace nigiri; | ||
|
||
TEST(DeltaT, NegDeltaValue) { | ||
{ | ||
auto [day, mam] = split_day_mam(day_idx_t{10}, delta_t{0}); | ||
EXPECT_EQ(day, day_idx_t{10}); | ||
EXPECT_EQ(mam.count(), 0); | ||
} | ||
{ | ||
auto [day, mam] = split_day_mam(day_idx_t{10}, delta_t{1441}); | ||
EXPECT_EQ(day, day_idx_t{11}); | ||
EXPECT_EQ(mam.count(), 1); | ||
} | ||
{ | ||
auto [day, mam] = split_day_mam(day_idx_t{10}, delta_t{1440}); | ||
EXPECT_EQ(day, day_idx_t{11}); | ||
EXPECT_EQ(mam.count(), 0); | ||
} | ||
{ | ||
auto [day, mam] = split_day_mam(day_idx_t{10}, delta_t{-1441}); | ||
EXPECT_EQ(day, day_idx_t{8}); | ||
EXPECT_EQ(mam.count(), 1439); | ||
} | ||
{ | ||
auto [day, mam] = split_day_mam(day_idx_t{10}, delta_t{-1440}); | ||
EXPECT_EQ(day, day_idx_t{9}); | ||
EXPECT_EQ(mam.count(), 0); | ||
} | ||
} |