Major formatting changes (breaks diffs). No code changes.

The changes made in this commit do not affect any actual code,
    they are purely aesthetic. I ran clang-format with google style
    over all .h/.cpp files in wpilibc that weren't in wpilibC++Sim
    or gtest, and the eclipse formatter over all of the Java files
    using the Google eclipse formatting configuration.

Change-Id: I9627bca0bc103c398ecc1c5ba17467193291ae63
This commit is contained in:
James Kuszmaul
2015-06-25 15:07:55 -04:00
parent bd64d9a7ef
commit 7eb8550bdb
470 changed files with 89798 additions and 77287 deletions

View File

@@ -13,98 +13,108 @@ enum MotorInvertingTestType { TEST_VICTOR, TEST_JAGUAR, TEST_TALON };
static const double motorSpeed = 0.25;
static const double delayTime = 0.5;
std::ostream &operator<<(std::ostream &os, MotorInvertingTestType const &type) {
switch(type) {
case TEST_VICTOR: os << "Victor"; break;
case TEST_JAGUAR: os << "Jaguar"; break;
case TEST_TALON: os << "Talon"; break;
}
switch (type) {
case TEST_VICTOR:
os << "Victor";
break;
case TEST_JAGUAR:
os << "Jaguar";
break;
case TEST_TALON:
os << "Talon";
break;
}
return os;
return os;
}
class MotorInvertingTest : public testing::TestWithParam<MotorInvertingTestType>{
protected:
SpeedController *m_speedController;
Encoder *m_encoder;
virtual void SetUp() {
switch(GetParam()) {
case TEST_VICTOR:
m_speedController = new Victor(TestBench::kVictorChannel);
m_encoder = new Encoder(TestBench::kVictorEncoderChannelA,
TestBench::kVictorEncoderChannelB);
break;
class MotorInvertingTest
: public testing::TestWithParam<MotorInvertingTestType> {
protected:
SpeedController *m_speedController;
Encoder *m_encoder;
virtual void SetUp() {
switch (GetParam()) {
case TEST_VICTOR:
m_speedController = new Victor(TestBench::kVictorChannel);
m_encoder = new Encoder(TestBench::kVictorEncoderChannelA,
TestBench::kVictorEncoderChannelB);
break;
case TEST_JAGUAR:
m_speedController = new Jaguar(TestBench::kJaguarChannel);
m_encoder = new Encoder(TestBench::kJaguarEncoderChannelA,
TestBench::kJaguarEncoderChannelB);
break;
case TEST_JAGUAR:
m_speedController = new Jaguar(TestBench::kJaguarChannel);
m_encoder = new Encoder(TestBench::kJaguarEncoderChannelA,
TestBench::kJaguarEncoderChannelB);
break;
case TEST_TALON:
m_speedController = new Talon(TestBench::kTalonChannel);
m_encoder = new Encoder(TestBench::kTalonEncoderChannelA,
TestBench::kTalonEncoderChannelB);
break;
}
case TEST_TALON:
m_speedController = new Talon(TestBench::kTalonChannel);
m_encoder = new Encoder(TestBench::kTalonEncoderChannelA,
TestBench::kTalonEncoderChannelB);
break;
}
}
virtual void TearDown() {
delete m_speedController;
delete m_encoder;
}
}
virtual void TearDown() {
delete m_speedController;
delete m_encoder;
}
void Reset() {
m_speedController->SetInverted(false);
m_speedController->Set(0.0f);
m_encoder->Reset();
}
void Reset() {
m_speedController->SetInverted(false);
m_speedController->Set(0.0f);
m_encoder->Reset();
}
};
TEST_P(MotorInvertingTest, InvertingPositive){
Reset();
m_speedController->Set(motorSpeed);
Wait(delayTime);
bool initDirection = m_encoder->GetDirection();
m_speedController->SetInverted(true);
m_speedController->Set(motorSpeed);
Wait(delayTime);
EXPECT_TRUE(m_encoder->GetDirection()!=initDirection) <<"Inverting with Positive value does not change direction";
Reset();
TEST_P(MotorInvertingTest, InvertingPositive) {
Reset();
m_speedController->Set(motorSpeed);
Wait(delayTime);
bool initDirection = m_encoder->GetDirection();
m_speedController->SetInverted(true);
m_speedController->Set(motorSpeed);
Wait(delayTime);
EXPECT_TRUE(m_encoder->GetDirection() != initDirection)
<< "Inverting with Positive value does not change direction";
Reset();
}
TEST_P(MotorInvertingTest, InvertingNegative){
Reset();
m_speedController->SetInverted(false);
m_speedController->Set(-motorSpeed);
Wait(delayTime);
bool initDirection = m_encoder->GetDirection();
m_speedController->SetInverted(true);
m_speedController->Set(-motorSpeed);
Wait(delayTime);
EXPECT_TRUE(m_encoder->GetDirection()!=initDirection) <<"Inverting with Negative value does not change direction";
Reset();
TEST_P(MotorInvertingTest, InvertingNegative) {
Reset();
m_speedController->SetInverted(false);
m_speedController->Set(-motorSpeed);
Wait(delayTime);
bool initDirection = m_encoder->GetDirection();
m_speedController->SetInverted(true);
m_speedController->Set(-motorSpeed);
Wait(delayTime);
EXPECT_TRUE(m_encoder->GetDirection() != initDirection)
<< "Inverting with Negative value does not change direction";
Reset();
}
TEST_P(MotorInvertingTest, InvertingSwitchingPosToNeg){
Reset();
m_speedController->SetInverted(false);
m_speedController->Set(motorSpeed);
Wait(delayTime);
bool initDirection = m_encoder->GetDirection();
m_speedController->SetInverted(true);
m_speedController->Set(-motorSpeed);
Wait(delayTime);
EXPECT_TRUE(m_encoder->GetDirection()==initDirection) <<"Inverting with Switching value does change direction";
Reset();
TEST_P(MotorInvertingTest, InvertingSwitchingPosToNeg) {
Reset();
m_speedController->SetInverted(false);
m_speedController->Set(motorSpeed);
Wait(delayTime);
bool initDirection = m_encoder->GetDirection();
m_speedController->SetInverted(true);
m_speedController->Set(-motorSpeed);
Wait(delayTime);
EXPECT_TRUE(m_encoder->GetDirection() == initDirection)
<< "Inverting with Switching value does change direction";
Reset();
}
TEST_P(MotorInvertingTest, InvertingSwitchingNegToPos){
Reset();
m_speedController->SetInverted(false);
m_speedController->Set(-motorSpeed);
Wait(delayTime);
bool initDirection = m_encoder->GetDirection();
m_speedController->SetInverted(true);
m_speedController->Set(motorSpeed);
Wait(delayTime);
EXPECT_TRUE(m_encoder->GetDirection()==initDirection) <<"Inverting with Switching value does change direction";
Reset();
TEST_P(MotorInvertingTest, InvertingSwitchingNegToPos) {
Reset();
m_speedController->SetInverted(false);
m_speedController->Set(-motorSpeed);
Wait(delayTime);
bool initDirection = m_encoder->GetDirection();
m_speedController->SetInverted(true);
m_speedController->Set(motorSpeed);
Wait(delayTime);
EXPECT_TRUE(m_encoder->GetDirection() == initDirection)
<< "Inverting with Switching value does change direction";
Reset();
}
INSTANTIATE_TEST_CASE_P(Test, MotorInvertingTest,
testing::Values(TEST_VICTOR, TEST_JAGUAR, TEST_TALON));
testing::Values(TEST_VICTOR, TEST_JAGUAR, TEST_TALON));