Skip to content

Commit 80d4110

Browse files
strongly-typedsalkinium
authored andcommitted
[tests] Replace enum with enum class
1 parent b6d0a09 commit 80d4110

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

test/modm/communication/xpcc/dispatcher_test.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ DispatcherTest::testEventTransmission()
147147

148148
// Event was delivered to the internal component
149149
TEST_ASSERT_EQUALS(timeline->events.getSize(), 1U);
150-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::EVENT);
150+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Event);
151151
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x21);
152152
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 2);
153153
TEST_ASSERT_EQUALS(timeline->events.getFront().payload.getSize(), 4U);
@@ -171,7 +171,7 @@ DispatcherTest::testInternalActionCallNoParameter()
171171
dispatcher->update();
172172

173173
TEST_ASSERT_EQUALS(timeline->events.getSize(), 1U);
174-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
174+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
175175
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x10);
176176
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 1);
177177
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 2);
@@ -190,7 +190,7 @@ DispatcherTest::testInternalActionCallUnit16()
190190
dispatcher->update();
191191

192192
TEST_ASSERT_EQUALS(timeline->events.getSize(), 1U);
193-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
193+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
194194
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x11);
195195
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 1);
196196
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 2);
@@ -214,14 +214,14 @@ DispatcherTest::testInternalActionCallDirectResponse()
214214

215215
TEST_ASSERT_EQUALS(timeline->events.getSize(), 2U);
216216

217-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
217+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
218218
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x12);
219219
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 1);
220220
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 2);
221221
TEST_ASSERT_EQUALS(timeline->events.getFront().payload.getSize(), 0U);
222222

223223
timeline->events.removeFront();
224-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::RESPONSE);
224+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Response);
225225
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x30);
226226
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 2);
227227
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 1);
@@ -242,7 +242,7 @@ DispatcherTest::testInternalActionCallDelayedResponse()
242242

243243
TEST_ASSERT_EQUALS(timeline->events.getSize(), 1U);
244244

245-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
245+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
246246
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x13);
247247
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 1);
248248
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 2);
@@ -256,7 +256,7 @@ DispatcherTest::testInternalActionCallDelayedResponse()
256256

257257
TEST_ASSERT_EQUALS(timeline->events.getSize(), 1U);
258258

259-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::RESPONSE);
259+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Response);
260260
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x30);
261261
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 2);
262262
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 1);
@@ -277,7 +277,7 @@ DispatcherTest::testInternalActionCallWithRecall()
277277

278278
TEST_ASSERT_EQUALS(timeline->events.getSize(), 2U);
279279

280-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
280+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
281281
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x14);
282282
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 1);
283283
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 2);
@@ -287,7 +287,7 @@ DispatcherTest::testInternalActionCallWithRecall()
287287
0x4321U);
288288

289289
timeline->events.removeFront();
290-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
290+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
291291
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x11);
292292
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 2);
293293
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 1);
@@ -318,15 +318,15 @@ DispatcherTest::testInternalActionBackAndForth()
318318
TEST_ASSERT_EQUALS(timeline->events.getSize(), 7U);
319319

320320
// 1
321-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
321+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
322322
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x12);
323323
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 1);
324324
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 2);
325325
TEST_ASSERT_EQUALS(timeline->events.getFront().payload.getSize(), 0U);
326326

327327
// 2
328328
timeline->events.removeFront();
329-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
329+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
330330
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x14);
331331
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 1);
332332
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 2);
@@ -337,15 +337,15 @@ DispatcherTest::testInternalActionBackAndForth()
337337

338338
// 3
339339
timeline->events.removeFront();
340-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
340+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
341341
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x10);
342342
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 2);
343343
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 1);
344344
TEST_ASSERT_EQUALS(timeline->events.getFront().payload.getSize(), 0U);
345345

346346
// 4
347347
timeline->events.removeFront();
348-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
348+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
349349
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x11);
350350
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 2);
351351
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 1);
@@ -356,23 +356,23 @@ DispatcherTest::testInternalActionBackAndForth()
356356

357357
// 5
358358
timeline->events.removeFront();
359-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::RESPONSE);
359+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Response);
360360
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x32);
361361
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 2);
362362
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 1);
363363
TEST_ASSERT_EQUALS(timeline->events.getFront().payload.getSize(), 0U);
364364

365365
// 6
366366
timeline->events.removeFront();
367-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::ACTION);
367+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Action);
368368
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x12);
369369
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 1);
370370
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 2);
371371
TEST_ASSERT_EQUALS(timeline->events.getFront().payload.getSize(), 0U);
372372

373373
// 7
374374
timeline->events.removeFront();
375-
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::RESPONSE);
375+
TEST_ASSERT_TRUE(timeline->events.getFront().type == Timeline::Type::Response);
376376
TEST_ASSERT_EQUALS(timeline->events.getFront().id, 0x30);
377377
TEST_ASSERT_EQUALS(timeline->events.getFront().component, 2);
378378
TEST_ASSERT_EQUALS(timeline->events.getFront().source, 1);

test/modm/communication/xpcc/testing_component_1.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ void
3535
TestingComponent1::actionNoParameter(const xpcc::ResponseHandle& handle)
3636
{
3737
timeline->events.append(
38-
Timeline::Event(Timeline::ACTION, 1, 0x10, handle.getDestination()));
38+
Timeline::Event(Timeline::Type::Action, 1, 0x10, handle.getDestination()));
3939
}
4040

