From 3cfff70244e31f48068c32cbc4c070468f4c3e85 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 13 Apr 2017 13:41:24 -0700 Subject: Add ability to make StringCs from std::vector<>s. Pre-cursor to using more std::vector as byte buffers. The widestring test case is more complicated, where we're not sure of having any particular uint*_t type to match wchar_t. Change-Id: Ic27980f16cdbc61fac7c11f39a85eea58d19bacb Reviewed-on: https://pdfium-review.googlesource.com/4153 Reviewed-by: dsinclair Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fxcrt/cfx_bytestring_unittest.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core/fxcrt/cfx_bytestring_unittest.cpp') diff --git a/core/fxcrt/cfx_bytestring_unittest.cpp b/core/fxcrt/cfx_bytestring_unittest.cpp index 3b679a086c..9cfc773fad 100644 --- a/core/fxcrt/cfx_bytestring_unittest.cpp +++ b/core/fxcrt/cfx_bytestring_unittest.cpp @@ -4,6 +4,8 @@ #include "core/fxcrt/cfx_bytestring.h" +#include + #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -773,6 +775,17 @@ TEST(fxcrt, ByteStringCFromChar) { EXPECT_NE(longer_string, lower_a_string_from_char); } +TEST(fxcrt, ByteStringCFromVector) { + std::vector null_vec; + CFX_ByteStringC null_string(null_vec); + EXPECT_EQ(0, null_string.GetLength()); + + std::vector lower_a_vec(10, static_cast('a')); + CFX_ByteStringC lower_a_string(lower_a_vec); + EXPECT_EQ(10, lower_a_string.GetLength()); + EXPECT_EQ("aaaaaaaaaa", lower_a_string); +} + TEST(fxcrt, ByteStringCGetID) { CFX_ByteStringC null_string; EXPECT_EQ(0u, null_string.GetID()); -- cgit v1.2.3