Cleaned up integer type usage in wpilibc (#92)

Replaced all unsigned types to signed and int32_t with int in wpilibc
This commit is contained in:
Tyler Veness
2016-09-06 00:01:45 -07:00
committed by Peter Johnson
parent ff93050b31
commit 0cd05d1a42
169 changed files with 914 additions and 943 deletions

View File

@@ -40,7 +40,7 @@ class AnalogLoopTest : public testing::Test {
*/
TEST_F(AnalogLoopTest, AnalogInputWorks) {
// Set the output voltage and check if the input measures the same voltage
for (int i = 0; i < 50; i++) {
for (int32_t i = 0; i < 50; i++) {
m_output->SetVoltage(i / 10.0f);
Wait(kDelayTime);
@@ -90,7 +90,7 @@ TEST_F(AnalogLoopTest, AnalogTriggerCounterWorks) {
Counter counter(trigger);
// Turn the analog output low and high 50 times
for (int i = 0; i < 50; i++) {
for (int32_t i = 0; i < 50; i++) {
m_output->SetVoltage(1.0);
Wait(kDelayTime);
m_output->SetVoltage(4.0);
@@ -103,15 +103,15 @@ TEST_F(AnalogLoopTest, AnalogTriggerCounterWorks) {
}
static void InterruptHandler(uint32_t interruptAssertedMask, void* param) {
*reinterpret_cast<int*>(param) = 12345;
*reinterpret_cast<int32_t*>(param) = 12345;
}
TEST_F(AnalogLoopTest, AsynchronusInterruptWorks) {
int param = 0;
int32_t param = 0;
AnalogTrigger trigger(m_input);
trigger.SetLimitsVoltage(2.0f, 3.0f);
// Given an interrupt handler that sets an int to 12345
// Given an interrupt handler that sets an int32_t to 12345
std::shared_ptr<AnalogTriggerOutput> triggerOutput =
trigger.CreateOutput(AnalogTriggerType::kState);
triggerOutput->RequestInterrupts(InterruptHandler, &param);
@@ -123,7 +123,7 @@ TEST_F(AnalogLoopTest, AsynchronusInterruptWorks) {
m_output->SetVoltage(5.0);
triggerOutput->CancelInterrupts();
// Then the int should be 12345
// Then the int32_t should be 12345
Wait(kDelayTime);
EXPECT_EQ(12345, param) << "The interrupt did not run.";
}

View File

@@ -79,7 +79,7 @@ class CANJaguarTest : public testing::Test {
* called in each iteration of the main loop.
*/
void SetJaguar(float totalTime, float value = 0.0f) {
for (int i = 0; i < 50; i++) {
for (int32_t i = 0; i < 50; i++) {
m_jaguar->Set(value);
Wait(totalTime / 50.0);
}
@@ -87,7 +87,7 @@ class CANJaguarTest : public testing::Test {
/**
* returns the sign of the given number
*/
int SignNum(double value) { return -(value < 0) + (value > 0); }
int32_t SignNum(double value) { return -(value < 0) + (value > 0); }
void InversionTest(float motorValue, float delayTime = kMotorTime) {
m_jaguar->EnableControl();
m_jaguar->SetInverted(false);
@@ -218,7 +218,7 @@ TEST_F(CANJaguarTest, BrownOut) {
/* The jaguar should automatically get set to quad encoder position mode,
so it should be able to reach a setpoint in a couple seconds. */
for (int i = 0; i < 10; i++) {
for (int32_t i = 0; i < 10; i++) {
SetJaguar(1.0f, setpoint);
if (std::abs(m_jaguar->GetPosition() - setpoint) <=
@@ -333,7 +333,7 @@ TEST_F(CANJaguarTest, PositionModeWorks) {
m_jaguar->EnableControl();
/* It should get to the setpoint within 10 seconds */
for (int i = 0; i < 10; i++) {
for (int32_t i = 0; i < 10; i++) {
SetJaguar(1.0f, setpoint);
if (std::abs(m_jaguar->GetPosition() - setpoint) <=
@@ -361,7 +361,7 @@ TEST_F(CANJaguarTest, DISABLED_CurrentModeWorks) {
float expectedCurrent = std::abs(setpoints_i);
/* It should get to each setpoint within 10 seconds */
for (int j = 0; j < 10; j++) {
for (int32_t j = 0; j < 10; j++) {
SetJaguar(1.0, setpoint);
if (std::abs(m_jaguar->GetOutputCurrent() - expectedCurrent) <=
@@ -385,7 +385,7 @@ TEST_F(CANJaguarTest, FakePotentiometerPosition) {
// Set the analog output to 4 different voltages and check if the Jaguar
// returns corresponding positions.
for (int i = 0; i <= 3; i++) {
for (int32_t i = 0; i <= 3; i++) {
m_fakePotentiometer->SetVoltage(static_cast<float>(i));
SetJaguar(kPotentiometerSettlingTime);

View File

@@ -11,7 +11,7 @@
#include "Timer.h"
#include "gtest/gtest.h"
const int deviceId = 0;
const int32_t deviceId = 0;
TEST(CANTalonTest, QuickTest) {
double throttle = 0.1;

View File

@@ -128,7 +128,7 @@ TEST_F(DIOLoopTest, FakeCounter) {
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++) {
for (int32_t i = 0; i < 100; i++) {
m_output->Set(true);
Wait(kCounterTime);
m_output->Set(false);
@@ -139,13 +139,13 @@ TEST_F(DIOLoopTest, FakeCounter) {
}
static void InterruptHandler(uint32_t interruptAssertedMask, void* param) {
*reinterpret_cast<int*>(param) = 12345;
*reinterpret_cast<int32_t*>(param) = 12345;
}
TEST_F(DIOLoopTest, AsynchronousInterruptWorks) {
int param = 0;
int32_t param = 0;
// Given an interrupt handler that sets an int to 12345
// Given an interrupt handler that sets an int32_t to 12345
m_input->RequestInterrupts(InterruptHandler, &param);
m_input->EnableInterrupts();
@@ -154,7 +154,7 @@ TEST_F(DIOLoopTest, AsynchronousInterruptWorks) {
m_output->Set(true);
m_input->CancelInterrupts();
// Then the int should be 12345
// Then the int32_t should be 12345
Wait(kDelayTime);
EXPECT_EQ(12345, param) << "The interrupt did not run.";
}

View File

@@ -54,7 +54,7 @@ class FakeEncoderTest : public testing::Test {
* ticks
*/
void Simulate100QuadratureTicks() {
for (int i = 0; i < 100; i++) {
for (int32_t i = 0; i < 100; i++) {
m_outputA->Set(true);
Wait(kDelayTime);
m_outputB->Set(true);

View File

@@ -46,7 +46,7 @@ class Notification {
bool m_set = false;
};
void SetProcessorAffinity(int core_id) {
void SetProcessorAffinity(int32_t core_id) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(core_id, &cpuset);
@@ -56,7 +56,7 @@ void SetProcessorAffinity(int core_id) {
0);
}
void SetThreadRealtimePriorityOrDie(int priority) {
void SetThreadRealtimePriorityOrDie(int32_t priority) {
struct sched_param param;
// Set realtime priority for this thread
param.sched_priority = priority + sched_get_priority_min(SCHED_RR);

View File

@@ -86,7 +86,7 @@ void TiltPanCameraTest::GyroAngle() {
Wait(0.5);
m_gyro->Reset();
for (int i = 0; i < 600; i++) {
for (int32_t i = 0; i < 600; i++) {
m_pan->Set(i / 1000.0);
Wait(0.001);
}
@@ -122,7 +122,7 @@ void TiltPanCameraTest::GyroCalibratedParameters() {
Wait(0.5);
m_gyro->Reset();
for (int i = 0; i < 600; i++) {
for (int32_t i = 0; i < 600; i++) {
m_pan->Set(i / 1000.0);
Wait(0.001);
}

View File

@@ -32,8 +32,9 @@ class CommandTest : public testing::Test {
*/
void TeardownScheduler() { Scheduler::GetInstance()->ResetAll(); }
void AssertCommandState(MockCommand& command, int initialize, int execute,
int isFinished, int end, int interrupted) {
void AssertCommandState(MockCommand& command, int32_t initialize,
int32_t execute, int32_t isFinished, int32_t end,
int32_t interrupted) {
EXPECT_EQ(initialize, command.GetInitializeCount());
EXPECT_EQ(execute, command.GetExecuteCount());
EXPECT_EQ(isFinished, command.GetIsFinishedCount());