Fixing unit tests.

This commit is contained in:
Vladimir Byko-Ianko 2015-10-05 14:33:38 +03:00
parent 27a2e94b79
commit 93d8c30483

View file

@ -107,18 +107,17 @@ UNIT_TEST(TurnsSoundMetersTest)
turnSound.Reset();
turnSound.SetSpeedMetersPerSecond(30.);
TurnItem turnItem(5 /* idx */, TurnDirection::TurnRight);
vector<TurnItemDist> turns = {{{5 /* idx */, TurnDirection::TurnRight}, 1000.}};
vector<string> turnNotifications;
ASSERT(turnNotifications.empty(), ());
// Starting nearing the turnItem.
// 1000 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem, 1000. /* distanceToTurnMeters */, turnNotifications);
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 700 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem, 700. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 700.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 699 meters till the turn. It's time to pronounce the first voice notification.
@ -127,42 +126,47 @@ UNIT_TEST(TurnsSoundMetersTest)
// Besides that we need 5 seconds (but 100 meters maximum) for playing the notification.
// So we start playing the first notification when the distance till the turn is less
// then 20 seconds * 30 meters per seconds + 100 meters = 700 meters.
turnSound.GenerateTurnSound(turnItem, 699. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 699.;
turnSound.GenerateTurnSound(turns, turnNotifications);
vector<string> const expectedNotification1 = {{"In 600 meters. Make a right turn."}};
TEST_EQUAL(turnNotifications, expectedNotification1, ());
// 650 meters till the turn. No sound notifications is required.
turnNotifications.clear();
turnSound.GenerateTurnSound(turnItem, 650. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 650.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
turnSound.SetSpeedMetersPerSecond(32.);
// 150 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem, 150. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 150.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 100 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem, 100. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 100.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 99 meters till the turn. It's time to pronounce the second voice notification.
turnSound.GenerateTurnSound(turnItem, 99. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 99.;
turnSound.GenerateTurnSound(turns, turnNotifications);
vector<string> const expectedNotification2 = {{"Make a right turn."}};
TEST_EQUAL(turnNotifications, expectedNotification2, ());
// 99 meters till the turn again. No sound notifications is required.
turnNotifications.clear();
turnSound.GenerateTurnSound(turnItem, 99. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 99.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 50 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem, 50. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 50.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 0 meters till the turn. No sound notifications is required.
turnNotifications.clear();
turnSound.GenerateTurnSound(turnItem, 0. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 0.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
TEST(turnSound.IsEnabled(), ());
@ -190,47 +194,52 @@ UNIT_TEST(TurnsSoundMetersTwoTurnsTest)
turnSound.Reset();
turnSound.SetSpeedMetersPerSecond(35.);
TurnItem turnItem1(5 /* idx */, TurnDirection::TurnSharpRight);
//TurnItem turnItem1(5 /* idx */, TurnDirection::TurnSharpRight);
vector<TurnItemDist> turns = {{{5 /* idx */, TurnDirection::TurnSharpRight}, 800.}};
vector<string> turnNotifications;
ASSERT(turnNotifications.empty(), ());
// Starting nearing the first turn.
// 800 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem1, 800. /* distanceToTurnMeters */, turnNotifications);
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 700 meters till the turn. It's time to pronounce the first voice notification.
turnSound.GenerateTurnSound(turnItem1, 700. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 700.;
turnSound.GenerateTurnSound(turns, turnNotifications);
vector<string> const expectedNotification1 = {{"In 700 meters. Make a sharp right turn."}};
TEST_EQUAL(turnNotifications, expectedNotification1, ());
turnSound.SetSpeedMetersPerSecond(32.);
// 150 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem1, 150. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 150.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 99 meters till the turn. It's time to pronounce the second voice notification.
turnSound.GenerateTurnSound(turnItem1, 99. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 99.;
turnSound.GenerateTurnSound(turns, turnNotifications);
vector<string> const expectedNotification2 = {{"Make a sharp right turn."}};
TEST_EQUAL(turnNotifications, expectedNotification2, ());
turnSound.SetSpeedMetersPerSecond(10.);
// 0 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem1, 0. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 0.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
TurnItem turnItem2(11 /* idx */, TurnDirection::EnterRoundAbout, 2 /* exitNum */);
vector<TurnItemDist> turns2 = {{{11 /* idx */, TurnDirection::EnterRoundAbout,
2 /* exitNum */}, 60.}};
// Starting nearing the second turn.
turnSound.GenerateTurnSound(turnItem2, 60. /* distanceToTurnMeters */, turnNotifications);
turnSound.GenerateTurnSound(turns2, turnNotifications);
TEST(turnNotifications.empty(), ());
// 40 meters till the second turn. It's time to pronounce the second voice notification
// without the first one.
turnSound.GenerateTurnSound(turnItem2, 40. /* distanceToTurnMeters */, turnNotifications);
turns2.front().m_distMeters = 40.;
turnSound.GenerateTurnSound(turns2, turnNotifications);
vector<string> const expectedNotification3 = {{"Enter the roundabout."}};
TEST_EQUAL(turnNotifications, expectedNotification3, ());
@ -254,18 +263,18 @@ UNIT_TEST(TurnsSoundFeetTest)
turnSound.Reset();
turnSound.SetSpeedMetersPerSecond(30.);
TurnItem turnItem(7 /* idx */, TurnDirection::EnterRoundAbout, 3 /* exitNum */);
vector<TurnItemDist> turns = {{{7 /* idx */, TurnDirection::EnterRoundAbout,
3 /* exitNum */}, 1000.}};
vector<string> turnNotifications;
ASSERT(turnNotifications.empty(), ());
// Starting nearing the turnItem.
// 1000 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem, 1000. /* distanceToTurnMeters */, turnNotifications);
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 700 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem, 700. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 700.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 699 meters till the turn. It's time to pronounce the first voice notification.
@ -274,41 +283,45 @@ UNIT_TEST(TurnsSoundFeetTest)
// Besides that we need 5 seconds (but 100 meters maximum) for playing the notification.
// So we start playing the first notification when the distance till the turn is less
// then 20 seconds * 30 meters per seconds + 100 meters = 700 meters.
turnSound.GenerateTurnSound(turnItem, 699. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 699.;
turnSound.GenerateTurnSound(turns, turnNotifications);
vector<string> const expectedNotification1 = {{"In 2000 feet. Enter the roundabout."}};
TEST_EQUAL(turnNotifications, expectedNotification1, ());
// 650 meters till the turn. No sound notifications is required.
turnNotifications.clear();
turnSound.GenerateTurnSound(turnItem, 650. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 650.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 150 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem, 150. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 150.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 100 meters till the turn. No sound notifications is required.
turnSound.GenerateTurnSound(turnItem, 100. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 100.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 99 meters till the turn. It's time to pronounce the second voice notification.
turnSound.GenerateTurnSound(turnItem, 99. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 99.;
turnSound.GenerateTurnSound(turns, turnNotifications);
vector<string> const expectedNotification2 = {{"Enter the roundabout."}};
TEST_EQUAL(turnNotifications, expectedNotification2, ());
// 99 meters till the turn again. No sound notifications is required.
turnNotifications.clear();
turnSound.GenerateTurnSound(turnItem, 99. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 99.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 50 meters till the turn. No sound notifications is required.
turnNotifications.clear();
turnSound.GenerateTurnSound(turnItem, 50. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 50.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
// 0 meters till the turn. No sound notifications is required.
turnNotifications.clear();
turnSound.GenerateTurnSound(turnItem, 0. /* distanceToTurnMeters */, turnNotifications);
turns.front().m_distMeters = 0.;
turnSound.GenerateTurnSound(turns, turnNotifications);
TEST(turnNotifications.empty(), ());
TEST(turnSound.IsEnabled(), ());