aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/tests/utils/int_array_view_test.cpp
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2014-11-11 06:19:31 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-11 06:19:31 +0000
commita9ff7e971e1623c965cf3676d6f4486f4e69e4a4 (patch)
treeaedc8cd95d88295f43aed07734aa17c539792f6f /native/jni/tests/utils/int_array_view_test.cpp
parent57ddc316740fdb10b3ff377b18d53f063875b013 (diff)
parent7a3e6242103b7637171c6430bb9cca916583bfc0 (diff)
downloadlatinime-a9ff7e971e1623c965cf3676d6f4486f4e69e4a4.tar.gz
latinime-a9ff7e971e1623c965cf3676d6f4486f4e69e4a4.tar.xz
latinime-a9ff7e971e1623c965cf3676d6f4486f4e69e4a4.zip
am 7a3e6242: Merge "Implement IntArrayView::split for dicttoolkit."
* commit '7a3e6242103b7637171c6430bb9cca916583bfc0': Implement IntArrayView::split for dicttoolkit.
Diffstat (limited to 'native/jni/tests/utils/int_array_view_test.cpp')
-rw-r--r--native/jni/tests/utils/int_array_view_test.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/native/jni/tests/utils/int_array_view_test.cpp b/native/jni/tests/utils/int_array_view_test.cpp
index 4757a416b..2fce633f5 100644
--- a/native/jni/tests/utils/int_array_view_test.cpp
+++ b/native/jni/tests/utils/int_array_view_test.cpp
@@ -151,5 +151,52 @@ TEST(IntArrayViewTest, TestToVector) {
EXPECT_EQ(std::vector<int>(), CodePointArrayView().toVector());
}
+TEST(IntArrayViewTest, TestSplit) {
+ EXPECT_TRUE(IntArrayView().split(0, 0).empty());
+ {
+ const auto intArrayViews = IntArrayView().split(0, 1);
+ EXPECT_EQ(1u, intArrayViews.size());
+ EXPECT_TRUE(intArrayViews[0].empty());
+ }
+ {
+ const auto intArrayViews = IntArrayView().split(0, 100);
+ EXPECT_EQ(1u, intArrayViews.size());
+ EXPECT_TRUE(intArrayViews[0].empty());
+ }
+
+ const std::vector<int> intVector = {1, 2, 3, 3, 2, 3};
+ const IntArrayView intArrayView(intVector);
+ {
+ const auto intArrayViews = intArrayView.split(2);
+ EXPECT_EQ(3u, intArrayViews.size());
+ EXPECT_EQ(std::vector<int>({1}), intArrayViews[0].toVector());
+ EXPECT_EQ(std::vector<int>({3, 3}), intArrayViews[1].toVector());
+ EXPECT_EQ(std::vector<int>({3}), intArrayViews[2].toVector());
+ }
+ {
+ const auto intArrayViews = intArrayView.split(2, 2);
+ EXPECT_EQ(2u, intArrayViews.size());
+ EXPECT_EQ(std::vector<int>({1}), intArrayViews[0].toVector());
+ EXPECT_EQ(std::vector<int>({3, 3, 2, 3}), intArrayViews[1].toVector());
+ }
+ {
+ const auto intArrayViews = intArrayView.split(2, 1);
+ EXPECT_EQ(1u, intArrayViews.size());
+ EXPECT_EQ(intVector, intArrayViews[0].toVector());
+ }
+ {
+ const auto intArrayViews = intArrayView.split(2, 0);
+ EXPECT_EQ(0u, intArrayViews.size());
+ }
+ {
+ const auto intArrayViews = intArrayView.split(3);
+ EXPECT_EQ(4u, intArrayViews.size());
+ EXPECT_EQ(std::vector<int>({1, 2}), intArrayViews[0].toVector());
+ EXPECT_EQ(std::vector<int>(), intArrayViews[1].toVector());
+ EXPECT_EQ(std::vector<int>({2}), intArrayViews[2].toVector());
+ EXPECT_EQ(std::vector<int>(), intArrayViews[3].toVector());
+ }
+}
+
} // namespace
} // namespace latinime