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

Unified Diff: core/src/fxcrt/fx_bidi_unittest.cpp

Issue 1423103002: XFA: Manual merge of Clean up IFX_BidiChar (Closed) Base URL: https://pdfium.googlesource.com/pdfium@xfa
Patch Set: address comments Created 5 years, 2 months 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
« no previous file with comments | « core/src/fxcrt/fx_bidi.cpp ('k') | core/src/fxcrt/fx_unicode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_bidi_unittest.cpp
diff --git a/core/src/fxcrt/fx_bidi_unittest.cpp b/core/src/fxcrt/fx_bidi_unittest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c629cbbdc67010cba998504c57cd3a4711b986aa
--- /dev/null
+++ b/core/src/fxcrt/fx_bidi_unittest.cpp
@@ -0,0 +1,136 @@
+// 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 "../../include/fxcrt/fx_bidi.h"
+
+namespace {
+
+const FX_WCHAR kNeutralChar = 32;
+const FX_WCHAR kLeftChar = 65;
+const FX_WCHAR kRightChar = 1424;
+
+} // namespace
+
+TEST(fxcrt, BidiCharEmpty) {
+ int32_t start = -1;
+ int32_t count = -1;
+ CFX_BidiChar bidi;
+ CFX_BidiChar::Direction dir = bidi.GetBidiInfo(nullptr, nullptr);
+ EXPECT_EQ(CFX_BidiChar::NEUTRAL, dir);
+
+ dir = bidi.GetBidiInfo(&start, nullptr);
+ EXPECT_EQ(CFX_BidiChar::NEUTRAL, dir);
+ EXPECT_EQ(0, start);
+
+ dir = bidi.GetBidiInfo(nullptr, &count);
+ EXPECT_EQ(CFX_BidiChar::NEUTRAL, dir);
+ EXPECT_EQ(0, count);
+
+ start = -1;
+ count = -1;
+ dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(CFX_BidiChar::NEUTRAL, dir);
+ EXPECT_EQ(0, start);
+ EXPECT_EQ(0, count);
+
+ EXPECT_FALSE(bidi.EndChar());
+}
+
+TEST(fxcrt, BidiCharLeft) {
+ int32_t start = -1;
+ int32_t count = -1;
+ CFX_BidiChar bidi;
+
+ EXPECT_TRUE(bidi.AppendChar(kLeftChar));
+ CFX_BidiChar::Direction dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(0, start);
+ EXPECT_EQ(0, count);
+
+ EXPECT_FALSE(bidi.AppendChar(kLeftChar));
+ EXPECT_FALSE(bidi.AppendChar(kLeftChar));
+
+ dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(CFX_BidiChar::NEUTRAL, dir);
+ EXPECT_EQ(0, start);
+ EXPECT_EQ(0, count);
+
+ EXPECT_TRUE(bidi.EndChar());
+ dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(CFX_BidiChar::LEFT, dir);
+ EXPECT_EQ(0, start);
+ EXPECT_EQ(3, count);
+
+ EXPECT_FALSE(bidi.EndChar());
+}
+
+TEST(fxcrt, BidiCharLeftNeutralRight) {
+ int32_t start = -1;
+ int32_t count = -1;
+ CFX_BidiChar bidi;
+
+ EXPECT_TRUE(bidi.AppendChar(kLeftChar));
+ CFX_BidiChar::Direction dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(0, start);
+ EXPECT_EQ(0, count);
+
+ EXPECT_FALSE(bidi.AppendChar(kLeftChar));
+ EXPECT_FALSE(bidi.AppendChar(kLeftChar));
+ EXPECT_TRUE(bidi.AppendChar(kNeutralChar));
+ dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(0, start);
+ EXPECT_EQ(3, count);
+
+ EXPECT_FALSE(bidi.AppendChar(kNeutralChar));
+ EXPECT_FALSE(bidi.AppendChar(kNeutralChar));
+ EXPECT_FALSE(bidi.AppendChar(kNeutralChar));
+ EXPECT_TRUE(bidi.AppendChar(kRightChar));
+ dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(CFX_BidiChar::NEUTRAL, dir);
+ EXPECT_EQ(3, start);
+ EXPECT_EQ(4, count);
+
+ EXPECT_TRUE(bidi.EndChar());
+ dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(CFX_BidiChar::RIGHT, dir);
+ EXPECT_EQ(7, start);
+ EXPECT_EQ(1, count);
+
+ EXPECT_FALSE(bidi.EndChar());
+}
+
+TEST(fxcrt, BidiCharLeftRightLeft) {
+ int32_t start = -1;
+ int32_t count = -1;
+ CFX_BidiChar bidi;
+
+ EXPECT_TRUE(bidi.AppendChar(kLeftChar));
+ CFX_BidiChar::Direction dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(0, start);
+ EXPECT_EQ(0, count);
+
+ EXPECT_FALSE(bidi.AppendChar(kLeftChar));
+ EXPECT_FALSE(bidi.AppendChar(kLeftChar));
+ EXPECT_TRUE(bidi.AppendChar(kRightChar));
+ dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(0, start);
+ EXPECT_EQ(3, count);
+
+ EXPECT_FALSE(bidi.AppendChar(kRightChar));
+ EXPECT_FALSE(bidi.AppendChar(kRightChar));
+ EXPECT_FALSE(bidi.AppendChar(kRightChar));
+ EXPECT_TRUE(bidi.AppendChar(kLeftChar));
+ dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(CFX_BidiChar::RIGHT, dir);
+ EXPECT_EQ(3, start);
+ EXPECT_EQ(4, count);
+
+ EXPECT_TRUE(bidi.EndChar());
+ dir = bidi.GetBidiInfo(&start, &count);
+ EXPECT_EQ(CFX_BidiChar::LEFT, dir);
+ EXPECT_EQ(7, start);
+ EXPECT_EQ(1, count);
+
+ EXPECT_FALSE(bidi.EndChar());
+}
« no previous file with comments | « core/src/fxcrt/fx_bidi.cpp ('k') | core/src/fxcrt/fx_unicode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698