Skip to content

Commit

Permalink
Rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKutzner committed Nov 15, 2024
1 parent eb5059e commit f41e6ea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion include/nigiri/routing/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct search {

tts.factor_ = std::max(tts.factor_, 1.0F);
if (tts.factor_ == 1.0F && tts.min_transfer_time_ == 0_minutes &&
tts.disposable_time_ == 0_minutes) {
tts.additional_time_ == 0_minutes) {
tts.default_ = true;
}

Expand Down
10 changes: 5 additions & 5 deletions include/nigiri/routing/transfer_time_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ namespace nigiri::routing {
struct transfer_time_settings {
bool operator==(transfer_time_settings const& o) const {
return default_ == o.default_ ||
std::tie(min_transfer_time_, disposable_time_, factor_) ==
std::tie(o.min_transfer_time_, disposable_time_, o.factor_);
std::tie(min_transfer_time_, additional_time_, factor_) ==
std::tie(o.min_transfer_time_, additional_time_, o.factor_);
}

bool default_{true};
duration_t min_transfer_time_{0};
duration_t disposable_time_{0};
duration_t additional_time_{0};
float factor_{1.0F};
};

Expand All @@ -23,7 +23,7 @@ inline T adjusted_transfer_time(transfer_time_settings const& settings,
if (settings.default_) {
return duration;
} else {
return static_cast<T>(settings.disposable_time_.count()) +
return static_cast<T>(settings.additional_time_.count()) +
std::max(
static_cast<T>(settings.min_transfer_time_.count()),
static_cast<T>(static_cast<float>(duration) * settings.factor_));
Expand All @@ -38,7 +38,7 @@ inline std::chrono::duration<Rep, std::ratio<60>> adjusted_transfer_time(
return duration;
} else {
return std::chrono::duration<Rep, std::ratio<60>>{
static_cast<Rep>(settings.disposable_time_.count()) +
static_cast<Rep>(settings.additional_time_.count()) +
std::max(static_cast<Rep>(settings.min_transfer_time_.count()),
static_cast<Rep>(static_cast<float>(duration.count()) *
settings.factor_))};
Expand Down
16 changes: 8 additions & 8 deletions test/routing/transfer_time_settings_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,35 +216,35 @@ TEST(routing, transfer_time_settings_test) {
EXPECT_EQ(expected_A_C_f20, results_to_str(results, tt));
}
{
// A -> C, default transfer time, 2 min disposable (= 4 min)
// A -> C, default transfer time, 2 min additional (= 4 min)
auto const results =
search(tt, nullptr, "A", "C", tt.date_range_, dir,
{.default_ = false, .disposable_time_ = duration_t{2}});
{.default_ = false, .additional_time_ = duration_t{2}});
EXPECT_EQ(expected_A_C_f20, results_to_str(results, tt));
}
{
// A -> C, 1.5x transfer time, 1 min disposable (= 4 min)
// A -> C, 1.5x transfer time, 1 min additional (= 4 min)
auto const results = search(tt, nullptr, "A", "C", tt.date_range_, dir,
{.default_ = false,
.disposable_time_ = duration_t{1},
.additional_time_ = duration_t{1},
.factor_ = 1.5F});
EXPECT_EQ(expected_A_C_f20, results_to_str(results, tt));
}
{
// A -> C, min 3 min transfer time, 1 min disposable (= 4 min)
// A -> C, min 3 min transfer time, 1 min additional (= 4 min)
auto const results = search(tt, nullptr, "A", "C", tt.date_range_, dir,
{.default_ = false,
.min_transfer_time_ = duration_t{3},
.disposable_time_ = duration_t{1}});
.additional_time_ = duration_t{1}});
EXPECT_EQ(expected_A_C_f20, results_to_str(results, tt));
}
{
// A -> C, min 3 min transfer time, 2.5x transfer time, 5 min disposable
// A -> C, min 3 min transfer time, 2.5x transfer time, 5 min additional
// (= 10 min)
auto const results = search(tt, nullptr, "A", "C", tt.date_range_, dir,
{.default_ = false,
.min_transfer_time_ = duration_t{3},
.disposable_time_ = duration_t{5},
.additional_time_ = duration_t{5},
.factor_ = 2.5F});
EXPECT_EQ(expected_A_C_min10, results_to_str(results, tt));
}
Expand Down

0 comments on commit f41e6ea

Please sign in to comment.