From 4f7f4eea92b607ca3864df63e4b277abd5e5af97 Mon Sep 17 00:00:00 2001 From: Wei Li Date: Tue, 16 Feb 2016 12:52:14 -0800 Subject: Simplify string function test macro R=thestig@chromium.org Review URL: https://codereview.chromium.org/1701123002 . --- .../fpdf_parser_decode_embeddertest.cpp | 27 +++++++++--------- .../fpdf_parser/fpdf_parser_decode_unittest.cpp | 32 +++++++++++----------- 2 files changed, 29 insertions(+), 30 deletions(-) (limited to 'core') diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp index 4b2e686015..9bb9d41db1 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp @@ -19,11 +19,11 @@ class FPDFParserDecodeEmbeddertest : public EmbedderTest {}; TEST_F(FPDFParserDecodeEmbeddertest, FlateEncode) { pdfium::StrFuncTestData flate_encode_cases[] = { - STR_TEST_CASE("", "\x78\x9c\x03\x00\x00\x00\x00\x01"), - STR_TEST_CASE(" ", "\x78\x9c\x53\x00\x00\x00\x21\x00\x21"), - STR_TEST_CASE("123", "\x78\x9c\x33\x34\x32\x06\x00\01\x2d\x00\x97"), - STR_TEST_CASE("\x00\xff", "\x78\x9c\x63\xf8\x0f\x00\x01\x01\x01\x00"), - STR_TEST_CASE( + STR_IN_OUT_CASE("", "\x78\x9c\x03\x00\x00\x00\x00\x01"), + STR_IN_OUT_CASE(" ", "\x78\x9c\x53\x00\x00\x00\x21\x00\x21"), + STR_IN_OUT_CASE("123", "\x78\x9c\x33\x34\x32\x06\x00\01\x2d\x00\x97"), + STR_IN_OUT_CASE("\x00\xff", "\x78\x9c\x63\xf8\x0f\x00\x01\x01\x01\x00"), + STR_IN_OUT_CASE( "1 0 0 -1 29 763 cm\n0 0 555 735 re\nW n\nq\n0 0 555 734.394 re\n" "W n\nq\n0.8009 0 0 0.8009 0 0 cm\n1 1 1 RG 1 1 1 rg\n/G0 gs\n" "0 0 693 917 re\nf\nQ\nQ\n", @@ -50,15 +50,14 @@ TEST_F(FPDFParserDecodeEmbeddertest, FlateEncode) { TEST_F(FPDFParserDecodeEmbeddertest, FlateDecode) { pdfium::DecodeTestData flate_decode_cases[] = { - DECODE_TEST_CASE("", "", 0), - DECODE_TEST_CASE("preposterous nonsense", "", 2), - DECODE_TEST_CASE("\x78\x9c\x03\x00\x00\x00\x00\x01", "", 8), - DECODE_TEST_CASE("\x78\x9c\x53\x00\x00\x00\x21\x00\x21", " ", 9), - DECODE_TEST_CASE("\x78\x9c\x33\x34\x32\x06\x00\01\x2d\x00\x97", "123", - 11), - DECODE_TEST_CASE("\x78\x9c\x63\xf8\x0f\x00\x01\x01\x01\x00", "\x00\xff", - 10), - DECODE_TEST_CASE( + STR_IN_OUT_CASE("", "", 0), + STR_IN_OUT_CASE("preposterous nonsense", "", 2), + STR_IN_OUT_CASE("\x78\x9c\x03\x00\x00\x00\x00\x01", "", 8), + STR_IN_OUT_CASE("\x78\x9c\x53\x00\x00\x00\x21\x00\x21", " ", 9), + STR_IN_OUT_CASE("\x78\x9c\x33\x34\x32\x06\x00\01\x2d\x00\x97", "123", 11), + STR_IN_OUT_CASE("\x78\x9c\x63\xf8\x0f\x00\x01\x01\x01\x00", "\x00\xff", + 10), + STR_IN_OUT_CASE( "\x78\x9c\x33\x54\x30\x00\x42\x5d\x43\x05\x23\x4b\x05\x73\x33\x63" "\x85\xe4\x5c\x2e\x90\x80\xa9\xa9\xa9\x82\xb9\xb1\xa9\x42\x51\x2a" "\x57\xb8\x42\x1e\x57\x21\x92\xa0\x89\x9e\xb1\xa5\x09\x92\x84\x9e" diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp index 3064a24b7a..8c1d971255 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp @@ -9,21 +9,21 @@ TEST(fpdf_parser_decode, A85Decode) { pdfium::DecodeTestData test_data[] = { // Empty src string. - DECODE_TEST_CASE("", "", 0), + STR_IN_OUT_CASE("", "", 0), // Empty content in src string. - DECODE_TEST_CASE("~>", "", 0), + STR_IN_OUT_CASE("~>", "", 0), // Regular conversion. - DECODE_TEST_CASE("FCfN8~>", "test", 7), + STR_IN_OUT_CASE("FCfN8~>", "test", 7), // End at the ending mark. - DECODE_TEST_CASE("FCfN8~>FCfN8", "test", 7), + STR_IN_OUT_CASE("FCfN8~>FCfN8", "test", 7), // Skip whitespaces. - DECODE_TEST_CASE("\t F C\r\n \tf N 8 ~>", "test", 17), + STR_IN_OUT_CASE("\t F C\r\n \tf N 8 ~>", "test", 17), // No ending mark. - DECODE_TEST_CASE("@3B0)DJj_BF*)>@Gp#-s", "a funny story :)", 20), + STR_IN_OUT_CASE("@3B0)DJj_BF*)>@Gp#-s", "a funny story :)", 20), // Non-multiple length. - DECODE_TEST_CASE("12A", "2k", 3), + STR_IN_OUT_CASE("12A", "2k", 3), // Stop at unknown characters. - DECODE_TEST_CASE("FCfN8FCfN8vw", "testtest", 11), + STR_IN_OUT_CASE("FCfN8FCfN8vw", "testtest", 11), }; for (size_t i = 0; i < FX_ArraySize(test_data); ++i) { pdfium::DecodeTestData* ptr = &test_data[i]; @@ -44,21 +44,21 @@ TEST(fpdf_parser_decode, A85Decode) { TEST(fpdf_parser_decode, HexDecode) { pdfium::DecodeTestData test_data[] = { // Empty src string. - DECODE_TEST_CASE("", "", 0), + STR_IN_OUT_CASE("", "", 0), // Empty content in src string. - DECODE_TEST_CASE(">", "", 1), + STR_IN_OUT_CASE(">", "", 1), // Only whitespaces in src string. - DECODE_TEST_CASE("\t \r\n>", "", 7), + STR_IN_OUT_CASE("\t \r\n>", "", 7), // Regular conversion. - DECODE_TEST_CASE("12Ac>zzz", "\x12\xac", 5), + STR_IN_OUT_CASE("12Ac>zzz", "\x12\xac", 5), // Skip whitespaces. - DECODE_TEST_CASE("12 Ac\t02\r\nBF>zzz>", "\x12\xac\x02\xbf", 13), + STR_IN_OUT_CASE("12 Ac\t02\r\nBF>zzz>", "\x12\xac\x02\xbf", 13), // Non-multiple length. - DECODE_TEST_CASE("12A>zzz", "\x12\xa0", 4), + STR_IN_OUT_CASE("12A>zzz", "\x12\xa0", 4), // Skips unknown characters. - DECODE_TEST_CASE("12tk \tAc>zzz", "\x12\xac", 10), + STR_IN_OUT_CASE("12tk \tAc>zzz", "\x12\xac", 10), // No ending mark. - DECODE_TEST_CASE("12AcED3c3456", "\x12\xac\xed\x3c\x34\x56", 12), + STR_IN_OUT_CASE("12AcED3c3456", "\x12\xac\xed\x3c\x34\x56", 12), }; for (size_t i = 0; i < FX_ArraySize(test_data); ++i) { pdfium::DecodeTestData* ptr = &test_data[i]; -- cgit v1.2.3