Pull in upstream fixes to reject invalid bases.
Also add tests to make sure the full set works correctly. Change-Id: I3e7f237f12c9c93e1185a97c9717803e7e55a73c
This commit is contained in:
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <stdio.h>
|
||||
|
||||
TEST(inttypes, misc) {
|
||||
char buf[512];
|
||||
|
||||
@@ -46,3 +47,51 @@ TEST(inttypes, wcstoimax) {
|
||||
TEST(inttypes, wcstoumax) {
|
||||
ASSERT_EQ(123U, wcstoumax(L"123", NULL, 10));
|
||||
}
|
||||
|
||||
TEST(inttypes, strtoimax_EINVAL) {
|
||||
errno = 0;
|
||||
strtoimax("123", NULL, -1);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
errno = 0;
|
||||
strtoimax("123", NULL, 1);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
errno = 0;
|
||||
strtoimax("123", NULL, 37);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
}
|
||||
|
||||
TEST(inttypes, strtoumax_EINVAL) {
|
||||
errno = 0;
|
||||
strtoumax("123", NULL, -1);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
errno = 0;
|
||||
strtoumax("123", NULL, 1);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
errno = 0;
|
||||
strtoumax("123", NULL, 37);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
}
|
||||
|
||||
TEST(inttypes, wcstoimax_EINVAL) {
|
||||
errno = 0;
|
||||
wcstoimax(L"123", NULL, -1);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
errno = 0;
|
||||
wcstoimax(L"123", NULL, 1);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
errno = 0;
|
||||
wcstoimax(L"123", NULL, 37);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
}
|
||||
|
||||
TEST(inttypes, wcstoumax_EINVAL) {
|
||||
errno = 0;
|
||||
wcstoumax(L"123", NULL, -1);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
errno = 0;
|
||||
wcstoumax(L"123", NULL, 1);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
errno = 0;
|
||||
wcstoumax(L"123", NULL, 37);
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
}
|
||||
|
Reference in New Issue
Block a user