Changeset b401b33 in mainline for uspace/lib/c/test/strtol.c
- Timestamp:
- 2019-06-06T12:15:29Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2a103b5, e28175d
- Parents:
- 83b64a59 (diff), 42e91ae (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-06-06 12:15:29)
- git-committer:
- GitHub <noreply@…> (2019-06-06 12:15:29)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/test/strtol.c
r83b64a59 rb401b33 38 38 #include <stdlib.h> 39 39 #include <str.h> 40 #include <limits.h> 40 41 41 42 PCUT_INIT; … … 217 218 /* Correct result. */ 218 219 PCUT_ASSERT_INT_EQUALS(EOVERFLOW, rc); 219 PCUT_ASSERT_UINT_EQUALS(UINT64_MAX, result);220 220 #endif 221 221 … … 245 245 /* Correct result. */ 246 246 PCUT_ASSERT_INT_EQUALS(EOVERFLOW, rc); 247 PCUT_ASSERT_UINT_EQUALS(UINT64_MAX, result);248 247 #endif 248 } 249 250 PCUT_TEST(strtoul_negative_wraparound) 251 { 252 long output; 253 char *endp; 254 char *endp_unchanged = (char *) "endp_unchanged unique pointer"; 255 int errno_unchanged = -1; 256 const char *input; 257 int base; 258 259 /* 260 * N2176 7.22.1.4 The strtol, strtoll, strtoul, and strtoull functions 261 * 262 * "If the subject sequence begins with a minus sign, the value 263 * resulting from the conversion is negated (in the return type)." 264 */ 265 266 endp = endp_unchanged; 267 errno = errno_unchanged; 268 output = strtoul(input = "-10", &endp, base = 0); 269 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 270 PCUT_ASSERT_PTR_EQUALS(input + 3, endp); 271 PCUT_ASSERT_UINT_EQUALS(-(10ul), output); 249 272 } 250 273 … … 404 427 endp = endp_unchanged; 405 428 errno = errno_unchanged; 429 output = strtol(input = " 0xg", &endp, base = 0); 430 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 431 PCUT_ASSERT_PTR_EQUALS(input + 5, endp); 432 PCUT_ASSERT_INT_EQUALS(0, output); 433 434 endp = endp_unchanged; 435 errno = errno_unchanged; 406 436 output = strtol(input = " 0x1", &endp, base = 0); 407 437 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); … … 418 448 endp = endp_unchanged; 419 449 errno = errno_unchanged; 450 output = strtol(input = " 0xg", &endp, base = 16); 451 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 452 PCUT_ASSERT_PTR_EQUALS(input + 5, endp); 453 PCUT_ASSERT_INT_EQUALS(0, output); 454 455 endp = endp_unchanged; 456 errno = errno_unchanged; 457 output = strtol(input = " g", &endp, base = 16); 458 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 459 PCUT_ASSERT_PTR_EQUALS(input, endp); 460 PCUT_ASSERT_INT_EQUALS(0, output); 461 462 endp = endp_unchanged; 463 errno = errno_unchanged; 420 464 output = strtol(input = " 0x1", &endp, base = 16); 421 465 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 422 466 PCUT_ASSERT_PTR_EQUALS(input + 7, endp); 423 467 PCUT_ASSERT_INT_EQUALS(1, output); 468 469 endp = endp_unchanged; 470 errno = errno_unchanged; 471 output = strtol(input = " +", &endp, base = 0); 472 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 473 PCUT_ASSERT_PTR_EQUALS(input, endp); 474 PCUT_ASSERT_INT_EQUALS(0, output); 475 476 endp = endp_unchanged; 477 errno = errno_unchanged; 478 output = strtol(input = " -", &endp, base = 0); 479 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 480 PCUT_ASSERT_PTR_EQUALS(input, endp); 481 PCUT_ASSERT_INT_EQUALS(0, output); 482 483 endp = endp_unchanged; 484 errno = errno_unchanged; 485 output = strtol(input = " +", &endp, base = 10); 486 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 487 PCUT_ASSERT_PTR_EQUALS(input, endp); 488 PCUT_ASSERT_INT_EQUALS(0, output); 489 490 endp = endp_unchanged; 491 errno = errno_unchanged; 492 output = strtol(input = " -", &endp, base = 10); 493 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 494 PCUT_ASSERT_PTR_EQUALS(input, endp); 495 PCUT_ASSERT_INT_EQUALS(0, output); 496 497 endp = endp_unchanged; 498 errno = errno_unchanged; 499 output = strtol(input = "+", &endp, base = 0); 500 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 501 PCUT_ASSERT_PTR_EQUALS(input, endp); 502 PCUT_ASSERT_INT_EQUALS(0, output); 503 504 endp = endp_unchanged; 505 errno = errno_unchanged; 506 output = strtol(input = "-", &endp, base = 0); 507 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 508 PCUT_ASSERT_PTR_EQUALS(input, endp); 509 PCUT_ASSERT_INT_EQUALS(0, output); 510 511 endp = endp_unchanged; 512 errno = errno_unchanged; 513 output = strtol(input = "+", &endp, base = 10); 514 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 515 PCUT_ASSERT_PTR_EQUALS(input, endp); 516 PCUT_ASSERT_INT_EQUALS(0, output); 517 518 endp = endp_unchanged; 519 errno = errno_unchanged; 520 output = strtol(input = "-", &endp, base = 10); 521 PCUT_ASSERT_INT_EQUALS(errno_unchanged, errno); 522 PCUT_ASSERT_PTR_EQUALS(input, endp); 523 PCUT_ASSERT_INT_EQUALS(0, output); 424 524 } 425 525
Note:
See TracChangeset
for help on using the changeset viewer.