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/fpdfapi/page/cpdf_streamcontentparser.h" 6 #include "testing/gtest/include/gtest/gtest.h" 7 8 TEST(cpdf_streamcontentparser, PDF_FindKeyAbbreviation) { 9 EXPECT_EQ(ByteStringView("BitsPerComponent"), 10 CPDF_StreamContentParser::FindKeyAbbreviationForTesting( 11 ByteStringView("BPC"))); 12 EXPECT_EQ(ByteStringView("Width"), 13 CPDF_StreamContentParser::FindKeyAbbreviationForTesting( 14 ByteStringView("W"))); 15 EXPECT_EQ(ByteStringView(""), 16 CPDF_StreamContentParser::FindKeyAbbreviationForTesting( 17 ByteStringView(""))); 18 EXPECT_EQ(ByteStringView(""), 19 CPDF_StreamContentParser::FindKeyAbbreviationForTesting( 20 ByteStringView("NoInList"))); 21 // Prefix should not match. 22 EXPECT_EQ(ByteStringView(""), 23 CPDF_StreamContentParser::FindKeyAbbreviationForTesting( 24 ByteStringView("WW"))); 25 } 26 27 TEST(cpdf_streamcontentparser, PDF_FindValueAbbreviation) { 28 EXPECT_EQ(ByteStringView("DeviceGray"), 29 CPDF_StreamContentParser::FindValueAbbreviationForTesting( 30 ByteStringView("G"))); 31 EXPECT_EQ(ByteStringView("DCTDecode"), 32 CPDF_StreamContentParser::FindValueAbbreviationForTesting( 33 ByteStringView("DCT"))); 34 EXPECT_EQ(ByteStringView(""), 35 CPDF_StreamContentParser::FindValueAbbreviationForTesting( 36 ByteStringView(""))); 37 EXPECT_EQ(ByteStringView(""), 38 CPDF_StreamContentParser::FindValueAbbreviationForTesting( 39 ByteStringView("NoInList"))); 40 // Prefix should not match. 41 EXPECT_EQ(ByteStringView(""), 42 CPDF_StreamContentParser::FindValueAbbreviationForTesting( 43 ByteStringView("II"))); 44 } 45