4141
void
4242
TestingComponent1::actionUint16(const xpcc::ResponseHandle& handle,
4343
const uint16_t *parameter)
4444
{
4545
timeline->events.append(
46-
Timeline::Event(Timeline::ACTION, 1, 0x11, handle.getDestination(), parameter));
46+
Timeline::Event(Timeline::Type::Action, 1, 0x11, handle.getDestination(), parameter));
4747
}
4848

4949
void
5050
TestingComponent1::actionDirectResponse(const xpcc::ResponseHandle& handle)
5151
{
5252
timeline->events.append(
53-
Timeline::Event(Timeline::ACTION, 1, 0x12, handle.getDestination()));
53+
Timeline::Event(Timeline::Type::Action, 1, 0x12, handle.getDestination()));
5454

5555
this->sendResponse(handle);
5656
}
@@ -59,7 +59,7 @@ void
5959
TestingComponent1::actionDelayedResponse(const xpcc::ResponseHandle& handle)
6060
{
6161
timeline->events.append(
62-
Timeline::Event(Timeline::ACTION, 1, 0x13, handle.getDestination()));
62+
Timeline::Event(Timeline::Type::Action, 1, 0x13, handle.getDestination()));
6363

6464
this->delayedResponseHandle = handle;
6565
this->isDelayedResponseActive = true;
@@ -70,7 +70,7 @@ TestingComponent1::actionUint16CallAction(const xpcc::ResponseHandle& handle,
7070
const uint16_t *parameter)
7171
{
7272
timeline->events.append(
73-
Timeline::Event(Timeline::ACTION, 1, 0x14, handle.getDestination(), parameter));
73+
Timeline::Event(Timeline::Type::Action, 1, 0x14, handle.getDestination(), parameter));
7474

7575
this->callAction(2, 0x11, *parameter);
7676
}
@@ -80,13 +80,13 @@ void
8080
TestingComponent1::eventNoParameter(const xpcc::Header& header)
8181
{
8282
timeline->events.append(
83-
Timeline::Event(Timeline::EVENT, 2, 0x20, header.source));
83+
Timeline::Event(Timeline::Type::Event, 2, 0x20, header.source));
8484
}
8585

8686
void
8787
TestingComponent1::eventUint32(const xpcc::Header& header,
8888
const uint32_t *parameter)
8989
{
9090
timeline->events.append(
91-
Timeline::Event(Timeline::EVENT, 1, 0x21, header.source, parameter));
91+
Timeline::Event(Timeline::Type::Event, 1, 0x21, header.source, parameter));
9292
}

test/modm/communication/xpcc/testing_component_2.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ void
3131
TestingComponent2::actionNoParameter(const xpcc::ResponseHandle& handle)
3232
{
3333
timeline->events.append(
34-
Timeline::Event(Timeline::ACTION, 2, 0x10, handle.getDestination()));
34+
Timeline::Event(Timeline::Type::Action, 2, 0x10, handle.getDestination()));
3535
}
3636

3737
void
3838
TestingComponent2::actionUint16(const xpcc::ResponseHandle& handle,
3939
const uint16_t *parameter)
4040
{
4141
timeline->events.append(
42-
Timeline::Event(Timeline::ACTION, 2, 0x11, handle.getDestination(),
42+
Timeline::Event(Timeline::Type::Action, 2, 0x11, handle.getDestination(),
4343
parameter));
4444
}
4545

@@ -48,7 +48,7 @@ void
4848
TestingComponent2::eventNoParameter(const xpcc::Header& header)
4949
{
5050
timeline->events.append(
51-
Timeline::Event(Timeline::EVENT, 2, 0x10, header.source));
51+
Timeline::Event(Timeline::Type::Event, 2, 0x10, header.source));
5252
}
5353

5454

@@ -57,22 +57,22 @@ void
5757
TestingComponent2::responseNoParameter(const xpcc::Header& header)
5858
{
5959
timeline->events.append(
60-
Timeline::Event(Timeline::RESPONSE, 2, 0x30, header.source));
60+
Timeline::Event(Timeline::Type::Response, 2, 0x30, header.source));
6161
}
6262

6363
void
6464
TestingComponent2::responseUint16(const xpcc::Header& header,
6565
const uint16_t *parameter)
6666
{
6767
timeline->events.append(
68-
Timeline::Event(Timeline::RESPONSE, 2, 0x31, header.source, parameter));
68+
Timeline::Event(Timeline::Type::Response, 2, 0x31, header.source, parameter));
6969
}
7070

7171
void
7272
TestingComponent2::responseCallAction(const xpcc::Header& header)
7373
{
7474
timeline->events.append(
75-
Timeline::Event(Timeline::RESPONSE, 2, 0x32, header.source));
75+
Timeline::Event(Timeline::Type::Response, 2, 0x32, header.source));
7676

7777
xpcc::ResponseCallback callback(this, &TestingComponent2::responseNoParameter);
7878
this->callAction(1, 0x12, callback);

test/modm/communication/xpcc/timeline.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
// ----------------------------------------------------------------------------
1414

15-
#include <cstring> // for std::memcpy
1615
#include "timeline.hpp"
1716

1817
Timeline::Event::Event(Type type, uint8_t component, uint8_t id,

test/modm/communication/xpcc/timeline.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
class Timeline
2323
{
2424
public:
25-
enum Type
25+
enum class Type : uint8_t
2626
{
27-
EVENT,
28-
ACTION,
29-
RESPONSE
27+
Event,
28+
Action,
29+
Response,
3030
};
3131

3232
struct Event

0 commit comments

Comments
 (0)