diff options
author | Elliott Hughes <enh@google.com> | 2014-09-23 14:53:10 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-09-23 14:53:10 -0700 |
commit | b05ec5ae933987e6b4a4f6a318cb13e035ad33e9 (patch) | |
tree | 64f418a870ba50ccec912a11f90605418f74c844 /tests/stdlib_test.cpp | |
parent | 8642165344217877b8a70811d19e09b584a0e10a (diff) |
Pull in upstream fixes to reject invalid bases.
Also add tests to make sure the full set works correctly.
Change-Id: I3e7f237f12c9c93e1185a97c9717803e7e55a73c
Diffstat (limited to 'tests/stdlib_test.cpp')
-rw-r--r-- | tests/stdlib_test.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp index 553f018ed..667ccd6a4 100644 --- a/tests/stdlib_test.cpp +++ b/tests/stdlib_test.cpp @@ -361,3 +361,51 @@ TEST(stdlib, unlockpt_ENOTTY) { ASSERT_EQ(ENOTTY, errno); close(fd); } + +TEST(stdlib, strtol_EINVAL) { + errno = 0; + strtol("123", NULL, -1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtol("123", NULL, 1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtol("123", NULL, 37); + ASSERT_EQ(EINVAL, errno); +} + +TEST(stdlib, strtoll_EINVAL) { + errno = 0; + strtoll("123", NULL, -1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoll("123", NULL, 1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoll("123", NULL, 37); + ASSERT_EQ(EINVAL, errno); +} + +TEST(stdlib, strtoul_EINVAL) { + errno = 0; + strtoul("123", NULL, -1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoul("123", NULL, 1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoul("123", NULL, 37); + ASSERT_EQ(EINVAL, errno); +} + +TEST(stdlib, strtoull_EINVAL) { + errno = 0; + strtoull("123", NULL, -1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoull("123", NULL, 1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoull("123", NULL, 37); + ASSERT_EQ(EINVAL, errno); +} |