summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_streamcontentparser_unittest.cpp
blob: 0f4fc1e87a8d8f0040209c1a88041ecf368fb362 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "core/fpdfapi/page/cpdf_streamcontentparser.h"
#include "testing/gtest/include/gtest/gtest.h"

TEST(cpdf_streamcontentparser, PDF_FindKeyAbbreviation) {
  EXPECT_EQ(ByteStringView("BitsPerComponent"),
            CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
                ByteStringView("BPC")));
  EXPECT_EQ(ByteStringView("Width"),
            CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
                ByteStringView("W")));
  EXPECT_EQ(ByteStringView(""),
            CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
                ByteStringView("")));
  EXPECT_EQ(ByteStringView(""),
            CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
                ByteStringView("NoInList")));
  // Prefix should not match.
  EXPECT_EQ(ByteStringView(""),
            CPDF_StreamContentParser::FindKeyAbbreviationForTesting(
                ByteStringView("WW")));
}

TEST(cpdf_streamcontentparser, PDF_FindValueAbbreviation) {
  EXPECT_EQ(ByteStringView("DeviceGray"),
            CPDF_StreamContentParser::FindValueAbbreviationForTesting(
                ByteStringView("G")));
  EXPECT_EQ(ByteStringView("DCTDecode"),
            CPDF_StreamContentParser::FindValueAbbreviationForTesting(
                ByteStringView("DCT")));
  EXPECT_EQ(ByteStringView(""),
            CPDF_StreamContentParser::FindValueAbbreviationForTesting(
                ByteStringView("")));
  EXPECT_EQ(ByteStringView(""),
            CPDF_StreamContentParser::FindValueAbbreviationForTesting(
                ByteStringView("NoInList")));
  // Prefix should not match.
  EXPECT_EQ(ByteStringView(""),
            CPDF_StreamContentParser::FindValueAbbreviationForTesting(
                ByteStringView("II")));
}