C++ PCM integration tests

Change-Id: I1ad0090edf0c8986ca8f1bfc78c936c5dd55c432
This commit is contained in:
thomasclark
2014-06-12 11:17:57 -04:00
parent 3c5d46c2ae
commit 5d646536fb
3 changed files with 143 additions and 14 deletions

View File

@@ -9,6 +9,8 @@
#include "gtest/gtest.h"
#include "TestBench.h"
static const double kDelayTime = 0.1;
/**
* A fixture with a digital input and a digital output physically wired
* together.
@@ -17,17 +19,17 @@ class DIOLoopTest : public testing::Test {
protected:
DigitalInput *m_input;
DigitalOutput *m_output;
virtual void SetUp() {
m_input = new DigitalInput(TestBench::kLoop1InputChannel);
m_output = new DigitalOutput(TestBench::kLoop1OutputChannel);
}
virtual void TearDown() {
delete m_input;
delete m_output;
}
void Reset() {
m_output->Set(false);
}
@@ -39,12 +41,14 @@ protected:
*/
TEST_F(DIOLoopTest, Loop) {
Reset();
m_output->Set(false);
Wait(kDelayTime);
EXPECT_FALSE(m_input->Get()) << "The digital output was turned off, but "
<< "the digital input is on.";
m_output->Set(true);
Wait(kDelayTime);
EXPECT_TRUE(m_input->Get()) << "The digital output was turned on, but "
<< "the digital input is off.";
}
@@ -55,18 +59,19 @@ TEST_F(DIOLoopTest, Loop) {
*/
TEST_F(DIOLoopTest, FakeCounter) {
Reset();
Counter counter(m_input);
counter.Start();
EXPECT_EQ(0, counter.Get()) << "Counter did not initialize to 0.";
/* Count 100 ticks. The counter value should be 100 after this loop. */
for(int i = 0; i < 100; i++) {
m_output->Set(true);
m_output->Set(false);
}
Wait(kDelayTime);
EXPECT_EQ(100, counter.Get()) << "Counter did not count up to 100.";
}