summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp
blob: 4a5dc25a4c1f7d89e3356abfd306329174ee1ac9 (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
// Copyright 2015 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/font/cpdf_tounicodemap.h"

#include "testing/gtest/include/gtest/gtest.h"

TEST(cpdf_tounicodemap, StringToCode) {
  EXPECT_EQ(0u, CPDF_ToUnicodeMap::StringToCode(""));
  EXPECT_EQ(194u, CPDF_ToUnicodeMap::StringToCode("<c2"));
  EXPECT_EQ(162u, CPDF_ToUnicodeMap::StringToCode("<A2"));
  EXPECT_EQ(2802u, CPDF_ToUnicodeMap::StringToCode("<Af2"));
  EXPECT_EQ(12u, CPDF_ToUnicodeMap::StringToCode("12"));
  EXPECT_EQ(128u, CPDF_ToUnicodeMap::StringToCode("128"));
}

TEST(cpdf_tounicodemap, StringToWideString) {
  EXPECT_EQ(L"", CPDF_ToUnicodeMap::StringToWideString(""));
  EXPECT_EQ(L"", CPDF_ToUnicodeMap::StringToWideString("1234"));

  EXPECT_EQ(L"", CPDF_ToUnicodeMap::StringToWideString("<c2"));

  WideString res = L"\xc2ab";
  EXPECT_EQ(res, CPDF_ToUnicodeMap::StringToWideString("<c2ab"));
  EXPECT_EQ(res, CPDF_ToUnicodeMap::StringToWideString("<c2abab"));
  EXPECT_EQ(res, CPDF_ToUnicodeMap::StringToWideString("<c2ab 1234"));

  res += L"\xfaab";
  EXPECT_EQ(res, CPDF_ToUnicodeMap::StringToWideString("<c2abFaAb"));
}