Skip to content

Commit f1d7c3f

Browse files
Fix build warnings in unit tests
1 parent 8dc0358 commit f1d7c3f

File tree

3 files changed

+23
-35
lines changed

3 files changed

+23
-35
lines changed

test/unit-test/downloader_base64_utest.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
/* ============================ TEST GLOBALS ============================= */
2222
const size_t destLength = mqttFileDownloader_CONFIG_BLOCK_SIZE;
23-
const uint8_t * encodedTest = "dGVzdA=="; /* The string 'test' base64 encoded */
23+
const uint8_t * encodedTest = ( const uint8_t * ) "dGVzdA=="; /* The string 'test' base64 encoded */
2424
size_t encodedTestLen = 8U;
2525
size_t decodedTestLen = 4U;
2626

@@ -73,7 +73,7 @@ void test_base64Decode_decodesDataSuccessfully_2Chars( void )
7373
/* Setting to an error before the test to make sure it's the function which succeeds */
7474
decodeStatus = Base64NullPointerInput;
7575

76-
decodeStatus = base64_Decode( destBuffer, destLength, &decodeLen, "dHk=", 4U );
76+
decodeStatus = base64_Decode( destBuffer, destLength, &decodeLen, ( const uint8_t * ) "dHk=", 4U );
7777

7878
TEST_ASSERT_EQUAL( Base64Success, decodeStatus );
7979
TEST_ASSERT_EQUAL( 2, decodeLen );
@@ -84,7 +84,7 @@ void test_base64Decode_decodesDataSuccessfully_3Chars( void )
8484
/* Setting to an error before the test to make sure it's the function which succeeds */
8585
decodeStatus = Base64NullPointerInput;
8686

87-
decodeStatus = base64_Decode( destBuffer, destLength, &decodeLen, "dHJ5", 3U );
87+
decodeStatus = base64_Decode( destBuffer, destLength, &decodeLen, ( const uint8_t * ) "dHJ5", 3U );
8888

8989
TEST_ASSERT_EQUAL( Base64NonZeroPadding, decodeStatus );
9090
}

test/unit-test/downloader_cbor_utest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ void test_Decode_returnsFalse_cannotGetBlockIdValue( void )
323323
cborFindsFileIdKey();
324324
cborFileIdKeyCorrectType();
325325
cborFindsBlockIdKey();
326-
cbor_value_get_type_ExpectAndReturn( &cborValue, CborNoError );
327-
cbor_value_get_int_ExpectAndReturn( &cborValue, &blockId, (CborType) CborUnknownError );
326+
cbor_value_get_type_ExpectAndReturn( &cborValue, (CborType) CborNoError );
327+
cbor_value_get_int_ExpectAndReturn( &cborValue, &blockId, CborUnknownError );
328328

329329
result = CBOR_Decode_GetStreamResponseMessage( decodeMessageBuffer, 1234U, &fileId, &blockId, &blockSize, payload, &payloadSize );
330330
TEST_ASSERT_FALSE( result );

test/unit-test/downloader_utest.c

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ int suiteTearDown( int numFailures )
5757
/* ============================= CALLBACKS ============================= */
5858

5959
bool mqtt_subscribe_stream_json_true( char * topic,
60-
size_t topicLength,
61-
int NumCalls )
60+
size_t topicLength )
6261
{
6362
TEST_ASSERT_EQUAL_MEMORY( "$aws/things/thingname/streams/stream-name/data/json", topic, strlen( "$aws/things/thingname/streams/stream-name/data/json" ) );
6463
TEST_ASSERT_EQUAL_INT( strlen( "$aws/things/thingname/streams/stream-name/data/json" ), topicLength );
6564
return true;
6665
}
6766

