Skip to content

Commit b4144b8

Browse files
authored
Merge pull request #111 from Hyp-ed/tel-tests-namespaces
Removed using keywords from all tests and changing structs to classes
2 parents f79991e + 3b5bd4b commit b4144b8

14 files changed

+114
-80
lines changed

test/state_machine/state.test.cpp

+24-12
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ class StateTest : public hyped::testing::Test {
7171
/**
7272
* Testing Idle behaviour with respect to data
7373
*/
74-
struct IdleTest : public StateTest {
74+
class IdleTest : public StateTest {
75+
protected:
7576
state_machine::Idle *state = state_machine::Idle::getInstance();
7677
};
7778

@@ -131,7 +132,8 @@ TEST_F(IdleTest, handlesAllInitialised)
131132
// Pre- Calibrating Tests
132133
//---------------------------------------------------------------------------
133134

134-
struct PreCalibratingTest : public StateTest {
135+
class PreCalibratingTest : public StateTest {
136+
protected:
135137
state_machine::PreCalibrating *state = state_machine::PreCalibrating::getInstance();
136138
};
137139

@@ -195,7 +197,8 @@ TEST_F(PreCalibratingTest, handlesCalibrateCommand)
195197
* Testing Calibrating behaviour with respect to data
196198
*/
197199

198-
struct CalibratingTest : public StateTest {
200+
class CalibratingTest : public StateTest {
201+
protected:
199202
state_machine::Calibrating *state = state_machine::Calibrating::getInstance();
200203
};
201204

@@ -259,7 +262,8 @@ TEST_F(CalibratingTest, handlesAllReady)
259262
/**
260263
* Testing Ready behaviour with respect to data
261264
*/
262-
struct ReadyTest : public StateTest {
265+
class ReadyTest : public StateTest {
266+
protected:
263267
state_machine::Ready *state = state_machine::Ready::getInstance();
264268
};
265269

@@ -325,7 +329,8 @@ TEST_F(ReadyTest, handlesLaunchCommand)
325329
/**
326330
* Testing Accelerating behaviour with respect to data
327331
*/
328-
struct AcceleratingTest : public StateTest {
332+
class AcceleratingTest : public StateTest {
333+
protected:
329334
state_machine::Accelerating *state = state_machine::Accelerating::getInstance();
330335
};
331336

@@ -433,7 +438,8 @@ TEST_F(AcceleratingTest, handlesReachedMaxVelocity)
433438
/**
434439
* Testing Cruising behaviour with respect to data
435440
*/
436-
struct CruisingTest : public StateTest {
441+
class CruisingTest : public StateTest {
442+
protected:
437443
state_machine::Cruising *state = state_machine::Cruising::getInstance();
438444
};
439445

@@ -498,7 +504,8 @@ TEST_F(CruisingTest, handlesInBrakingZone)
498504
/**
499505
* Testing PreBraking behaviour with respect to data
500506
*/
501-
struct PreBrakingTest : public StateTest {
507+
class PreBrakingTest : public StateTest {
508+
protected:
502509
state_machine::PreBraking *state = state_machine::PreBraking::getInstance();
503510
};
504511

@@ -563,7 +570,8 @@ TEST_F(PreBrakingTest, handlesHighPowerOff)
563570
/**
564571
* Testing NominalBraking behaviour with respect to data
565572
*/
566-
struct NominalBrakingTest : public StateTest {
573+
class NominalBrakingTest : public StateTest {
574+
protected:
567575
state_machine::NominalBraking *state = state_machine::NominalBraking::getInstance();
568576
};
569577

@@ -628,7 +636,8 @@ TEST_F(NominalBrakingTest, handlesStopped)
628636
/**
629637
* Testing Finished behaviour with respect to data
630638
*/
631-
struct FinishedTest : public StateTest {
639+
class FinishedTest : public StateTest {
640+
protected:
632641
state_machine::Finished *state = state_machine::Finished::getInstance();
633642
};
634643

@@ -663,7 +672,8 @@ TEST_F(FinishedTest, handlesShutdownCommand)
663672
/**
664673
* Testing failure pre-braking behaviour with respect to data
665674
*/
666-
struct FailurePreBrakingTest : public StateTest {
675+
class FailurePreBrakingTest : public StateTest {
676+
protected:
667677
state_machine::FailurePreBraking *state = state_machine::FailurePreBraking::getInstance();
668678
};
669679

@@ -698,7 +708,8 @@ TEST_F(FailurePreBrakingTest, handlesHighPowerOff)
698708
/**
699709
* Testing failure Braking behaviour with respect to data
700710
*/
701-
struct FailureBrakingTest : public StateTest {
711+
class FailureBrakingTest : public StateTest {
712+
protected:
702713
state_machine::FailureBraking *state = state_machine::FailureBraking::getInstance();
703714
};
704715

@@ -733,7 +744,8 @@ TEST_F(FailureBrakingTest, handlesStopped)
733744
/**
734745
* Testing FailureStopped behaviour with respect to data
735746
*/
736-
struct FailureStoppedTest : public StateTest {
747+
class FailureStoppedTest : public StateTest {
748+
protected:
737749
state_machine::FailureStopped *state = state_machine::FailureStopped::getInstance();
738750
};
739751

test/state_machine/transitions.test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace hyped::testing {
1515

1616
/**
17-
* Struct used for testing transition functions. Contains
17+
* Class used for testing transition functions. Contains
1818
*
1919
* 1. Logger
2020
* 2. Error messages
@@ -967,4 +967,4 @@ TEST_F(TransitionFunctionality, handlesNonpositiveVelocity)
967967
}
968968
}
969969

970-
} // namespace hyped::testing
970+
} // namespace hyped::testing

test/telemetry/writer_convert_module_status.test.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,43 @@
55
#include <data/data.hpp>
66
#include <telemetry/writer.hpp>
77

8-
using namespace hyped::telemetry;
9-
using namespace hyped::data;
8+
namespace hyped::testing {
109

1110
/**
1211
* Tests the conversion of Module Status from Enum to String as required for GUI
1312
*/
14-
struct WriterConvertModuleStatus : public ::testing::Test {
13+
class WriterConvertModuleStatus : public ::testing::Test {
1514
protected:
1615
void SetUp() {}
1716
void TearDown() {}
1817
};
1918

2019
TEST_F(WriterConvertModuleStatus, convertsStartStatus)
2120
{
22-
std::string convertedModuleStatus = Writer::convertModuleStatus(ModuleStatus::kStart);
21+
std::string convertedModuleStatus
22+
= telemetry::Writer::convertModuleStatus(data::ModuleStatus::kStart);
2323
ASSERT_EQ(convertedModuleStatus, "START") << "Should convert Start status.";
2424
}
2525

2626
TEST_F(WriterConvertModuleStatus, convertsInitStatus)
2727
{
28-
std::string convertedModuleStatus = Writer::convertModuleStatus(ModuleStatus::kInit);
28+
std::string convertedModuleStatus
29+
= telemetry::Writer::convertModuleStatus(data::ModuleStatus::kInit);
2930
ASSERT_EQ(convertedModuleStatus, "INIT") << "Should convert Init status.";
3031
}
3132

3233
TEST_F(WriterConvertModuleStatus, convertsReadyStatus)
3334
{
34-
std::string convertedModuleStatus = Writer::convertModuleStatus(ModuleStatus::kReady);
35+
std::string convertedModuleStatus
36+
= telemetry::Writer::convertModuleStatus(data::ModuleStatus::kReady);
3537
ASSERT_EQ(convertedModuleStatus, "READY") << "Should convert Ready status.";
3638
}
3739

3840
TEST_F(WriterConvertModuleStatus, convertsCriticalFailureState)
3941
{
40-
std::string convertedModuleStatus = Writer::convertModuleStatus(ModuleStatus::kCriticalFailure);
42+
std::string convertedModuleStatus
43+
= telemetry::Writer::convertModuleStatus(data::ModuleStatus::kCriticalFailure);
4144
ASSERT_EQ(convertedModuleStatus, "CRITICAL_FAILURE") << "Should convert Critical Failure status.";
4245
}
46+
47+
} // namespace hyped::testing

test/telemetry/writer_convert_state_machine_state.test.cpp

+21-14
Original file line numberDiff line numberDiff line change
@@ -4,80 +4,87 @@
44
#include "gtest/gtest.h"
55
#include "telemetry/writer.hpp"
66

7-
using namespace hyped::telemetry;
8-
using namespace hyped::data;
7+
namespace hyped::testing {
98

109
/**
1110
* Tests the conversion of State from Enum to String as required for GUI
1211
*/
13-
struct WriterConvertStateMachineState : public ::testing::Test {
12+
class WriterConvertStateMachineState : public ::testing::Test {
1413
protected:
1514
void SetUp() {}
1615
void TearDown() {}
1716
};
1817

1918
TEST_F(WriterConvertStateMachineState, convertsIdleState)
2019
{
21-
std::string convertedState = Writer::convertStateMachineState(State::kIdle);
20+
std::string convertedState = telemetry::Writer::convertStateMachineState(data::State::kIdle);
2221
ASSERT_EQ(convertedState, "IDLE") << "Should convert Idle state.";
2322
}
2423

2524
TEST_F(WriterConvertStateMachineState, convertsCalibratingState)
2625
{
27-
std::string convertedState = Writer::convertStateMachineState(State::kCalibrating);
26+
std::string convertedState
27+
= telemetry::Writer::convertStateMachineState(data::State::kCalibrating);
2828
ASSERT_EQ(convertedState, "CALIBRATING") << "Should convert Calibrating state.";
2929
}
3030

3131
TEST_F(WriterConvertStateMachineState, convertsPreCalibratingState)
3232
{
33-
std::string convertedState = Writer::convertStateMachineState(State::kPreCalibrating);
33+
std::string convertedState
34+
= telemetry::Writer::convertStateMachineState(data::State::kPreCalibrating);
3435
ASSERT_EQ(convertedState, "PRE_CALIBRATING") << "Should convert Pre-calibrating state.";
3536
}
3637

3738
TEST_F(WriterConvertStateMachineState, convertsReadyState)
3839
{
39-
std::string convertedState = Writer::convertStateMachineState(State::kReady);
40+
std::string convertedState = telemetry::Writer::convertStateMachineState(data::State::kReady);
4041
ASSERT_EQ(convertedState, "READY") << "Should convert Ready state.";
4142
}
4243

4344
TEST_F(WriterConvertStateMachineState, convertsAcceleratingState)
4445
{
45-
std::string convertedState = Writer::convertStateMachineState(State::kAccelerating);
46+
std::string convertedState
47+
= telemetry::Writer::convertStateMachineState(data::State::kAccelerating);
4648
ASSERT_EQ(convertedState, "ACCELERATING") << "Should convert Accelerating state.";
4749
}
4850

4951
TEST_F(WriterConvertStateMachineState, convertsCruisingState)
5052
{
51-
std::string convertedState = Writer::convertStateMachineState(State::kCruising);
53+
std::string convertedState = telemetry::Writer::convertStateMachineState(data::State::kCruising);
5254
ASSERT_EQ(convertedState, "CRUISING") << "Should convert Cruising state.";
5355
}
5456

5557
TEST_F(WriterConvertStateMachineState, convertsNominalBrakingState)
5658
{
57-
std::string convertedState = Writer::convertStateMachineState(State::kNominalBraking);
59+
std::string convertedState
60+
= telemetry::Writer::convertStateMachineState(data::State::kNominalBraking);
5861
ASSERT_EQ(convertedState, "NOMINAL_BRAKING") << "Should convert Nominal Braking state.";
5962
}
6063

6164
TEST_F(WriterConvertStateMachineState, convertsEmergencyBrakingState)
6265
{
63-
std::string convertedState = Writer::convertStateMachineState(State::kEmergencyBraking);
66+
std::string convertedState
67+
= telemetry::Writer::convertStateMachineState(data::State::kEmergencyBraking);
6468
ASSERT_EQ(convertedState, "EMERGENCY_BRAKING") << "Should convert Emergency Braking state.";
6569
}
6670

6771
TEST_F(WriterConvertStateMachineState, convertsFailureStoppedState)
6872
{
69-
std::string convertedState = Writer::convertStateMachineState(State::kFailureStopped);
73+
std::string convertedState
74+
= telemetry::Writer::convertStateMachineState(data::State::kFailureStopped);
7075
ASSERT_EQ(convertedState, "FAILURE_STOPPED") << "Should convert Failure Stopped state.";
7176
}
7277

7378
TEST_F(WriterConvertStateMachineState, convertsFinishedState)
7479
{
75-
std::string convertedState = Writer::convertStateMachineState(State::kFinished);
80+
std::string convertedState = telemetry::Writer::convertStateMachineState(data::State::kFinished);
7681
ASSERT_EQ(convertedState, "FINISHED") << "Should convert Finished state.";
7782
}
7883

7984
TEST_F(WriterConvertStateMachineState, convertsInvalidState)
8085
{
81-
std::string convertedState = Writer::convertStateMachineState(State::kInvalid);
86+
std::string convertedState = telemetry::Writer::convertStateMachineState(data::State::kInvalid);
8287
ASSERT_EQ(convertedState, "INVALID") << "Should convert Invalid state.";
8388
}
89+
90+
} // namespace hyped::testing

test/utils/differentiator.test.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ using hyped::utils::math::Differentiator;
1616
// -------------------------------------------------------------------------------------------------
1717

1818
/**
19-
* Struct used for test fixtures testing functionality.
19+
* Class used for test fixtures testing functionality.
2020
* Constructor sets the values of the DataPoint objects.
2121
* Helper functions defined to assist in testing
2222
*/
23-
struct DifferentiatorFunctionality : public ::testing::Test {
23+
class DifferentiatorFunctionality : public ::testing::Test {
2424
protected:
2525
Differentiator<float> diff_test;
2626
DataPoint<float> test_point;
@@ -124,11 +124,11 @@ TEST_F(DifferentiatorFunctionality, derivativeOfSameValue)
124124
// -------------------------------------------------------------------------------------------------
125125

126126
/**
127-
* Struct used in Testing the Differentiator special cases for linear and constants.
127+
* Class used in Testing the Differentiator special cases for linear and constants.
128128
* Constructor populates an array of DataPoints with sample data for each of the functions.
129129
* These arrays are then accessed in the Test's for Test data.
130130
*/
131-
struct SpecialCases : public ::testing::Test {
131+
class SpecialCases : public ::testing::Test {
132132
protected:
133133
Differentiator<float> diff_linear;
134134
DataPoint<float> linear_data[100];
@@ -180,11 +180,11 @@ TEST_F(SpecialCases, differentiatorConstantCase)
180180
// -------------------------------------------------------------------------------------------------
181181

182182
/**
183-
* Struct used for checking the Sum of Derivatives property
183+
* Class used for checking the Sum of Derivatives property
184184
* Creates an Array of DataPoints for the linear, quadratic, and function data.
185185
* These arrays are later accessed in the tests for Test Data.
186186
*/
187-
struct DifferentiatorProperty : public ::testing::Test {
187+
class DifferentiatorProperty : public ::testing::Test {
188188
protected:
189189
Differentiator<float> diff_linear;
190190
Differentiator<float> diff_quadratic;

test/utils/integrator.test.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ TEST(IntegratorFunctionalityTest, handlesInitializationTest)
6363
// -------------------------------------------------------------------------------------------------
6464

6565
/**
66-
* @brief struct used to setup all needed variables to make property tests of Integrator
66+
* @brief class used to setup all needed variables to make property tests of Integrator
6767
*
6868
*/
69-
struct IntegratorPropertyTest : public ::testing::Test {
69+
class IntegratorPropertyTest : public ::testing::Test {
70+
protected:
7071
int number_of_points = 101;
7172
DataPoint<float> datafunction[101];
7273

@@ -180,10 +181,11 @@ TEST_F(IntegratorPropertyTest, ConstantMultiplyTest)
180181
// Linear Tests
181182
// -------------------------------------------------------------------------------------------------
182183
/**
183-
* @brief struct used to set up all needed variables to make linear tests of Integrator
184+
* @brief class used to set up all needed variables to make linear tests of Integrator
184185
*
185186
*/
186-
struct IntegratorTestLinear : public ::testing::Test {
187+
class IntegratorTestLinear : public ::testing::Test {
188+
protected:
187189
int max_time = 100;
188190
DataPoint<float> datatry[101];
189191
DataPoint<float> datatry2[101];

0 commit comments

Comments
 (0)