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

Unified Diff: core/src/fpdfapi/fpdf_font/fpdf_font_unittest.cpp

Issue 1428593005: Add test for StringToCode and StringToWideString. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfapi/fpdf_font/fpdf_font_unittest.cpp
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_unittest.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_unittest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9101ca11c6f8c1a40a3b765062ece42e610f5265
--- /dev/null
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_unittest.cpp
@@ -0,0 +1,36 @@
+// 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 "testing/gtest/include/gtest/gtest.h"
+
+#include "font_int.h"
+
+TEST(fpdf_font, StringToCode) {
+ CPDF_ToUnicodeMap to_map;
+
+ EXPECT_EQ(0, to_map.StringToCode(""));
+ EXPECT_EQ(194, to_map.StringToCode("<c2"));
+ EXPECT_EQ(162, to_map.StringToCode("<A2"));
+ EXPECT_EQ(2802, to_map.StringToCode("<Af2"));
+ EXPECT_EQ(12, to_map.StringToCode("12"));
+ EXPECT_EQ(128, to_map.StringToCode("128"));
+}
+
+TEST(fpdf_font, StringToWideString) {
+ CPDF_ToUnicodeMap to_map;
+
+ EXPECT_EQ(L"", to_map.StringToWideString(""));
+ EXPECT_EQ(L"", to_map.StringToWideString("1234"));
+
+ EXPECT_EQ(L"", to_map.StringToWideString("<c2"));
+
+ CFX_WideString res = L"";
+ res += 49835;
Tom Sepez 2015/11/02 18:00:28 ????
dsinclair 2015/11/02 18:14:28 Done. Converted to res += L"\xc2ab"; to be cleare
+ EXPECT_EQ(res, to_map.StringToWideString("<c2ab"));
+ EXPECT_EQ(res, to_map.StringToWideString("<c2abab"));
+ EXPECT_EQ(res, to_map.StringToWideString("<c2ab 1234"));
+
+ res += 64171;
+ EXPECT_EQ(res, to_map.StringToWideString("<c2abFaAb"));
+}

Powered by Google App Engine
This is Rietveld 408576698