Skip to content

Commit 0ee94bc

Browse files
author
Marcus Chang
committed
Add consistent casts and widths to constants
1 parent 71966b6 commit 0ee94bc

File tree

1 file changed

+17
-17
lines changed
  • features/minimal-printf/TESTS/minimal-printf/compliance

1 file changed

+17
-17
lines changed

features/minimal-printf/TESTS/minimal-printf/compliance/main.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ static control_t test_printf_u(const size_t call_count)
160160
result_baseline = printf("u: %u\r\n", UINT_MAX);
161161
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
162162

163-
result_minimal = mbed_printf("lu: %lu\r\n", 0);
163+
result_minimal = mbed_printf("lu: %lu\r\n", 0UL);
164164
result_baseline = printf("lu: %lu\r\n", 0UL);
165165
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
166166

167167
result_minimal = mbed_printf("lu: %lu\r\n", ULONG_MAX);
168168
result_baseline = printf("lu: %lu\r\n", ULONG_MAX);
169169
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
170170

171-
result_minimal = mbed_printf("llu: %llu\r\n", 0);
171+
result_minimal = mbed_printf("llu: %llu\r\n", 0ULL);
172172
result_baseline = printf("llu: %llu\r\n", 0ULL);
173173
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
174174

@@ -179,8 +179,8 @@ static control_t test_printf_u(const size_t call_count)
179179
#ifdef TARGET_LIKE_MBED
180180
printf("%%ju not supported by mbed\r\n");
181181
#else
182-
result_minimal = mbed_printf("ju: %ju\r\n", 0);
183-
result_baseline = printf("ju: %ju\r\n",(uintmax_t) 0);
182+
result_minimal = mbed_printf("ju: %ju\r\n", (uintmax_t) 0);
183+
result_baseline = printf("ju: %ju\r\n", (uintmax_t) 0);
184184
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
185185

186186
result_minimal = mbed_printf("ju: %ju\r\n", UINTMAX_MAX);
@@ -246,15 +246,15 @@ static control_t test_printf_x(const size_t call_count)
246246
result_baseline = printf("X: %X\r\n", UINT_MAX);
247247
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
248248

249-
result_minimal = mbed_printf("lX: %lX\r\n", 0);
249+
result_minimal = mbed_printf("lX: %lX\r\n", 0UL);
250250
result_baseline = printf("lX: %lX\r\n", 0UL);
251251
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
252252

253253
result_minimal = mbed_printf("lX: %lX\r\n", ULONG_MAX);
254254
result_baseline = printf("lX: %lX\r\n", ULONG_MAX);
255255
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
256256

257-
result_minimal = mbed_printf("llX: %llX\r\n", 0);
257+
result_minimal = mbed_printf("llX: %llX\r\n", 0ULL);
258258
result_baseline = printf("llX: %llX\r\n", 0ULL);
259259
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
260260

@@ -265,7 +265,7 @@ static control_t test_printf_x(const size_t call_count)
265265
#ifdef TARGET_LIKE_MBED
266266
printf("%%jX not supported by mbed\r\n");
267267
#else
268-
result_minimal = mbed_printf("jX: %jX\r\n", 0);
268+
result_minimal = mbed_printf("jX: %jX\r\n", (uintmax_t) 0);
269269
result_baseline = printf("jX: %jX\r\n", (uintmax_t) 0);
270270
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
271271

@@ -369,12 +369,12 @@ static control_t test_snprintf_d(const size_t call_count)
369369
#ifdef TARGET_LIKE_MBED
370370
printf("%%jd not supported by mbed\r\n");
371371
#else
372-
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "jd: %jd\r\n", INT32_MIN);
372+
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "jd: %jd\r\n", (intmax_t) INT32_MIN);
373373
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "jd: %jd\r\n", (intmax_t) INT32_MIN);
374374
TEST_ASSERT_EQUAL_STRING("jd: -2147483648\r\n", buffer_minimal);
375375
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
376376

377-
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "jd: %jd\r\n", INT32_MAX);
377+
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "jd: %jd\r\n", (intmax_t) INT32_MAX);
378378
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "jd: %jd\r\n", (intmax_t) INT32_MAX);
379379
TEST_ASSERT_EQUAL_STRING("jd: 2147483647\r\n", buffer_minimal);
380380
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
@@ -383,12 +383,12 @@ static control_t test_snprintf_d(const size_t call_count)
383383
#ifdef TARGET_LIKE_MBED
384384
printf("%%zd not supported by mbed\r\n");
385385
#else
386-
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "zd: %zd\r\n", INT32_MIN);
386+
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "zd: %zd\r\n", (ssize_t) INT32_MIN);
387387
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "zd: %zd\r\n", (ssize_t) INT32_MIN);
388388
TEST_ASSERT_EQUAL_STRING("zd: -2147483648\r\n", buffer_minimal);
389389
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
390390

391-
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "zd: %zd\r\n", INT32_MAX);
391+
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "zd: %zd\r\n", (ssize_t) INT32_MAX);
392392
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "zd: %zd\r\n", (ssize_t) INT32_MAX);
393393
TEST_ASSERT_EQUAL_STRING("zd: 2147483647\r\n", buffer_minimal);
394394
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
@@ -450,7 +450,7 @@ static control_t test_snprintf_u(const size_t call_count)
450450
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
451451
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
452452

453-
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "lu: %lu\r\n", 0);
453+
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "lu: %lu\r\n", 0UL);
454454
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "lu: %lu\r\n", 0UL);
455455
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
456456
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
@@ -460,7 +460,7 @@ static control_t test_snprintf_u(const size_t call_count)
460460
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
461461
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
462462

463-
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "llu: %llu\r\n", 0);
463+
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "llu: %llu\r\n", 0ULL);
464464
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "llu: %llu\r\n", 0ULL);
465465
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
466466
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
@@ -473,7 +473,7 @@ static control_t test_snprintf_u(const size_t call_count)
473473
#ifdef TARGET_LIKE_MBED
474474
printf("%%ju not supported by mbed\r\n");
475475
#else
476-
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "ju: %ju\r\n", 0);
476+
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "ju: %ju\r\n", (uintmax_t) 0);
477477
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "ju: %ju\r\n", (uintmax_t) 0);
478478
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
479479
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
@@ -553,7 +553,7 @@ static control_t test_snprintf_x(const size_t call_count)
553553
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
554554
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
555555

556-
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "lX: %lX\r\n", 0);
556+
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "lX: %lX\r\n", 0UL);
557557
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "lX: %lX\r\n", 0UL);
558558
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
559559
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
@@ -563,7 +563,7 @@ static control_t test_snprintf_x(const size_t call_count)
563563
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
564564
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
565565

566-
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "llX: %llX\r\n", 0);
566+
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "llX: %llX\r\n", 0ULL);
567567
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "llX: %llX\r\n", 0ULL);
568568
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
569569
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
@@ -576,7 +576,7 @@ static control_t test_snprintf_x(const size_t call_count)
576576
#ifdef TARGET_LIKE_MBED
577577
printf("%%jX not supported by mbed\r\n");
578578
#else
579-
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "jX: %jX\r\n", 0);
579+
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "jX: %jX\r\n", (uintmax_t) 0);
580580
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "jX: %jX\r\n", (uintmax_t) 0);
581581
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
582582
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);

0 commit comments

Comments
 (0)