Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: core/src/fxcrt/fx_basic_gcc_unittest.cpp

Issue 1755273002: Fix parsing of object numbers > 16,777,216. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/fx_basic_gcc.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/include/fxcrt/fx_system.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 TEST(fxcrt, FXSYS_atoi) {
9 EXPECT_EQ(0, FXSYS_atoi(""));
10 EXPECT_EQ(0, FXSYS_atoi("0"));
11 EXPECT_EQ(-1, FXSYS_atoi("-1"));
12 EXPECT_EQ(2345, FXSYS_atoi("2345"));
13 EXPECT_EQ(2147483647, FXSYS_atoi("2147483647"));
14 EXPECT_EQ(-2147483647, FXSYS_atoi("-2147483647"));
15 EXPECT_EQ(9, FXSYS_atoi("9x9"));
16
17 // TODO(dsinclair): These are all wacky .....
18 EXPECT_EQ(2147483623, FXSYS_atoi("2147483623423412348"));
19 EXPECT_EQ(214748364, FXSYS_atoi("2147483648"));
20 // The digit is parsed as a positive value, so we end up not being able to
21 // handle the largest possible negative value.
22 EXPECT_EQ(-214748364, FXSYS_atoi("-2147483648"));
23 }
24
25 TEST(fxcrt, FXSYS_atoi64) {
26 EXPECT_EQ(0, FXSYS_atoi64(""));
27 EXPECT_EQ(0, FXSYS_atoi64("0"));
28 EXPECT_EQ(-1, FXSYS_atoi64("-1"));
29 EXPECT_EQ(2345, FXSYS_atoi64("2345"));
30 EXPECT_EQ(9223372036854775807LL, FXSYS_atoi64("9223372036854775807"));
31 EXPECT_EQ(-9223372036854775807LL, FXSYS_atoi64("-9223372036854775807"));
32 EXPECT_EQ(9, FXSYS_atoi64("9x9"));
33
34 // TODO(dsinclair): These are all wacky .....
35 EXPECT_EQ(9223372036854712341LL, FXSYS_atoi64("922337203685471234123475807"));
36 EXPECT_EQ(922337203685477580LL, FXSYS_atoi64("9223372036854775808"));
37 // The digit is parsed as a positive value, so we end up not being able to
38 // handle the largest possible negative value.
39 EXPECT_EQ(-922337203685477580LL, FXSYS_atoi64("-9223372036854775808"));
40 }
41
42 TEST(fxcrt, FXSYS_wtoi) {
43 EXPECT_EQ(0, FXSYS_wtoi(L""));
44 EXPECT_EQ(0, FXSYS_wtoi(L"0"));
45 EXPECT_EQ(-1, FXSYS_wtoi(L"-1"));
46 EXPECT_EQ(2345, FXSYS_wtoi(L"2345"));
47 EXPECT_EQ(2147483647, FXSYS_wtoi(L"2147483647"));
48 EXPECT_EQ(-2147483647, FXSYS_wtoi(L"-2147483647"));
49 EXPECT_EQ(9, FXSYS_wtoi64(L"9x9"));
50
51 // TODO(dsinclair): These are all wacky .....
52 EXPECT_EQ(2147483623, FXSYS_wtoi(L"2147483623423412348"));
53 EXPECT_EQ(214748364, FXSYS_wtoi(L"2147483648"));
54 // The digit is parsed as a positive value, so we end up not being able to
55 // handle the largest possible negative value.
56 EXPECT_EQ(-214748364, FXSYS_wtoi(L"-2147483648"));
57 }
58
59 TEST(fxcrt, FXSYS_wtoi64) {
60 EXPECT_EQ(0, FXSYS_wtoi64(L""));
61 EXPECT_EQ(0, FXSYS_wtoi64(L"0"));
62 EXPECT_EQ(-1, FXSYS_wtoi64(L"-1"));
63 EXPECT_EQ(2345, FXSYS_wtoi64(L"2345"));
64 EXPECT_EQ(9223372036854775807LL, FXSYS_wtoi64(L"9223372036854775807"));
65 EXPECT_EQ(-9223372036854775807LL, FXSYS_wtoi64(L"-9223372036854775807"));
66 EXPECT_EQ(9, FXSYS_wtoi64(L"9x9"));
67
68 // TODO(dsinclair): These are all wacky .....
69 EXPECT_EQ(9223372036854712341LL,
70 FXSYS_wtoi64(L"922337203685471234123475807"));
71 EXPECT_EQ(922337203685477580LL, FXSYS_wtoi64(L"9223372036854775808"));
72 // The digit is parsed as a positive value, so we end up not being able to
73 // handle the largest possible negative value.
74 EXPECT_EQ(-922337203685477580LL, FXSYS_wtoi64(L"-9223372036854775808"));
75 }
76
77 TEST(fxcrt, FXSYS_atoui) {
78 EXPECT_EQ(0, FXSYS_atoui(""));
79 EXPECT_EQ(0, FXSYS_atoui("0"));
80 EXPECT_EQ(0, FXSYS_atoui("-1"));
81 EXPECT_EQ(2345, FXSYS_atoui("2345"));
82 EXPECT_EQ(4294967295, FXSYS_atoui("4294967295"));
83 EXPECT_EQ(9, FXSYS_atoui("9x9"));
84
85 // TODO(dsinclair): These are all wacky .....
86 EXPECT_EQ(2147483623, FXSYS_atoi("2147483623423412348"));
87 EXPECT_EQ(429496729, FXSYS_atoi("4294967296"));
88 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_gcc.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698