6867
bool mqtt_subscribe_stream_json_false( char * topic,
69-
size_t topicLength,
70-
int NumCalls )
68+
size_t topicLength )
7169
{
7270
TEST_ASSERT_EQUAL_MEMORY( "$aws/things/thingname/streams/stream-name/data/json", topic, strlen( "$aws/things/thingname/streams/stream-name/data/json" ) );
7371
TEST_ASSERT_EQUAL_INT( strlen( "$aws/things/thingname/streams/stream-name/data/json" ), topicLength );
@@ -76,17 +74,15 @@ bool mqtt_subscribe_stream_json_false( char * topic,
7674

7775

7876
bool mqtt_subscribe_stream_cbor_true( char * topic,
79-
size_t topicLength,
80-
int NumCalls )
77+
size_t topicLength )
8178
{
8279
TEST_ASSERT_EQUAL_MEMORY( "$aws/things/thingname/streams/stream-name/data/cbor", topic, strlen( "$aws/things/thingname/streams/stream-name/data/cbor" ) );
8380
TEST_ASSERT_EQUAL_INT( strlen( "$aws/things/thingname/streams/stream-name/data/cbor" ), topicLength );
8481
return true;
8582
}
8683

8784
bool mqtt_subscribe_stream_cbor_false( char * topic,
88-
size_t topicLength,
89-
int NumCalls )
85+
size_t topicLength )
9086
{
9187
TEST_ASSERT_EQUAL_MEMORY( "$aws/things/thingname/streams/stream-name/data/cbor", topic, strlen( "$aws/things/thingname/streams/stream-name/data/cbor" ) );
9288
TEST_ASSERT_EQUAL_INT( strlen( "$aws/things/thingname/streams/stream-name/data/cbor" ), topicLength );
@@ -96,8 +92,7 @@ bool mqtt_subscribe_stream_cbor_false( char * topic,
9692
bool mqtt_publish_request_json_true( char * topic,
9793
size_t topicLength,
9894
uint8_t * message,
99-
size_t messageLength,
100-
int NumCalls )
95+
size_t messageLength )
10196
{
10297
TEST_ASSERT_EQUAL_MEMORY( getStreamTopic, topic, getStreamTopicLength );
10398
TEST_ASSERT_EQUAL_INT( getStreamTopicLength, topicLength );
@@ -109,8 +104,7 @@ bool mqtt_publish_request_json_true( char * topic,
109104
bool mqtt_publish_request_json_false( char * topic,
110105
size_t topicLength,
111106
uint8_t * message,
112-
size_t messageLength,
113-
int NumCalls )
107+
size_t messageLength )
114108
{
115109
TEST_ASSERT_EQUAL_MEMORY( getStreamTopic, topic, getStreamTopicLength );
116110
TEST_ASSERT_EQUAL_INT( getStreamTopicLength, topicLength );
@@ -208,7 +202,7 @@ void test_createGetDataBlockRequest_succeedsForCBORDataType( void )
208202
char * encodedMessage = "expected-message";
209203
size_t expectedCborSize = 9999U;
210204

211-
CBOR_Encode_GetStreamRequestMessage_ExpectAndReturn( getStreamRequest,
205+
CBOR_Encode_GetStreamRequestMessage_ExpectAndReturn( ( uint8_t * ) &getStreamRequest,
212206
GET_STREAM_REQUEST_BUFFER_SIZE,
213207
NULL,
214208
"rdy",
@@ -223,7 +217,7 @@ void test_createGetDataBlockRequest_succeedsForCBORDataType( void )
223217
CBOR_Encode_GetStreamRequestMessage_IgnoreArg_encodedMessageSize();
224218
CBOR_Encode_GetStreamRequestMessage_IgnoreArg_messageBuffer();
225219
CBOR_Encode_GetStreamRequestMessage_ReturnThruPtr_encodedMessageSize( &expectedCborSize );
226-
CBOR_Encode_GetStreamRequestMessage_ReturnThruPtr_messageBuffer( encodedMessage );
220+
CBOR_Encode_GetStreamRequestMessage_ReturnThruPtr_messageBuffer( ( uint8_t * ) encodedMessage );
227221

228222
requestLength = mqttDownloader_createGetDataBlockRequest( DATA_TYPE_CBOR, 4U, 3U, 2U, 1U, getStreamRequest, getStreamRequestLength );
229223
TEST_ASSERT_EQUAL( expectedCborSize, requestLength );
@@ -235,9 +229,6 @@ void test_createGetDataBlockRequest_FailsWhenGetStreamRequestLengthTooSmall( voi
235229
char getStreamRequest[ GET_STREAM_REQUEST_BUFFER_SIZE ];
236230
size_t getStreamRequestLength = 0;
237231

238-
char * encodedMessage = "expected-message";
239-
size_t expectedCborSize = 9999U;
240-
241232
requestLength = mqttDownloader_createGetDataBlockRequest( DATA_TYPE_JSON, 4U, 3U, 2U, 1U, getStreamRequest, getStreamRequestLength );
242233
TEST_ASSERT_EQUAL( 0, requestLength );
243234
}
@@ -246,9 +237,6 @@ void test_createGetDataBlockRequest_FailsWhenGetStreamRequestBufferIsNull( void
246237
{
247238
size_t getStreamRequestLength = GET_STREAM_REQUEST_BUFFER_SIZE;
248239

249-
char * encodedMessage = "expected-message";
250-
size_t expectedCborSize = 9999U;
251-
252240
requestLength = mqttDownloader_createGetDataBlockRequest( DATA_TYPE_JSON, 4U, 3U, 2U, 1U, NULL, getStreamRequestLength );
253241
TEST_ASSERT_EQUAL( 0, requestLength );
254242
}
@@ -313,7 +301,7 @@ void test_processReceivedDataBlock_processesJSONBlock( void )
313301
uint8_t decodedData[ mqttFileDownloader_CONFIG_BLOCK_SIZE ];
314302
size_t dataLength = 0;
315303

316-
bool result = mqttDownloader_processReceivedDataBlock( &context, "{\"p\": \"dGVzdA==\"}", strlen( "{\"p\": \"dGVzdA==\"}" ), decodedData, &dataLength );
304+
bool result = mqttDownloader_processReceivedDataBlock( &context, (uint8_t * ) "{\"p\": \"dGVzdA==\"}", strlen( "{\"p\": \"dGVzdA==\"}" ), decodedData, &dataLength );
317305

318306
TEST_ASSERT_TRUE( result );
319307
TEST_ASSERT_EQUAL( 4, dataLength );
@@ -328,7 +316,7 @@ void test_processReceivedDataBlock_invalidJSONBlock( void )
328316
uint8_t decodedData[ mqttFileDownloader_CONFIG_BLOCK_SIZE ];
329317
size_t dataLength = 0;
330318

331-
MQTTFileDownloaderStatus_t result = mqttDownloader_processReceivedDataBlock( &context, "{\"wrongKey\": \"dGVzdA==\"}", strlen( "{\"wrongKey\": \"dGVzdA==\"}" ), decodedData, &dataLength );
319+
MQTTFileDownloaderStatus_t result = mqttDownloader_processReceivedDataBlock( &context, ( uint8_t * ) "{\"wrongKey\": \"dGVzdA==\"}", strlen( "{\"wrongKey\": \"dGVzdA==\"}" ), decodedData, &dataLength );
332320

333321
TEST_ASSERT_EQUAL( 7, result );
334322
TEST_ASSERT_EQUAL( 0, dataLength );
@@ -343,7 +331,7 @@ void test_processReceivedDataBlock_invalidEncodingJSONBlock( void )
343331
uint8_t decodedData[ mqttFileDownloader_CONFIG_BLOCK_SIZE ];
344332
size_t dataLength = 0;
345333

346-
MQTTFileDownloaderStatus_t result = mqttDownloader_processReceivedDataBlock( &context, "{\"p\": \"notEncoded\"}", strlen( "{\"p\": \"notEncoded\"}" ), decodedData, &dataLength );
334+
MQTTFileDownloaderStatus_t result = mqttDownloader_processReceivedDataBlock( &context, ( uint8_t * ) "{\"p\": \"notEncoded\"}", strlen( "{\"p\": \"notEncoded\"}" ), decodedData, &dataLength );
347335

348336
TEST_ASSERT_EQUAL( 7, result );
349337
TEST_ASSERT_EQUAL( 0, dataLength );
@@ -360,15 +348,15 @@ void test_processReceivedDataBlock_processesCBORBlock( void )
360348
uint8_t decodedData[ mqttFileDownloader_CONFIG_BLOCK_SIZE ];
361349
size_t dataLength = 0;
362350

363-
CBOR_Decode_GetStreamResponseMessage_ExpectAndReturn( validCBORMsg, strlen( validCBORMsg ), NULL, NULL, NULL, NULL, NULL, true );
351+
CBOR_Decode_GetStreamResponseMessage_ExpectAndReturn( ( const uint8_t * ) validCBORMsg, strlen( validCBORMsg ), NULL, NULL, NULL, NULL, NULL, true );
364352
CBOR_Decode_GetStreamResponseMessage_IgnoreArg_fileId();
365353
CBOR_Decode_GetStreamResponseMessage_IgnoreArg_blockSize();
366354
CBOR_Decode_GetStreamResponseMessage_IgnoreArg_blockId();
367355
CBOR_Decode_GetStreamResponseMessage_IgnoreArg_payload();
368356
CBOR_Decode_GetStreamResponseMessage_IgnoreArg_payloadSize();
369357
CBOR_Decode_GetStreamResponseMessage_ReturnThruPtr_payloadSize( &expectedProcessedDataLength );
370358

371-
bool result = mqttDownloader_processReceivedDataBlock( &context, validCBORMsg, strlen( validCBORMsg ), decodedData, &dataLength );
359+
bool result = mqttDownloader_processReceivedDataBlock( &context, ( uint8_t * ) validCBORMsg, strlen( validCBORMsg ), decodedData, &dataLength );
372360

373361
TEST_ASSERT_TRUE( result );
374362
TEST_ASSERT_EQUAL( expectedProcessedDataLength, dataLength );
@@ -385,15 +373,15 @@ void test_processReceivedDataBlock_invalidCBORBlock( void )
385373
uint8_t decodedData[ mqttFileDownloader_CONFIG_BLOCK_SIZE ];
386374
size_t dataLength = 0;
387375

388-
CBOR_Decode_GetStreamResponseMessage_ExpectAndReturn( invalidCBORMsg, strlen( invalidCBORMsg ), NULL, NULL, NULL, NULL, NULL, false );
376+
CBOR_Decode_GetStreamResponseMessage_ExpectAndReturn( ( const uint8_t * ) invalidCBORMsg, strlen( invalidCBORMsg ), NULL, NULL, NULL, NULL, NULL, false );
389377
CBOR_Decode_GetStreamResponseMessage_IgnoreArg_fileId();
390378
CBOR_Decode_GetStreamResponseMessage_IgnoreArg_blockSize();
391379
CBOR_Decode_GetStreamResponseMessage_IgnoreArg_blockId();
392380
CBOR_Decode_GetStreamResponseMessage_IgnoreArg_payload();
393381
CBOR_Decode_GetStreamResponseMessage_IgnoreArg_payloadSize();
394382
CBOR_Decode_GetStreamResponseMessage_ReturnThruPtr_payloadSize( &notExpectedProcessedDataLength );
395383

396-
MQTTFileDownloaderStatus_t result = mqttDownloader_processReceivedDataBlock( &context, invalidCBORMsg, strlen( invalidCBORMsg ), decodedData, &dataLength );
384+
MQTTFileDownloaderStatus_t result = mqttDownloader_processReceivedDataBlock( &context, ( uint8_t * ) invalidCBORMsg, strlen( invalidCBORMsg ), decodedData, &dataLength );
397385

398386
TEST_ASSERT_EQUAL( 7, result );
399387
TEST_ASSERT_EQUAL( 0, dataLength );
@@ -421,7 +409,7 @@ void test_processReceivedDataBlock_returnsFailureWhenMessageLengthZero( void )
421409
uint8_t decodedData[ mqttFileDownloader_CONFIG_BLOCK_SIZE ];
422410
size_t dataLength = 0;
423411

424-
uintResult = mqttDownloader_processReceivedDataBlock( &context, "{\"p\": \"dGVzdA==\"}", 0U, decodedData, &dataLength );
412+
uintResult = mqttDownloader_processReceivedDataBlock( &context, ( uint8_t * ) "{\"p\": \"dGVzdA==\"}", 0U, decodedData, &dataLength );
425413
TEST_ASSERT_EQUAL( MQTTFileDownloaderFailure, uintResult );
426414
}
427415

@@ -434,7 +422,7 @@ void test_processReceivedDataBlock_returnsFailureWhenDataIsNull( void )
434422
uint8_t decodedData[ mqttFileDownloader_CONFIG_BLOCK_SIZE ];
435423
size_t dataLength = 0;
436424

437-
uintResult = mqttDownloader_processReceivedDataBlock( &context, "{\"p\": \"dGVzdA==\"}", strlen( "{\"p\": \"dGVzdA==\"}" ), NULL, &dataLength );
425+
uintResult = mqttDownloader_processReceivedDataBlock( &context, ( uint8_t * ) "{\"p\": \"dGVzdA==\"}", strlen( "{\"p\": \"dGVzdA==\"}" ), NULL, &dataLength );
438426
TEST_ASSERT_EQUAL( MQTTFileDownloaderFailure, uintResult );
439427
}
440428

@@ -447,6 +435,6 @@ void test_processReceivedDataBlock_returnsFailureWhenDataLengthIsNull( void )
447435
uint8_t decodedData[ mqttFileDownloader_CONFIG_BLOCK_SIZE ];
448436
size_t * dataLength = NULL;
449437

450-
uintResult = mqttDownloader_processReceivedDataBlock( &context, "{\"p\": \"dGVzdA==\"}", strlen( "{\"p\": \"dGVzdA==\"}" ), decodedData, dataLength );
438+
uintResult = mqttDownloader_processReceivedDataBlock( &context, ( uint8_t * ) "{\"p\": \"dGVzdA==\"}", strlen( "{\"p\": \"dGVzdA==\"}" ), decodedData, dataLength );
451439
TEST_ASSERT_EQUAL( MQTTFileDownloaderFailure, uintResult );
452440
}

0 commit comments

Comments
 (0)