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

Side by Side Diff: core/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp

Issue 2392603004: Move core/fpdfapi/fpdf_parser to core/fpdfapi/parser (Closed)
Patch Set: Rebase to master Created 4 years, 2 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
OLDNEW
(Empty)
1 // Copyright 2015 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/fpdfapi/fpdf_parser/fpdf_parser_decode.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/test_support.h"
9
10 TEST(fpdf_parser_decode, A85Decode) {
11 pdfium::DecodeTestData test_data[] = {
12 // Empty src string.
13 STR_IN_OUT_CASE("", "", 0),
14 // Empty content in src string.
15 STR_IN_OUT_CASE("~>", "", 0),
16 // Regular conversion.
17 STR_IN_OUT_CASE("FCfN8~>", "test", 7),
18 // End at the ending mark.
19 STR_IN_OUT_CASE("FCfN8~>FCfN8", "test", 7),
20 // Skip whitespaces.
21 STR_IN_OUT_CASE("\t F C\r\n \tf N 8 ~>", "test", 17),
22 // No ending mark.
23 STR_IN_OUT_CASE("@3B0)DJj_BF*)>@Gp#-s", "a funny story :)", 20),
24 // Non-multiple length.
25 STR_IN_OUT_CASE("12A", "2k", 3),
26 // Stop at unknown characters.
27 STR_IN_OUT_CASE("FCfN8FCfN8vw", "testtest", 11),
28 };
29 for (size_t i = 0; i < FX_ArraySize(test_data); ++i) {
30 pdfium::DecodeTestData* ptr = &test_data[i];
31 uint8_t* result = nullptr;
32 uint32_t result_size = 0;
33 EXPECT_EQ(ptr->processed_size,
34 A85Decode(ptr->input, ptr->input_size, result, result_size))
35 << "for case " << i;
36 ASSERT_EQ(ptr->expected_size, result_size);
37 for (size_t j = 0; j < result_size; ++j) {
38 EXPECT_EQ(ptr->expected[j], result[j]) << "for case " << i << " char "
39 << j;
40 }
41 FX_Free(result);
42 }
43 }
44
45 TEST(fpdf_parser_decode, HexDecode) {
46 pdfium::DecodeTestData test_data[] = {
47 // Empty src string.
48 STR_IN_OUT_CASE("", "", 0),
49 // Empty content in src string.
50 STR_IN_OUT_CASE(">", "", 1),
51 // Only whitespaces in src string.
52 STR_IN_OUT_CASE("\t \r\n>", "", 7),
53 // Regular conversion.
54 STR_IN_OUT_CASE("12Ac>zzz", "\x12\xac", 5),
55 // Skip whitespaces.
56 STR_IN_OUT_CASE("12 Ac\t02\r\nBF>zzz>", "\x12\xac\x02\xbf", 13),
57 // Non-multiple length.
58 STR_IN_OUT_CASE("12A>zzz", "\x12\xa0", 4),
59 // Skips unknown characters.
60 STR_IN_OUT_CASE("12tk \tAc>zzz", "\x12\xac", 10),
61 // No ending mark.
62 STR_IN_OUT_CASE("12AcED3c3456", "\x12\xac\xed\x3c\x34\x56", 12),
63 };
64 for (size_t i = 0; i < FX_ArraySize(test_data); ++i) {
65 pdfium::DecodeTestData* ptr = &test_data[i];
66 uint8_t* result = nullptr;
67 uint32_t result_size = 0;
68 EXPECT_EQ(ptr->processed_size,
69 HexDecode(ptr->input, ptr->input_size, result, result_size))
70 << "for case " << i;
71 ASSERT_EQ(ptr->expected_size, result_size);
72 for (size_t j = 0; j < result_size; ++j) {
73 EXPECT_EQ(ptr->expected[j], result[j]) << "for case " << i << " char "
74 << j;
75 }
76 FX_Free(result);
77 }
78 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp ('k') | core/fpdfapi/fpdf_parser/fpdf_parser_utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698