diff options
author | Sean M. Pappalardo <pegasus@renegadetech.com> | 2015-12-10 08:44:46 -0800 |
---|---|---|
committer | Sean M. Pappalardo <pegasus@renegadetech.com> | 2015-12-10 08:44:46 -0800 |
commit | 6f475ec07568474ec8e6858aed27868fb7063645 (patch) | |
tree | 5d34aec3787ffc7ca5d9aa2fbb8553e82ebdaa2a /src/test/softtakeover_test.cpp | |
parent | 0a354e20f811a6880db00e30025c0350f7eafc0d (diff) |
Re-derived the ST ignore cases with a truth table, now in the comments in softtakeover.cpp. Adjusted the tests to match the truth table.
Diffstat (limited to 'src/test/softtakeover_test.cpp')
-rw-r--r-- | src/test/softtakeover_test.cpp | 263 |
1 files changed, 24 insertions, 239 deletions
diff --git a/src/test/softtakeover_test.cpp b/src/test/softtakeover_test.cpp index 2ec530e65d..b31a899087 100644 --- a/src/test/softtakeover_test.cpp +++ b/src/test/softtakeover_test.cpp @@ -76,8 +76,13 @@ TEST_F(SoftTakeoverTest, SoftTakeover_IgnoresFirstValue) { /* The meat of the tests * (See decscription in SoftTakeover::ignore() ) * - * The test matrix is given in the accompanying CSV file. Of the 32 possible - * cases, only four should be ignored. + * The test matrix is given in the accompanying CSV file. + * There are 32 possible cases due to five binary possibilities: + * - Previous value distance from current (near/far) + * - Previous value side of current (less/greater) + * - New value distance + * - New value side + * - New value arrival time (below or above threshold) */ // ---- Previous Near & less than current @@ -162,6 +167,7 @@ TEST_F(SoftTakeoverTest, PrevNearLess_NewNearMore_Late) { EXPECT_FALSE(st_control.ignore(co.data(), 60)); } +// Ignore this case TEST_F(SoftTakeoverTest, PrevNearLess_NewFarLess_Late) { QScopedPointer<ControlPotmeter> co(new ControlPotmeter( ConfigKey("[Channel1]", "test_pot"), -250, 250)); @@ -173,9 +179,10 @@ TEST_F(SoftTakeoverTest, PrevNearLess_NewFarLess_Late) { // First is always ignored. EXPECT_TRUE(st_control.ignore(co.data(), 40)); Time::setTestElapsedTime(100); - EXPECT_FALSE(st_control.ignore(co.data(), 1)); + EXPECT_TRUE(st_control.ignore(co.data(), 1)); } +// Ignore this case TEST_F(SoftTakeoverTest, PrevNearLess_NewFarMore_Late) { QScopedPointer<ControlPotmeter> co(new ControlPotmeter( ConfigKey("[Channel1]", "test_pot"), -250, 250)); @@ -187,7 +194,7 @@ TEST_F(SoftTakeoverTest, PrevNearLess_NewFarMore_Late) { // First is always ignored. EXPECT_TRUE(st_control.ignore(co.data(), 40)); Time::setTestElapsedTime(100); - EXPECT_FALSE(st_control.ignore(co.data(), 100)); + EXPECT_TRUE(st_control.ignore(co.data(), 100)); } // ---- Previous Near & greater than current @@ -272,6 +279,7 @@ TEST_F(SoftTakeoverTest, PrevNearMore_NewNearMore_Late) { EXPECT_FALSE(st_control.ignore(co.data(), 60)); } +// Ignore this case TEST_F(SoftTakeoverTest, PrevNearMore_NewFarLess_Late) { QScopedPointer<ControlPotmeter> co(new ControlPotmeter( ConfigKey("[Channel1]", "test_pot"), -250, 250)); @@ -283,9 +291,10 @@ TEST_F(SoftTakeoverTest, PrevNearMore_NewFarLess_Late) { // First is always ignored. EXPECT_TRUE(st_control.ignore(co.data(), 55)); Time::setTestElapsedTime(100); - EXPECT_FALSE(st_control.ignore(co.data(), 1)); + EXPECT_TRUE(st_control.ignore(co.data(), 1)); } +// Ignore this case TEST_F(SoftTakeoverTest, PrevNearMore_NewFarMore_Late) { QScopedPointer<ControlPotmeter> co(new ControlPotmeter( ConfigKey("[Channel1]", "test_pot"), -250, 250)); @@ -297,7 +306,7 @@ TEST_F(SoftTakeoverTest, PrevNearMore_NewFarMore_Late) { // First is always ignored. EXPECT_TRUE(st_control.ignore(co.data(), 55)); Time::setTestElapsedTime(100); - EXPECT_FALSE(st_control.ignore(co.data(), 100)); + EXPECT_TRUE(st_control.ignore(co.data(), 100)); } // ---- Previous Far & less than current @@ -328,7 +337,7 @@ TEST_F(SoftTakeoverTest, PrevFarLess_NewNearMore_Soon) { EXPECT_FALSE(st_control.ignore(co.data(), 60)); } -// This should be ignored +// Ignore this case TEST_F(SoftTakeoverTest, PrevFarLess_NewFarLess_Soon) { QScopedPointer<ControlPotmeter> co(new ControlPotmeter( ConfigKey("[Channel1]", "test_pot"), -250, 250)); @@ -383,7 +392,7 @@ TEST_F(SoftTakeoverTest, PrevFarLess_NewNearMore_Late) { EXPECT_FALSE(st_control.ignore(co.data(), 60)); } -// This should be ignored +// Ignore this case TEST_F(SoftTakeoverTest, PrevFarLess_NewFarLess_Late) { QScopedPointer<ControlPotmeter> co(new ControlPotmeter( ConfigKey("[Channel1]", "test_pot"), -250, 250)); @@ -398,6 +407,7 @@ TEST_F(SoftTakeoverTest, PrevFarLess_NewFarLess_Late) { EXPECT_TRUE(st_control.ignore(co.data(), 1)); } +// Ignore this case TEST_F(SoftTakeoverTest, PrevFarLess_NewFarMore_Late) { QScopedPointer<ControlPotmeter> co(new ControlPotmeter( ConfigKey("[Channel1]", "test_pot"), -250, 250)); @@ -409,7 +419,7 @@ TEST_F(SoftTakeoverTest, PrevFarLess_NewFarMore_Late) { // First is always ignored. EXPECT_TRUE(st_control.ignore(co.data(), -50)); Time::setTestElapsedTime(100); - EXPECT_FALSE(st_control.ignore(co.data(), 100)); + EXPECT_TRUE(st_control.ignore(co.data(), 100)); } // ---- Previous Far & greater than current @@ -453,7 +463,7 @@ TEST_F(SoftTakeoverTest, PrevFarMore_NewFarLess_Soon) { EXPECT_FALSE(st_control.ignore(co.data(), 1)); } -// This should be ignored +// Ignore this case TEST_F(SoftTakeoverTest, PrevFarMore_NewFarMore_Soon) { QScopedPointer<ControlPotmeter> co(new ControlPotmeter( ConfigKey("[Channel1]", "test_pot"), -250, 250)); @@ -495,6 +505,7 @@ TEST_F(SoftTakeoverTest, PrevFarMore_NewNearMore_Late) { EXPECT_FALSE(st_control.ignore(co.data(), 60)); } +// Ignore this case TEST_F(SoftTakeoverTest, PrevFarMore_NewFarLess_Late) { QScopedPointer<ControlPotmeter> co(new ControlPotmeter( ConfigKey("[Channel1]", "test_pot"), -250, 250)); @@ -506,10 +517,10 @@ TEST_F(SoftTakeoverTest, PrevFarMore_NewFarLess_Late) { // First is always ignored. EXPECT_TRUE(st_control.ignore(co.data(), 120)); Time::setTestElapsedTime(100); - EXPECT_FALSE(st_control.ignore(co.data(), 1)); + EXPECT_TRUE(st_control.ignore(co.data(), 1)); } -// This should be ignored +// Ignore this case TEST_F(SoftTakeoverTest, PrevFarMore_NewFarMore_Late) { QScopedPointer<ControlPotmeter> co(new ControlPotmeter( ConfigKey("[Channel1]", "test_pot"), -250, 250)); @@ -525,232 +536,6 @@ TEST_F(SoftTakeoverTest, PrevFarMore_NewFarMore_Late) { } // For the ignore cases, check that they work correctly with various signed values - - -// Far away and less than current, within time threshold - -TEST_F(SoftTakeoverTest, PrevFarLessNeg_NewFarLessNeg_Soon) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(100); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), -50)); - EXPECT_TRUE(st_control.ignore(co.data(), -20)); -} - -TEST_F(SoftTakeoverTest, PrevFarLessNeg_NewFarLessPos_Soon) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(100); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), -50)); - EXPECT_TRUE(st_control.ignore(co.data(), 20)); -} - -TEST_F(SoftTakeoverTest, PrevFarLessPos_NewFarLessNeg_Soon) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(100); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), 50)); - EXPECT_TRUE(st_control.ignore(co.data(), -20)); -} - -TEST_F(SoftTakeoverTest, PrevFarLessPos_NewFarLessPos_Soon) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(100); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), 50)); - EXPECT_TRUE(st_control.ignore(co.data(), 20)); -} - - -// Far away and less than current, over time threshold - -TEST_F(SoftTakeoverTest, PrevFarLessNeg_NewFarLessNeg_Late) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(100); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), -50)); - Time::setTestElapsedTime(100); - EXPECT_TRUE(st_control.ignore(co.data(), -20)); -} - -TEST_F(SoftTakeoverTest, PrevFarLessNeg_NewFarLessPos_Late) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(100); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), -50)); - Time::setTestElapsedTime(100); - EXPECT_TRUE(st_control.ignore(co.data(), 20)); -} - -TEST_F(SoftTakeoverTest, PrevFarLessPos_NewFarLessNeg_Late) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(100); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), 50)); - Time::setTestElapsedTime(100); - EXPECT_TRUE(st_control.ignore(co.data(), -20)); -} - -TEST_F(SoftTakeoverTest, PrevFarLessPos_NewFarLessPos_Late) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(100); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), 50)); - Time::setTestElapsedTime(100); - EXPECT_TRUE(st_control.ignore(co.data(), 20)); -} - -// Far away and more than current, within time threshold - -TEST_F(SoftTakeoverTest, PrevFarMoreNeg_NewFarMoreNeg_Soon) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(-200); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), -150)); - EXPECT_TRUE(st_control.ignore(co.data(), -100)); -} - -TEST_F(SoftTakeoverTest, PrevFarMoreNeg_NewFarMorePos_Soon) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(-200); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), -150)); - EXPECT_TRUE(st_control.ignore(co.data(), 100)); -} - -TEST_F(SoftTakeoverTest, PrevFarMorePos_NewFarMoreNeg_Soon) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(-200); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), 150)); - EXPECT_TRUE(st_control.ignore(co.data(), -100)); -} - -TEST_F(SoftTakeoverTest, PrevFarMorePos_NewFarMorePos_Soon) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(-200); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), 150)); - EXPECT_TRUE(st_control.ignore(co.data(), 100)); -} - -// Far away and more than current, over time threshold - -TEST_F(SoftTakeoverTest, PrevFarMoreNeg_NewFarMoreNeg_Late) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(-200); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), -150)); - Time::setTestElapsedTime(100); - EXPECT_TRUE(st_control.ignore(co.data(), -100)); -} - -TEST_F(SoftTakeoverTest, PrevFarMoreNeg_NewFarMorePos_Late) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(-200); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), -150)); - Time::setTestElapsedTime(100); - EXPECT_TRUE(st_control.ignore(co.data(), 100)); -} - -TEST_F(SoftTakeoverTest, PrevFarMorePos_NewFarMoreNeg_Late) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(-200); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), 150)); - Time::setTestElapsedTime(100); - EXPECT_TRUE(st_control.ignore(co.data(), -100)); -} - -TEST_F(SoftTakeoverTest, PrevFarMorePos_NewFarMorePos_Late) { - QScopedPointer<ControlPotmeter> co(new ControlPotmeter( - ConfigKey("[Channel1]", "test_pot"), -250, 250)); - - co->set(-200); - SoftTakeoverCtrl st_control; - st_control.enable(co.data()); - - // First is always ignored. - EXPECT_TRUE(st_control.ignore(co.data(), 150)); - Time::setTestElapsedTime(100); - EXPECT_TRUE(st_control.ignore(co.data(), 100)); -} - +// TODO } // namespace |