Open alexey-malov opened 7 years ago
Алгоритмы + Структуры данных = Программы
Engine is turned on
Direction is: forward
Gear is: 0
Speed is: 3
> SetGear 1
Engine is turned off or gear does not match current speed
> Info
Engine is turned on
Direction is: forward
Gear is: 5
Speed is: 90
> EngineOff
> Info
Engine is turned on
Direction is: forward
Gear is: 5
Speed is: 90
// Вспомогательная функция для проверки работы команды command
// Она принимает ожидаемый номер канала expectedChannel и expectedOutput
void VerifyCommandHandling(const string& command, const string& expectedOutput)
{
// Предварительно очищаем содержимое выходного потока
output = stringstream();
input = stringstream();
BOOST_CHECK(input << command);
BOOST_CHECK(remoteControl.HandleCommand());
BOOST_CHECK(input.eof());
BOOST_CHECK_EQUAL(output.str(), expectedOutput);
}
canSetGear = (gear == -1 && m_speed == 0 && m_direction <= Direction::none) || (gear == 1 && m_speed == 0 && m_direction>= Direction::none) || (gear == 0)||(gear>=2);
bool CCar::SpeedIsInRange(int const &gear, int speed) const
bool CCar::SpeedIsInRange(int const &gear, int speed) const
{
auto it = speedRange.find(gear);
auto speedRange = it->second;
return (speedRange.second >= speed) && (speedRange.first <= speed);
}