diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-08-31 16:08:39 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-31 20:29:45 +0000 |
commit | a864419a26164350a27ff03f34fa30d0166bc077 (patch) | |
tree | 174ed423bdd19e7acfdd699d39292cc2255e0bc8 /core/fxcrt/fx_system_unittest.cpp | |
parent | 2a1c8ac53f249bfe2789ea95170f11d308992449 (diff) | |
download | pdfium-a864419a26164350a27ff03f34fa30d0166bc077.tar.xz |
Move implementations into fx_system.cpp
This CL moves code defined in fx_system.h to be implemented in
fx_system.cpp.
Change-Id: I0c19066d4497bd208f4560fdcaf57cf04bf9f146
Reviewed-on: https://pdfium-review.googlesource.com/12674
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/fx_system_unittest.cpp')
-rw-r--r-- | core/fxcrt/fx_system_unittest.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/core/fxcrt/fx_system_unittest.cpp b/core/fxcrt/fx_system_unittest.cpp index 958d295a24..6a0fe71abe 100644 --- a/core/fxcrt/fx_system_unittest.cpp +++ b/core/fxcrt/fx_system_unittest.cpp @@ -211,3 +211,83 @@ TEST(fxcrt, FXSYS_wcsftime) { FXSYS_wcsftime(buf, FX_ArraySize(buf), L"%y-%m-%dT%H:%M:%S", &feb_time); } + +TEST(fxcrt, FXSYS_atoi) { + EXPECT_EQ(0, FXSYS_atoi("")); + EXPECT_EQ(0, FXSYS_atoi("0")); + EXPECT_EQ(-1, FXSYS_atoi("-1")); + EXPECT_EQ(2345, FXSYS_atoi("2345")); + EXPECT_EQ(-2147483647, FXSYS_atoi("-2147483647")); + // Handle the sign. + EXPECT_EQ(-2345, FXSYS_atoi("-2345")); + EXPECT_EQ(2345, FXSYS_atoi("+2345")); + // The max value. + EXPECT_EQ(2147483647, FXSYS_atoi("2147483647")); + // The min value. Written in -1 format to avoid "unary minus operator applied + // to unsigned type" warning. + EXPECT_EQ(-2147483647 - 1, FXSYS_atoi("-2147483648")); + // With invalid char. + EXPECT_EQ(9, FXSYS_atoi("9x9")); + + // Out of range values. + EXPECT_EQ(2147483647, FXSYS_atoi("2147483623423412348")); + EXPECT_EQ(2147483647, FXSYS_atoi("2147483648")); + EXPECT_EQ(-2147483647 - 1, FXSYS_atoi("-2147483650")); +} + +TEST(fxcrt, FXSYS_atoi64) { + EXPECT_EQ(0, FXSYS_atoi64("")); + EXPECT_EQ(0, FXSYS_atoi64("0")); + EXPECT_EQ(-1, FXSYS_atoi64("-1")); + EXPECT_EQ(2345, FXSYS_atoi64("2345")); + EXPECT_EQ(-9223372036854775807LL, FXSYS_atoi64("-9223372036854775807")); + // Handle the sign. + EXPECT_EQ(-2345, FXSYS_atoi64("-2345")); + EXPECT_EQ(2345, FXSYS_atoi64("+2345")); + // The max value. + EXPECT_EQ(9223372036854775807LL, FXSYS_atoi64("9223372036854775807")); + // The min value. Written in -1 format to avoid implicit unsigned warning. + EXPECT_EQ(-9223372036854775807LL - 1LL, FXSYS_atoi64("-9223372036854775808")); + // With invalid char. + EXPECT_EQ(9, FXSYS_atoi64("9x9")); + + // Out of range values. + EXPECT_EQ(9223372036854775807LL, FXSYS_atoi64("922337203685471234123475807")); + EXPECT_EQ(9223372036854775807LL, FXSYS_atoi64("9223372036854775808")); + EXPECT_EQ(-9223372036854775807LL - 1LL, FXSYS_atoi64("-9223372036854775810")); +} + +TEST(fxcrt, FXSYS_wtoi) { + EXPECT_EQ(0, FXSYS_wtoi(L"")); + EXPECT_EQ(0, FXSYS_wtoi(L"0")); + EXPECT_EQ(-1, FXSYS_wtoi(L"-1")); + EXPECT_EQ(2345, FXSYS_wtoi(L"2345")); + EXPECT_EQ(-2147483647, FXSYS_wtoi(L"-2147483647")); + // The max value. + EXPECT_EQ(2147483647, FXSYS_wtoi(L"2147483647")); + // The min value. + EXPECT_EQ(-2147483647 - 1, FXSYS_wtoi(L"-2147483648")); + + // Out of range values. + EXPECT_EQ(2147483647, FXSYS_wtoi(L"2147483623423412348")); + EXPECT_EQ(2147483647, FXSYS_wtoi(L"2147483648")); + EXPECT_EQ(-2147483647 - 1, FXSYS_wtoi(L"-2147483652")); +} + +TEST(fxcrt, FXSYS_atoui) { + EXPECT_EQ(0u, FXSYS_atoui("")); + EXPECT_EQ(0u, FXSYS_atoui("0")); + EXPECT_EQ(4294967295, FXSYS_atoui("-1")); + EXPECT_EQ(2345u, FXSYS_atoui("2345")); + // Handle the sign. + EXPECT_EQ(4294964951, FXSYS_atoui("-2345")); + EXPECT_EQ(2345u, FXSYS_atoui("+2345")); + // The max value. + EXPECT_EQ(4294967295, FXSYS_atoui("4294967295")); + EXPECT_EQ(9u, FXSYS_atoui("9x9")); + + // Out of range values. + EXPECT_EQ(4294967295, FXSYS_atoui("2147483623423412348")); + EXPECT_EQ(4294967295, FXSYS_atoui("4294967296")); + EXPECT_EQ(4294967295, FXSYS_atoui("-4294967345")); +} |