1176c853dSMichael Jones //===-- Unittests for string_view -----------------------------------------===// 22a7ed8fcSSiva Chandra Reddy // 32a7ed8fcSSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42a7ed8fcSSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information. 52a7ed8fcSSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 62a7ed8fcSSiva Chandra Reddy // 72a7ed8fcSSiva Chandra Reddy //===----------------------------------------------------------------------===// 82a7ed8fcSSiva Chandra Reddy 9aa59c981SGuillaume Chatelet #include "src/__support/CPP/string_view.h" 10af1315c2SSiva Chandra Reddy #include "test/UnitTest/Test.h" 112a7ed8fcSSiva Chandra Reddy 12b6bc9d72SGuillaume Chatelet using LIBC_NAMESPACE::cpp::string_view; 13e0aece27SGuillaume Chatelet 142a7ed8fcSSiva Chandra Reddy TEST(LlvmLibcStringViewTest, InitializeCheck) { 15aa59c981SGuillaume Chatelet string_view v; 162a7ed8fcSSiva Chandra Reddy ASSERT_EQ(v.size(), size_t(0)); 172a7ed8fcSSiva Chandra Reddy ASSERT_TRUE(v.data() == nullptr); 182a7ed8fcSSiva Chandra Reddy 19aa59c981SGuillaume Chatelet v = string_view(""); 202a7ed8fcSSiva Chandra Reddy ASSERT_EQ(v.size(), size_t(0)); 211e5b3ce7SGuillaume Chatelet ASSERT_TRUE(v.data() != nullptr); 222a7ed8fcSSiva Chandra Reddy 23aa59c981SGuillaume Chatelet v = string_view("abc", 0); 242a7ed8fcSSiva Chandra Reddy ASSERT_EQ(v.size(), size_t(0)); 251e5b3ce7SGuillaume Chatelet ASSERT_TRUE(v.data() != nullptr); 262a7ed8fcSSiva Chandra Reddy 27aa59c981SGuillaume Chatelet v = string_view("123456789"); 282a7ed8fcSSiva Chandra Reddy ASSERT_EQ(v.size(), size_t(9)); 292a7ed8fcSSiva Chandra Reddy } 302a7ed8fcSSiva Chandra Reddy 312a7ed8fcSSiva Chandra Reddy TEST(LlvmLibcStringViewTest, Equals) { 32aa59c981SGuillaume Chatelet string_view v("abc"); 331e5b3ce7SGuillaume Chatelet ASSERT_EQ(v, string_view("abc")); 341e5b3ce7SGuillaume Chatelet ASSERT_NE(v, string_view()); 351e5b3ce7SGuillaume Chatelet ASSERT_NE(v, string_view("")); 361e5b3ce7SGuillaume Chatelet ASSERT_NE(v, string_view("123")); 371e5b3ce7SGuillaume Chatelet ASSERT_NE(v, string_view("abd")); 381e5b3ce7SGuillaume Chatelet ASSERT_NE(v, string_view("aaa")); 391e5b3ce7SGuillaume Chatelet ASSERT_NE(v, string_view("abcde")); 402a7ed8fcSSiva Chandra Reddy } 412a7ed8fcSSiva Chandra Reddy 42f2a7f835SRaman Tenneti TEST(LlvmLibcStringViewTest, startsWith) { 43aa59c981SGuillaume Chatelet string_view v("abc"); 44897b8014SJeff Bailey ASSERT_TRUE(v.starts_with('a')); 45aa59c981SGuillaume Chatelet ASSERT_TRUE(v.starts_with(string_view("a"))); 46aa59c981SGuillaume Chatelet ASSERT_TRUE(v.starts_with(string_view("ab"))); 47aa59c981SGuillaume Chatelet ASSERT_TRUE(v.starts_with(string_view("abc"))); 48aa59c981SGuillaume Chatelet ASSERT_TRUE(v.starts_with(string_view())); 49aa59c981SGuillaume Chatelet ASSERT_TRUE(v.starts_with(string_view(""))); 50897b8014SJeff Bailey ASSERT_FALSE(v.starts_with('1')); 51aa59c981SGuillaume Chatelet ASSERT_FALSE(v.starts_with(string_view("123"))); 52aa59c981SGuillaume Chatelet ASSERT_FALSE(v.starts_with(string_view("abd"))); 53aa59c981SGuillaume Chatelet ASSERT_FALSE(v.starts_with(string_view("aaa"))); 54aa59c981SGuillaume Chatelet ASSERT_FALSE(v.starts_with(string_view("abcde"))); 55f2a7f835SRaman Tenneti } 56f2a7f835SRaman Tenneti 57897b8014SJeff Bailey TEST(LlvmLibcStringViewTest, endsWith) { 58aa59c981SGuillaume Chatelet string_view v("abc"); 59897b8014SJeff Bailey ASSERT_TRUE(v.ends_with('c')); 60aa59c981SGuillaume Chatelet ASSERT_TRUE(v.ends_with(string_view("c"))); 61aa59c981SGuillaume Chatelet ASSERT_TRUE(v.ends_with(string_view("bc"))); 62aa59c981SGuillaume Chatelet ASSERT_TRUE(v.ends_with(string_view("abc"))); 63aa59c981SGuillaume Chatelet ASSERT_TRUE(v.ends_with(string_view())); 64aa59c981SGuillaume Chatelet ASSERT_TRUE(v.ends_with(string_view(""))); 65897b8014SJeff Bailey ASSERT_FALSE(v.ends_with('1')); 66aa59c981SGuillaume Chatelet ASSERT_FALSE(v.ends_with(string_view("123"))); 67aa59c981SGuillaume Chatelet ASSERT_FALSE(v.ends_with(string_view("abd"))); 68aa59c981SGuillaume Chatelet ASSERT_FALSE(v.ends_with(string_view("aaa"))); 69aa59c981SGuillaume Chatelet ASSERT_FALSE(v.ends_with(string_view("abcde"))); 70897b8014SJeff Bailey } 71897b8014SJeff Bailey 722a7ed8fcSSiva Chandra Reddy TEST(LlvmLibcStringViewTest, RemovePrefix) { 73aa59c981SGuillaume Chatelet string_view a("123456789"); 748aad330eSJeff Bailey a.remove_prefix(0); 758aad330eSJeff Bailey ASSERT_EQ(a.size(), size_t(9)); 761e5b3ce7SGuillaume Chatelet ASSERT_TRUE(a == "123456789"); 772a7ed8fcSSiva Chandra Reddy 78aa59c981SGuillaume Chatelet string_view b("123456789"); 798aad330eSJeff Bailey b.remove_prefix(4); 808aad330eSJeff Bailey ASSERT_EQ(b.size(), size_t(5)); 811e5b3ce7SGuillaume Chatelet ASSERT_TRUE(b == "56789"); 822a7ed8fcSSiva Chandra Reddy 83aa59c981SGuillaume Chatelet string_view c("123456789"); 848aad330eSJeff Bailey c.remove_prefix(9); 858aad330eSJeff Bailey ASSERT_EQ(c.size(), size_t(0)); 862a7ed8fcSSiva Chandra Reddy } 872a7ed8fcSSiva Chandra Reddy 882a7ed8fcSSiva Chandra Reddy TEST(LlvmLibcStringViewTest, RemoveSuffix) { 89aa59c981SGuillaume Chatelet string_view a("123456789"); 908aad330eSJeff Bailey a.remove_suffix(0); 918aad330eSJeff Bailey ASSERT_EQ(a.size(), size_t(9)); 921e5b3ce7SGuillaume Chatelet ASSERT_TRUE(a == "123456789"); 932a7ed8fcSSiva Chandra Reddy 94aa59c981SGuillaume Chatelet string_view b("123456789"); 958aad330eSJeff Bailey b.remove_suffix(4); 968aad330eSJeff Bailey ASSERT_EQ(b.size(), size_t(5)); 971e5b3ce7SGuillaume Chatelet ASSERT_TRUE(b == "12345"); 982a7ed8fcSSiva Chandra Reddy 99aa59c981SGuillaume Chatelet string_view c("123456789"); 1008aad330eSJeff Bailey c.remove_suffix(9); 1018aad330eSJeff Bailey ASSERT_EQ(c.size(), size_t(0)); 1022a7ed8fcSSiva Chandra Reddy } 1032a7ed8fcSSiva Chandra Reddy 104e0aece27SGuillaume Chatelet TEST(LlvmLibcStringViewTest, Observer) { 105aa59c981SGuillaume Chatelet string_view ABC("abc"); 106e0aece27SGuillaume Chatelet ASSERT_EQ(ABC.size(), size_t(3)); 107e0aece27SGuillaume Chatelet ASSERT_FALSE(ABC.empty()); 108e0aece27SGuillaume Chatelet ASSERT_EQ(ABC.front(), 'a'); 109e0aece27SGuillaume Chatelet ASSERT_EQ(ABC.back(), 'c'); 110e0aece27SGuillaume Chatelet } 111e0aece27SGuillaume Chatelet 112897b8014SJeff Bailey TEST(LlvmLibcStringViewTest, FindFirstOf) { 113aa59c981SGuillaume Chatelet string_view Tmp("abca"); 114897b8014SJeff Bailey ASSERT_TRUE(Tmp.find_first_of('a') == 0); 115aa59c981SGuillaume Chatelet ASSERT_TRUE(Tmp.find_first_of('d') == string_view::npos); 116897b8014SJeff Bailey ASSERT_TRUE(Tmp.find_first_of('b') == 1); 117897b8014SJeff Bailey ASSERT_TRUE(Tmp.find_first_of('a', 0) == 0); 118897b8014SJeff Bailey ASSERT_TRUE(Tmp.find_first_of('b', 1) == 1); 119897b8014SJeff Bailey ASSERT_TRUE(Tmp.find_first_of('a', 1) == 3); 120aa59c981SGuillaume Chatelet ASSERT_TRUE(Tmp.find_first_of('a', 42) == string_view::npos); 121897b8014SJeff Bailey ASSERT_FALSE(Tmp.find_first_of('c') == 1); 122897b8014SJeff Bailey ASSERT_FALSE(Tmp.find_first_of('c', 0) == 1); 123897b8014SJeff Bailey ASSERT_FALSE(Tmp.find_first_of('c', 1) == 1); 124897b8014SJeff Bailey } 125f8322d13SSiva Chandra Reddy 126f8322d13SSiva Chandra Reddy TEST(LlvmLibcStringViewTest, FindLastOf) { 127aa59c981SGuillaume Chatelet string_view Tmp("abada"); 128f8322d13SSiva Chandra Reddy 129f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('a'), size_t(4)); 130f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('a', 123), size_t(4)); 131f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('a', 5), size_t(4)); 132f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('a', 4), size_t(4)); 133f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('a', 3), size_t(2)); 134f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('a', 2), size_t(2)); 135f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('a', 1), size_t(0)); 136f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('a', 0), size_t(0)); 137f8322d13SSiva Chandra Reddy 138f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('b'), size_t(1)); 139f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('b', 123), size_t(1)); 140f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('b', 5), size_t(1)); 141f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('b', 4), size_t(1)); 142f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('b', 3), size_t(1)); 143f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('b', 2), size_t(1)); 144f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('b', 1), size_t(1)); 145aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('b', 0), string_view::npos); 146f8322d13SSiva Chandra Reddy 147f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('d'), size_t(3)); 148f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('d', 123), size_t(3)); 149f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('d', 5), size_t(3)); 150f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('d', 4), size_t(3)); 151f8322d13SSiva Chandra Reddy ASSERT_EQ(Tmp.find_last_of('d', 3), size_t(3)); 152aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('d', 2), string_view::npos); 153aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('d', 1), string_view::npos); 154aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('d', 0), string_view::npos); 155f8322d13SSiva Chandra Reddy 156aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('e'), string_view::npos); 157aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('e', 123), string_view::npos); 158aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('e', 5), string_view::npos); 159aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('e', 4), string_view::npos); 160aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('e', 3), string_view::npos); 161aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('e', 2), string_view::npos); 162aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('e', 1), string_view::npos); 163aa59c981SGuillaume Chatelet ASSERT_EQ(Tmp.find_last_of('e', 0), string_view::npos); 164f8322d13SSiva Chandra Reddy 165aa59c981SGuillaume Chatelet string_view Empty; 166aa59c981SGuillaume Chatelet ASSERT_EQ(Empty.find_last_of('a'), string_view::npos); 167aa59c981SGuillaume Chatelet ASSERT_EQ(Empty.find_last_of('a', 0), string_view::npos); 168aa59c981SGuillaume Chatelet ASSERT_EQ(Empty.find_last_of('a', 123), string_view::npos); 169f8322d13SSiva Chandra Reddy 170aa59c981SGuillaume Chatelet string_view Empty1(""); 171aa59c981SGuillaume Chatelet ASSERT_EQ(Empty1.find_last_of('a'), string_view::npos); 172aa59c981SGuillaume Chatelet ASSERT_EQ(Empty1.find_last_of('a', 0), string_view::npos); 173aa59c981SGuillaume Chatelet ASSERT_EQ(Empty1.find_last_of('a', 123), string_view::npos); 174f8322d13SSiva Chandra Reddy } 175f6f42af0SSchrodinger ZHU Yifan 176f6f42af0SSchrodinger ZHU Yifan TEST(LlvmLibcStringViewTest, FindFirstNotOf) { 177f6f42af0SSchrodinger ZHU Yifan string_view Tmp("abada"); 178f6f42af0SSchrodinger ZHU Yifan 179f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('a'), size_t(1)); 180f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('a', 123), string_view::npos); 181f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('a', 5), string_view::npos); 182f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('a', 4), string_view::npos); 183f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('a', 3), size_t(3)); 184f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('a', 2), size_t(3)); 185f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('a', 1), size_t(1)); 186f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('a', 0), size_t(1)); 187f6f42af0SSchrodinger ZHU Yifan 188f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('b'), size_t(0)); 189f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('b', 123), string_view::npos); 190f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('b', 5), string_view::npos); 191f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('b', 4), size_t(4)); 192f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('b', 3), size_t(3)); 193f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('b', 2), size_t(2)); 194f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('b', 1), size_t(2)); 195f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('b', 0), size_t(0)); 196f6f42af0SSchrodinger ZHU Yifan 197f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('d'), size_t(0)); 198f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('d', 123), string_view::npos); 199f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('d', 5), string_view::npos); 200f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('d', 4), size_t(4)); 201f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('d', 3), size_t(4)); 202f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('d', 2), size_t(2)); 203f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('d', 1), size_t(1)); 204f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('d', 0), size_t(0)); 205f6f42af0SSchrodinger ZHU Yifan 206f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('e'), size_t(0)); 207f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('e', 123), string_view::npos); 208f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('e', 5), string_view::npos); 209f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('e', 4), size_t(4)); 210f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('e', 3), size_t(3)); 211f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('e', 2), size_t(2)); 212f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('e', 1), size_t(1)); 213f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Tmp.find_first_not_of('e', 0), size_t(0)); 214f6f42af0SSchrodinger ZHU Yifan 215f6f42af0SSchrodinger ZHU Yifan string_view Empty; 216f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Empty.find_first_not_of('a'), string_view::npos); 217f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Empty.find_first_not_of('a', 0), string_view::npos); 218f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Empty.find_first_not_of('a', 123), string_view::npos); 219f6f42af0SSchrodinger ZHU Yifan 220f6f42af0SSchrodinger ZHU Yifan string_view Empty1(""); 221f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Empty1.find_first_not_of('a'), string_view::npos); 222f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Empty1.find_first_not_of('a', 0), string_view::npos); 223f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Empty1.find_first_not_of('a', 123), string_view::npos); 224f6f42af0SSchrodinger ZHU Yifan 225f6f42af0SSchrodinger ZHU Yifan string_view Full("aaaaaaa"); 226f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Full.find_first_not_of('a'), string_view::npos); 227f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Full.find_first_not_of('a', 0), string_view::npos); 228f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Full.find_first_not_of('a', 123), string_view::npos); 229f6f42af0SSchrodinger ZHU Yifan 230f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Full.find_first_not_of('b'), size_t(0)); 231f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Full.find_first_not_of('b', 0), size_t(0)); 232f6f42af0SSchrodinger ZHU Yifan EXPECT_EQ(Full.find_first_not_of('b', 123), string_view::npos); 233f6f42af0SSchrodinger ZHU Yifan } 234f6f42af0SSchrodinger ZHU Yifan 235f6f42af0SSchrodinger ZHU Yifan TEST(LlvmLibcStringViewTest, Contains) { 236f6f42af0SSchrodinger ZHU Yifan string_view Empty; 237*a0c4f854SMichael Jones static_assert( 238*a0c4f854SMichael Jones 'a' < 'z', 239*a0c4f854SMichael Jones "This test only supports character encodings where 'a' is below 'z'"); 240f6f42af0SSchrodinger ZHU Yifan for (char c = 'a'; c < 'z'; ++c) 241f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Empty.contains(c)); 242f6f42af0SSchrodinger ZHU Yifan 243f6f42af0SSchrodinger ZHU Yifan string_view Tmp("abada"); 244f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.contains('a')); 245f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.contains('b')); 246f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.contains('c')); 247f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.contains('d')); 248f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.contains('e')); 249f6f42af0SSchrodinger ZHU Yifan 250f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.substr(1).contains('a')); 251f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.substr(1).contains('b')); 252f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(1).contains('c')); 253f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.substr(1).contains('d')); 254f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(1).contains('e')); 255f6f42af0SSchrodinger ZHU Yifan 256f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.substr(2).contains('a')); 257f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(2).contains('b')); 258f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(2).contains('c')); 259f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.substr(2).contains('d')); 260f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(2).contains('e')); 261f6f42af0SSchrodinger ZHU Yifan 262f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.substr(3).contains('a')); 263f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(3).contains('b')); 264f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(3).contains('c')); 265f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.substr(3).contains('d')); 266f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(3).contains('e')); 267f6f42af0SSchrodinger ZHU Yifan 268f6f42af0SSchrodinger ZHU Yifan EXPECT_TRUE(Tmp.substr(4).contains('a')); 269f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(4).contains('b')); 270f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(4).contains('c')); 271f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(4).contains('d')); 272f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(4).contains('e')); 273f6f42af0SSchrodinger ZHU Yifan 274f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(5).contains('a')); 275f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(5).contains('b')); 276f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(5).contains('c')); 277f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(5).contains('d')); 278f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(5).contains('e')); 279f6f42af0SSchrodinger ZHU Yifan 280f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(6).contains('a')); 281f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(6).contains('b')); 282f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(6).contains('c')); 283f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(6).contains('d')); 284f6f42af0SSchrodinger ZHU Yifan EXPECT_FALSE(Tmp.substr(6).contains('e')); 285f6f42af0SSchrodinger ZHU Yifan } 286