OLD | NEW |
---|---|
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/fpdfapi/fpdf_font/font_int.h" | 5 #include "core/fpdfapi/fpdf_font/font_int.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace { | 8 namespace { |
9 | 9 |
10 bool uint_ranges_equal(uint8_t* a, uint8_t* b, size_t count) { | 10 bool uint_ranges_equal(uint8_t* a, uint8_t* b, size_t count) { |
(...skipping 10 matching lines...) Expand all Loading... | |
21 EXPECT_EQ(0u, CPDF_CMapParser::CMap_GetCode("")); | 21 EXPECT_EQ(0u, CPDF_CMapParser::CMap_GetCode("")); |
22 EXPECT_EQ(0u, CPDF_CMapParser::CMap_GetCode("<")); | 22 EXPECT_EQ(0u, CPDF_CMapParser::CMap_GetCode("<")); |
23 EXPECT_EQ(194u, CPDF_CMapParser::CMap_GetCode("<c2")); | 23 EXPECT_EQ(194u, CPDF_CMapParser::CMap_GetCode("<c2")); |
24 EXPECT_EQ(162u, CPDF_CMapParser::CMap_GetCode("<A2")); | 24 EXPECT_EQ(162u, CPDF_CMapParser::CMap_GetCode("<A2")); |
25 EXPECT_EQ(2802u, CPDF_CMapParser::CMap_GetCode("<Af2")); | 25 EXPECT_EQ(2802u, CPDF_CMapParser::CMap_GetCode("<Af2")); |
26 EXPECT_EQ(162u, CPDF_CMapParser::CMap_GetCode("<A2z")); | 26 EXPECT_EQ(162u, CPDF_CMapParser::CMap_GetCode("<A2z")); |
27 | 27 |
28 EXPECT_EQ(12u, CPDF_CMapParser::CMap_GetCode("12")); | 28 EXPECT_EQ(12u, CPDF_CMapParser::CMap_GetCode("12")); |
29 EXPECT_EQ(12u, CPDF_CMapParser::CMap_GetCode("12d")); | 29 EXPECT_EQ(12u, CPDF_CMapParser::CMap_GetCode("12d")); |
30 EXPECT_EQ(128u, CPDF_CMapParser::CMap_GetCode("128")); | 30 EXPECT_EQ(128u, CPDF_CMapParser::CMap_GetCode("128")); |
31 | |
32 // Overflow a uint32_t. | |
33 EXPECT_EQ(0u, CPDF_CMapParser::CMap_GetCode("<FFFFFFFFa")); | |
Tom Sepez
2016/09/21 18:58:13
nit: how about 100000000, the first thing that ove
dsinclair
2016/09/21 19:00:32
Done.
| |
34 EXPECT_EQ(4294967295u, CPDF_CMapParser::CMap_GetCode("<FFFFFFFF")); | |
Tom Sepez
2016/09/21 18:58:13
nit: this should come before the case at line 33 s
dsinclair
2016/09/21 19:00:32
Done.
| |
31 } | 35 } |
32 | 36 |
33 TEST(fpdf_font_cid, CMap_GetCodeRange) { | 37 TEST(fpdf_font_cid, CMap_GetCodeRange) { |
34 CMap_CodeRange range; | 38 CMap_CodeRange range; |
35 | 39 |
36 // Must start with a < | 40 // Must start with a < |
37 EXPECT_FALSE(CPDF_CMapParser::CMap_GetCodeRange(range, "", "")); | 41 EXPECT_FALSE(CPDF_CMapParser::CMap_GetCodeRange(range, "", "")); |
38 EXPECT_FALSE(CPDF_CMapParser::CMap_GetCodeRange(range, "A", "")); | 42 EXPECT_FALSE(CPDF_CMapParser::CMap_GetCodeRange(range, "A", "")); |
39 | 43 |
40 // m_CharSize must be <= 4 | 44 // m_CharSize must be <= 4 |
(...skipping 15 matching lines...) Expand all Loading... | |
56 EXPECT_EQ(1, range.m_CharSize); | 60 EXPECT_EQ(1, range.m_CharSize); |
57 EXPECT_EQ(161, range.m_Lower[0]); | 61 EXPECT_EQ(161, range.m_Lower[0]); |
58 EXPECT_EQ(243, range.m_Upper[0]); | 62 EXPECT_EQ(243, range.m_Upper[0]); |
59 | 63 |
60 // The second string should return 0's if it is shorter | 64 // The second string should return 0's if it is shorter |
61 EXPECT_TRUE(CPDF_CMapParser::CMap_GetCodeRange(range, "<a1>", "")); | 65 EXPECT_TRUE(CPDF_CMapParser::CMap_GetCodeRange(range, "<a1>", "")); |
62 EXPECT_EQ(1, range.m_CharSize); | 66 EXPECT_EQ(1, range.m_CharSize); |
63 EXPECT_EQ(161, range.m_Lower[0]); | 67 EXPECT_EQ(161, range.m_Lower[0]); |
64 EXPECT_EQ(0, range.m_Upper[0]); | 68 EXPECT_EQ(0, range.m_Upper[0]); |
65 } | 69 } |
OLD | NEW |