|
| 1 | +/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
| 2 | +
|
| 3 | + This program is free software; you can redistribute it and/or modify |
| 4 | + it under the terms of the GNU General Public License as published by |
| 5 | + the Free Software Foundation; version 2 of the License. |
| 6 | +
|
| 7 | + This program is distributed in the hope that it will be useful, |
| 8 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | + GNU General Public License for more details. |
| 11 | +
|
| 12 | + You should have received a copy of the GNU General Public License |
| 13 | + along with this program; if not, write to the Free Software |
| 14 | + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ |
| 15 | + |
| 16 | +// First include (the generated) my_config.h, to get correct platform defines. |
| 17 | +#include "my_config.h" |
| 18 | +#include <gtest/gtest.h> |
| 19 | +/* |
| 20 | +
|
| 21 | + ==== Purpose ==== |
| 22 | +
|
| 23 | + Test if my_strtoll10 overflows values above unsigned long long |
| 24 | + limit correctly. |
| 25 | +
|
| 26 | + ==== Related Bugs and Worklogs ==== |
| 27 | +
|
| 28 | + BUG#16997513: MY_STRTOLL10 ACCEPTING OVERFLOWED UNSIGNED LONG LONG |
| 29 | + VALUES AS NORMAL ONES |
| 30 | +
|
| 31 | + ==== Implementation ==== |
| 32 | +
|
| 33 | + Check if my_strtoll10 returns the larger unsigned long long and raise |
| 34 | + the overflow error when receiving a number like 18446744073709551915 |
| 35 | +
|
| 36 | +*/ |
| 37 | +#include <m_string.h> |
| 38 | + |
| 39 | +TEST(StringToULLTest, OverflowedNumber) |
| 40 | +{ |
| 41 | + unsigned long long number; |
| 42 | + int error; |
| 43 | + const char * str= "18446744073709551915"; |
| 44 | + number= my_strtoll10(str, 0, &error); |
| 45 | + EXPECT_EQ(number, ULONGLONG_MAX); |
| 46 | + EXPECT_EQ(error, MY_ERRNO_ERANGE); |
| 47 | +} |
0 commit comments