diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-07-03 18:36:44 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-03 18:36:44 +0000 |
commit | 08d939291804b7f867d077d05eaead2adccb0e2d (patch) | |
tree | 603f5058da908f08fa4ae6df2761d086b16fe643 | |
parent | c205b6da9307232594bcb3f30c89306c9b1362a8 (diff) | |
download | pdfium-08d939291804b7f867d077d05eaead2adccb0e2d.tar.xz |
Test {Byte,Wide}String works with std::begin().
Test-only CL. Building another container from the string in the
manner in the test is desirable.
Change-Id: I8f41aecfd82fd27f8b9af159b887b66b566f9ac7
Reviewed-on: https://pdfium-review.googlesource.com/36910
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
-rw-r--r-- | core/fxcrt/bytestring_unittest.cpp | 10 | ||||
-rw-r--r-- | core/fxcrt/widestring_unittest.cpp | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp index 2b7d4f7836..fb5fc0d996 100644 --- a/core/fxcrt/bytestring_unittest.cpp +++ b/core/fxcrt/bytestring_unittest.cpp @@ -5,6 +5,7 @@ #include "core/fxcrt/bytestring.h" #include <algorithm> +#include <iterator> #include <vector> #include "core/fxcrt/fx_string.h" @@ -1634,6 +1635,15 @@ TEST(ByteString, MultiCharIterator) { EXPECT_EQ('a' + 'b' + 'c', sum); } +TEST(ByteString, StdBegin) { + ByteString one_str("abc"); + std::vector<uint8_t> vec(std::begin(one_str), std::end(one_str)); + ASSERT_EQ(3u, vec.size()); + EXPECT_EQ('a', vec[0]); + EXPECT_EQ('b', vec[1]); + EXPECT_EQ('c', vec[2]); +} + TEST(ByteString, AnyAllNoneOf) { ByteString str("aaaaaaaaaaaaaaaaab"); EXPECT_FALSE(std::all_of(str.begin(), str.end(), diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp index b044a81bb0..93f6b07e72 100644 --- a/core/fxcrt/widestring_unittest.cpp +++ b/core/fxcrt/widestring_unittest.cpp @@ -5,6 +5,7 @@ #include "core/fxcrt/widestring.h" #include <algorithm> +#include <iterator> #include <vector> #include "core/fxcrt/fx_string.h" @@ -1449,6 +1450,15 @@ TEST(WideString, MultiCharIterator) { EXPECT_EQ(static_cast<int32_t>(L'a' + L'b' + L'c'), sum); } +TEST(WideString, StdBegin) { + WideString one_str(L"abc"); + std::vector<wchar_t> vec(std::begin(one_str), std::end(one_str)); + ASSERT_EQ(3u, vec.size()); + EXPECT_EQ(L'a', vec[0]); + EXPECT_EQ(L'b', vec[1]); + EXPECT_EQ(L'c', vec[2]); +} + TEST(WideString, AnyAllNoneOf) { WideString str(L"aaaaaaaaaaaaaaaaab"); EXPECT_FALSE(std::all_of(str.begin(), str.end(), |