Add {start,end}with_lower methods to StringRef.
[oota-llvm.git] / unittests / ADT / StringRefTest.cpp
1 //===- llvm/unittest/ADT/StringRefTest.cpp - StringRef unit tests ---------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/ADT/StringRef.h"
11 #include "llvm/ADT/StringExtras.h"
12 #include "llvm/ADT/Hashing.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/Support/raw_ostream.h"
15 #include "gtest/gtest.h"
16 using namespace llvm;
17
18 namespace llvm {
19
20 std::ostream &operator<<(std::ostream &OS, const StringRef &S) {
21   OS << S.str();
22   return OS;
23 }
24
25 std::ostream &operator<<(std::ostream &OS,
26                          const std::pair<StringRef, StringRef> &P) {
27   OS << "(" << P.first << ", " << P.second << ")";
28   return OS;
29 }
30
31 }
32
33 namespace {
34 TEST(StringRefTest, Construction) {
35   EXPECT_EQ("", StringRef());
36   EXPECT_EQ("hello", StringRef("hello"));
37   EXPECT_EQ("hello", StringRef("hello world", 5));
38   EXPECT_EQ("hello", StringRef(std::string("hello")));
39 }
40
41 TEST(StringRefTest, Iteration) {
42   StringRef S("hello");
43   const char *p = "hello";
44   for (const char *it = S.begin(), *ie = S.end(); it != ie; ++it, ++p)
45     EXPECT_EQ(*it, *p);
46 }
47
48 TEST(StringRefTest, StringOps) {
49   const char *p = "hello";
50   EXPECT_EQ(p, StringRef(p, 0).data());
51   EXPECT_TRUE(StringRef().empty());
52   EXPECT_EQ((size_t) 5, StringRef("hello").size());
53   EXPECT_EQ(-1, StringRef("aab").compare("aad"));
54   EXPECT_EQ( 0, StringRef("aab").compare("aab"));
55   EXPECT_EQ( 1, StringRef("aab").compare("aaa"));
56   EXPECT_EQ(-1, StringRef("aab").compare("aabb"));
57   EXPECT_EQ( 1, StringRef("aab").compare("aa"));
58   EXPECT_EQ( 1, StringRef("\xFF").compare("\1"));
59
60   EXPECT_EQ(-1, StringRef("AaB").compare_lower("aAd"));
61   EXPECT_EQ( 0, StringRef("AaB").compare_lower("aab"));
62   EXPECT_EQ( 1, StringRef("AaB").compare_lower("AAA"));
63   EXPECT_EQ(-1, StringRef("AaB").compare_lower("aaBb"));
64   EXPECT_EQ(-1, StringRef("AaB").compare_lower("bb"));
65   EXPECT_EQ( 1, StringRef("aaBb").compare_lower("AaB"));
66   EXPECT_EQ( 1, StringRef("bb").compare_lower("AaB"));
67   EXPECT_EQ( 1, StringRef("AaB").compare_lower("aA"));
68   EXPECT_EQ( 1, StringRef("\xFF").compare_lower("\1"));
69
70   EXPECT_EQ(-1, StringRef("aab").compare_numeric("aad"));
71   EXPECT_EQ( 0, StringRef("aab").compare_numeric("aab"));
72   EXPECT_EQ( 1, StringRef("aab").compare_numeric("aaa"));
73   EXPECT_EQ(-1, StringRef("aab").compare_numeric("aabb"));
74   EXPECT_EQ( 1, StringRef("aab").compare_numeric("aa"));
75   EXPECT_EQ(-1, StringRef("1").compare_numeric("10"));
76   EXPECT_EQ( 0, StringRef("10").compare_numeric("10"));
77   EXPECT_EQ( 0, StringRef("10a").compare_numeric("10a"));
78   EXPECT_EQ( 1, StringRef("2").compare_numeric("1"));
79   EXPECT_EQ( 0, StringRef("llvm_v1i64_ty").compare_numeric("llvm_v1i64_ty"));
80   EXPECT_EQ( 1, StringRef("\xFF").compare_numeric("\1"));
81   EXPECT_EQ( 1, StringRef("V16").compare_numeric("V1_q0"));
82   EXPECT_EQ(-1, StringRef("V1_q0").compare_numeric("V16"));
83   EXPECT_EQ(-1, StringRef("V8_q0").compare_numeric("V16"));
84   EXPECT_EQ( 1, StringRef("V16").compare_numeric("V8_q0"));
85   EXPECT_EQ(-1, StringRef("V1_q0").compare_numeric("V8_q0"));
86   EXPECT_EQ( 1, StringRef("V8_q0").compare_numeric("V1_q0"));
87 }
88
89 TEST(StringRefTest, Operators) {
90   EXPECT_EQ("", StringRef());
91   EXPECT_TRUE(StringRef("aab") < StringRef("aad"));
92   EXPECT_FALSE(StringRef("aab") < StringRef("aab"));
93   EXPECT_TRUE(StringRef("aab") <= StringRef("aab"));
94   EXPECT_FALSE(StringRef("aab") <= StringRef("aaa"));
95   EXPECT_TRUE(StringRef("aad") > StringRef("aab"));
96   EXPECT_FALSE(StringRef("aab") > StringRef("aab"));
97   EXPECT_TRUE(StringRef("aab") >= StringRef("aab"));
98   EXPECT_FALSE(StringRef("aaa") >= StringRef("aab"));
99   EXPECT_EQ(StringRef("aab"), StringRef("aab"));
100   EXPECT_FALSE(StringRef("aab") == StringRef("aac"));
101   EXPECT_FALSE(StringRef("aab") != StringRef("aab"));
102   EXPECT_TRUE(StringRef("aab") != StringRef("aac"));
103   EXPECT_EQ('a', StringRef("aab")[1]);
104 }
105
106 TEST(StringRefTest, Substr) {
107   StringRef Str("hello");
108   EXPECT_EQ("lo", Str.substr(3));
109   EXPECT_EQ("", Str.substr(100));
110   EXPECT_EQ("hello", Str.substr(0, 100));
111   EXPECT_EQ("o", Str.substr(4, 10));
112 }
113
114 TEST(StringRefTest, Slice) {
115   StringRef Str("hello");
116   EXPECT_EQ("l", Str.slice(2, 3));
117   EXPECT_EQ("ell", Str.slice(1, 4));
118   EXPECT_EQ("llo", Str.slice(2, 100));
119   EXPECT_EQ("", Str.slice(2, 1));
120   EXPECT_EQ("", Str.slice(10, 20));
121 }
122
123 TEST(StringRefTest, Split) {
124   StringRef Str("hello");
125   EXPECT_EQ(std::make_pair(StringRef("hello"), StringRef("")),
126             Str.split('X'));
127   EXPECT_EQ(std::make_pair(StringRef("h"), StringRef("llo")),
128             Str.split('e'));
129   EXPECT_EQ(std::make_pair(StringRef(""), StringRef("ello")),
130             Str.split('h'));
131   EXPECT_EQ(std::make_pair(StringRef("he"), StringRef("lo")),
132             Str.split('l'));
133   EXPECT_EQ(std::make_pair(StringRef("hell"), StringRef("")),
134             Str.split('o'));
135
136   EXPECT_EQ(std::make_pair(StringRef("hello"), StringRef("")),
137             Str.rsplit('X'));
138   EXPECT_EQ(std::make_pair(StringRef("h"), StringRef("llo")),
139             Str.rsplit('e'));
140   EXPECT_EQ(std::make_pair(StringRef(""), StringRef("ello")),
141             Str.rsplit('h'));
142   EXPECT_EQ(std::make_pair(StringRef("hel"), StringRef("o")),
143             Str.rsplit('l'));
144   EXPECT_EQ(std::make_pair(StringRef("hell"), StringRef("")),
145             Str.rsplit('o'));
146 }
147
148 TEST(StringRefTest, Split2) {
149   SmallVector<StringRef, 5> parts;
150   SmallVector<StringRef, 5> expected;
151
152   expected.push_back("ab"); expected.push_back("c");
153   StringRef(",ab,,c,").split(parts, ",", -1, false);
154   EXPECT_TRUE(parts == expected);
155
156   expected.clear(); parts.clear();
157   expected.push_back(""); expected.push_back("ab"); expected.push_back("");
158   expected.push_back("c"); expected.push_back("");
159   StringRef(",ab,,c,").split(parts, ",", -1, true);
160   EXPECT_TRUE(parts == expected);
161
162   expected.clear(); parts.clear();
163   expected.push_back("");
164   StringRef("").split(parts, ",", -1, true);
165   EXPECT_TRUE(parts == expected);
166
167   expected.clear(); parts.clear();
168   StringRef("").split(parts, ",", -1, false);
169   EXPECT_TRUE(parts == expected);
170
171   expected.clear(); parts.clear();
172   StringRef(",").split(parts, ",", -1, false);
173   EXPECT_TRUE(parts == expected);
174
175   expected.clear(); parts.clear();
176   expected.push_back(""); expected.push_back("");
177   StringRef(",").split(parts, ",", -1, true);
178   EXPECT_TRUE(parts == expected);
179
180   expected.clear(); parts.clear();
181   expected.push_back("a"); expected.push_back("b");
182   StringRef("a,b").split(parts, ",", -1, true);
183   EXPECT_TRUE(parts == expected);
184
185   // Test MaxSplit
186   expected.clear(); parts.clear();
187   expected.push_back("a,,b,c");
188   StringRef("a,,b,c").split(parts, ",", 0, true);
189   EXPECT_TRUE(parts == expected);
190
191   expected.clear(); parts.clear();
192   expected.push_back("a,,b,c");
193   StringRef("a,,b,c").split(parts, ",", 0, false);
194   EXPECT_TRUE(parts == expected);
195
196   expected.clear(); parts.clear();
197   expected.push_back("a"); expected.push_back(",b,c");
198   StringRef("a,,b,c").split(parts, ",", 1, true);
199   EXPECT_TRUE(parts == expected);
200
201   expected.clear(); parts.clear();
202   expected.push_back("a"); expected.push_back(",b,c");
203   StringRef("a,,b,c").split(parts, ",", 1, false);
204   EXPECT_TRUE(parts == expected);
205
206   expected.clear(); parts.clear();
207   expected.push_back("a"); expected.push_back(""); expected.push_back("b,c");
208   StringRef("a,,b,c").split(parts, ",", 2, true);
209   EXPECT_TRUE(parts == expected);
210
211   expected.clear(); parts.clear();
212   expected.push_back("a"); expected.push_back("b,c");
213   StringRef("a,,b,c").split(parts, ",", 2, false);
214   EXPECT_TRUE(parts == expected);
215
216   expected.clear(); parts.clear();
217   expected.push_back("a"); expected.push_back(""); expected.push_back("b");
218   expected.push_back("c");
219   StringRef("a,,b,c").split(parts, ",", 3, true);
220   EXPECT_TRUE(parts == expected);
221
222   expected.clear(); parts.clear();
223   expected.push_back("a"); expected.push_back("b"); expected.push_back("c");
224   StringRef("a,,b,c").split(parts, ",", 3, false);
225   EXPECT_TRUE(parts == expected);
226 }
227
228 TEST(StringRefTest, Trim) {
229   StringRef Str0("hello");
230   StringRef Str1(" hello ");
231   StringRef Str2("  hello  ");
232
233   EXPECT_EQ(StringRef("hello"), Str0.rtrim());
234   EXPECT_EQ(StringRef(" hello"), Str1.rtrim());
235   EXPECT_EQ(StringRef("  hello"), Str2.rtrim());
236   EXPECT_EQ(StringRef("hello"), Str0.ltrim());
237   EXPECT_EQ(StringRef("hello "), Str1.ltrim());
238   EXPECT_EQ(StringRef("hello  "), Str2.ltrim());
239   EXPECT_EQ(StringRef("hello"), Str0.trim());
240   EXPECT_EQ(StringRef("hello"), Str1.trim());
241   EXPECT_EQ(StringRef("hello"), Str2.trim());
242
243   EXPECT_EQ(StringRef("ello"), Str0.trim("hhhhhhhhhhh"));
244
245   EXPECT_EQ(StringRef(""), StringRef("").trim());
246   EXPECT_EQ(StringRef(""), StringRef(" ").trim());
247   EXPECT_EQ(StringRef("\0", 1), StringRef(" \0 ", 3).trim());
248   EXPECT_EQ(StringRef("\0\0", 2), StringRef("\0\0", 2).trim());
249   EXPECT_EQ(StringRef("x"), StringRef("\0\0x\0\0", 5).trim(StringRef("\0", 1)));
250 }
251
252 TEST(StringRefTest, StartsWith) {
253   StringRef Str("hello");
254   EXPECT_TRUE(Str.startswith(""));
255   EXPECT_TRUE(Str.startswith("he"));
256   EXPECT_FALSE(Str.startswith("helloworld"));
257   EXPECT_FALSE(Str.startswith("hi"));
258 }
259
260 TEST(StringRefTest, StartsWithLower) {
261   StringRef Str("heLLo");
262   EXPECT_TRUE(Str.startswith_lower(""));
263   EXPECT_TRUE(Str.startswith_lower("he"));
264   EXPECT_TRUE(Str.startswith_lower("hell"));
265   EXPECT_TRUE(Str.startswith_lower("HELlo"));
266   EXPECT_FALSE(Str.startswith_lower("helloworld"));
267   EXPECT_FALSE(Str.startswith_lower("hi"));
268 }
269
270 TEST(StringRefTest, EndsWith) {
271   StringRef Str("hello");
272   EXPECT_TRUE(Str.endswith(""));
273   EXPECT_TRUE(Str.endswith("lo"));
274   EXPECT_FALSE(Str.endswith("helloworld"));
275   EXPECT_FALSE(Str.endswith("worldhello"));
276   EXPECT_FALSE(Str.endswith("so"));
277 }
278
279 TEST(StringRefTest, EndsWithLower) {
280   StringRef Str("heLLo");
281   EXPECT_TRUE(Str.endswith_lower(""));
282   EXPECT_TRUE(Str.endswith_lower("lo"));
283   EXPECT_TRUE(Str.endswith_lower("LO"));
284   EXPECT_TRUE(Str.endswith_lower("ELlo"));
285   EXPECT_FALSE(Str.endswith_lower("helloworld"));
286   EXPECT_FALSE(Str.endswith_lower("hi"));
287 }
288
289 TEST(StringRefTest, Find) {
290   StringRef Str("hello");
291   EXPECT_EQ(2U, Str.find('l'));
292   EXPECT_EQ(StringRef::npos, Str.find('z'));
293   EXPECT_EQ(StringRef::npos, Str.find("helloworld"));
294   EXPECT_EQ(0U, Str.find("hello"));
295   EXPECT_EQ(1U, Str.find("ello"));
296   EXPECT_EQ(StringRef::npos, Str.find("zz"));
297   EXPECT_EQ(2U, Str.find("ll", 2));
298   EXPECT_EQ(StringRef::npos, Str.find("ll", 3));
299   EXPECT_EQ(0U, Str.find(""));
300   StringRef LongStr("hellx xello hell ello world foo bar hello");
301   EXPECT_EQ(36U, LongStr.find("hello"));
302   EXPECT_EQ(28U, LongStr.find("foo"));
303   EXPECT_EQ(12U, LongStr.find("hell", 2));
304   EXPECT_EQ(0U, LongStr.find(""));
305
306   EXPECT_EQ(3U, Str.rfind('l'));
307   EXPECT_EQ(StringRef::npos, Str.rfind('z'));
308   EXPECT_EQ(StringRef::npos, Str.rfind("helloworld"));
309   EXPECT_EQ(0U, Str.rfind("hello"));
310   EXPECT_EQ(1U, Str.rfind("ello"));
311   EXPECT_EQ(StringRef::npos, Str.rfind("zz"));
312
313   EXPECT_EQ(2U, Str.find_first_of('l'));
314   EXPECT_EQ(1U, Str.find_first_of("el"));
315   EXPECT_EQ(StringRef::npos, Str.find_first_of("xyz"));
316
317   EXPECT_EQ(1U, Str.find_first_not_of('h'));
318   EXPECT_EQ(4U, Str.find_first_not_of("hel"));
319   EXPECT_EQ(StringRef::npos, Str.find_first_not_of("hello"));
320
321   EXPECT_EQ(3U, Str.find_last_not_of('o'));
322   EXPECT_EQ(1U, Str.find_last_not_of("lo"));
323   EXPECT_EQ(StringRef::npos, Str.find_last_not_of("helo"));
324 }
325
326 TEST(StringRefTest, Count) {
327   StringRef Str("hello");
328   EXPECT_EQ(2U, Str.count('l'));
329   EXPECT_EQ(1U, Str.count('o'));
330   EXPECT_EQ(0U, Str.count('z'));
331   EXPECT_EQ(0U, Str.count("helloworld"));
332   EXPECT_EQ(1U, Str.count("hello"));
333   EXPECT_EQ(1U, Str.count("ello"));
334   EXPECT_EQ(0U, Str.count("zz"));
335 }
336
337 TEST(StringRefTest, EditDistance) {
338   StringRef Str("hello");
339   EXPECT_EQ(2U, Str.edit_distance("hill"));
340 }
341
342 TEST(StringRefTest, Misc) {
343   std::string Storage;
344   raw_string_ostream OS(Storage);
345   OS << StringRef("hello");
346   EXPECT_EQ("hello", OS.str());
347 }
348
349 TEST(StringRefTest, Hashing) {
350   EXPECT_EQ(hash_value(std::string()), hash_value(StringRef()));
351   EXPECT_EQ(hash_value(std::string()), hash_value(StringRef("")));
352   std::string S = "hello world";
353   hash_code H = hash_value(S);
354   EXPECT_EQ(H, hash_value(StringRef("hello world")));
355   EXPECT_EQ(H, hash_value(StringRef(S)));
356   EXPECT_NE(H, hash_value(StringRef("hello worl")));
357   EXPECT_EQ(hash_value(std::string("hello worl")),
358             hash_value(StringRef("hello worl")));
359   EXPECT_NE(H, hash_value(StringRef("hello world ")));
360   EXPECT_EQ(hash_value(std::string("hello world ")),
361             hash_value(StringRef("hello world ")));
362   EXPECT_EQ(H, hash_value(StringRef("hello world\0")));
363   EXPECT_NE(hash_value(std::string("ello worl")),
364             hash_value(StringRef("hello world").slice(1, -1)));
365 }
366
367 struct UnsignedPair {
368   const char *Str;
369   uint64_t Expected;
370 } Unsigned[] =
371   { {"0", 0}
372   , {"255", 255}
373   , {"256", 256}
374   , {"65535", 65535}
375   , {"65536", 65536}
376   , {"4294967295", 4294967295ULL}
377   , {"4294967296", 4294967296ULL}
378   , {"18446744073709551615", 18446744073709551615ULL}
379   , {"042", 34}
380   , {"0x42", 66}
381   , {"0b101010", 42}
382   };
383
384 struct SignedPair {
385   const char *Str;
386   int64_t Expected;
387 } Signed[] =
388   { {"0", 0}
389   , {"-0", 0}
390   , {"127", 127}
391   , {"128", 128}
392   , {"-128", -128}
393   , {"-129", -129}
394   , {"32767", 32767}
395   , {"32768", 32768}
396   , {"-32768", -32768}
397   , {"-32769", -32769}
398   , {"2147483647", 2147483647LL}
399   , {"2147483648", 2147483648LL}
400   , {"-2147483648", -2147483648LL}
401   , {"-2147483649", -2147483649LL}
402   , {"-9223372036854775808", -(9223372036854775807LL) - 1}
403   , {"042", 34}
404   , {"0x42", 66}
405   , {"0b101010", 42}
406   , {"-042", -34}
407   , {"-0x42", -66}
408   , {"-0b101010", -42}
409   };
410
411 TEST(StringRefTest, getAsInteger) {
412   uint8_t U8;
413   uint16_t U16;
414   uint32_t U32;
415   uint64_t U64;
416
417   for (size_t i = 0; i < array_lengthof(Unsigned); ++i) {
418     bool U8Success = StringRef(Unsigned[i].Str).getAsInteger(0, U8);
419     if (static_cast<uint8_t>(Unsigned[i].Expected) == Unsigned[i].Expected) {
420       ASSERT_FALSE(U8Success);
421       EXPECT_EQ(U8, Unsigned[i].Expected);
422     } else {
423       ASSERT_TRUE(U8Success);
424     }
425     bool U16Success = StringRef(Unsigned[i].Str).getAsInteger(0, U16);
426     if (static_cast<uint16_t>(Unsigned[i].Expected) == Unsigned[i].Expected) {
427       ASSERT_FALSE(U16Success);
428       EXPECT_EQ(U16, Unsigned[i].Expected);
429     } else {
430       ASSERT_TRUE(U16Success);
431     }
432     bool U32Success = StringRef(Unsigned[i].Str).getAsInteger(0, U32);
433     if (static_cast<uint32_t>(Unsigned[i].Expected) == Unsigned[i].Expected) {
434       ASSERT_FALSE(U32Success);
435       EXPECT_EQ(U32, Unsigned[i].Expected);
436     } else {
437       ASSERT_TRUE(U32Success);
438     }
439     bool U64Success = StringRef(Unsigned[i].Str).getAsInteger(0, U64);
440     if (static_cast<uint64_t>(Unsigned[i].Expected) == Unsigned[i].Expected) {
441       ASSERT_FALSE(U64Success);
442       EXPECT_EQ(U64, Unsigned[i].Expected);
443     } else {
444       ASSERT_TRUE(U64Success);
445     }
446   }
447
448   int8_t S8;
449   int16_t S16;
450   int32_t S32;
451   int64_t S64;
452
453   for (size_t i = 0; i < array_lengthof(Signed); ++i) {
454     bool S8Success = StringRef(Signed[i].Str).getAsInteger(0, S8);
455     if (static_cast<int8_t>(Signed[i].Expected) == Signed[i].Expected) {
456       ASSERT_FALSE(S8Success);
457       EXPECT_EQ(S8, Signed[i].Expected);
458     } else {
459       ASSERT_TRUE(S8Success);
460     }
461     bool S16Success = StringRef(Signed[i].Str).getAsInteger(0, S16);
462     if (static_cast<int16_t>(Signed[i].Expected) == Signed[i].Expected) {
463       ASSERT_FALSE(S16Success);
464       EXPECT_EQ(S16, Signed[i].Expected);
465     } else {
466       ASSERT_TRUE(S16Success);
467     }
468     bool S32Success = StringRef(Signed[i].Str).getAsInteger(0, S32);
469     if (static_cast<int32_t>(Signed[i].Expected) == Signed[i].Expected) {
470       ASSERT_FALSE(S32Success);
471       EXPECT_EQ(S32, Signed[i].Expected);
472     } else {
473       ASSERT_TRUE(S32Success);
474     }
475     bool S64Success = StringRef(Signed[i].Str).getAsInteger(0, S64);
476     if (static_cast<int64_t>(Signed[i].Expected) == Signed[i].Expected) {
477       ASSERT_FALSE(S64Success);
478       EXPECT_EQ(S64, Signed[i].Expected);
479     } else {
480       ASSERT_TRUE(S64Success);
481     }
482   }
483 }
484
485
486 static const char* BadStrings[] = {
487     "18446744073709551617"  // value just over max
488   , "123456789012345678901" // value way too large
489   , "4t23v"                 // illegal decimal characters
490   , "0x123W56"              // illegal hex characters
491   , "0b2"                   // illegal bin characters
492   , "08"                    // illegal oct characters
493   , "0o8"                   // illegal oct characters
494   , "-123"                  // negative unsigned value
495 };
496
497
498 TEST(StringRefTest, getAsUnsignedIntegerBadStrings) {
499   unsigned long long U64;
500   for (size_t i = 0; i < array_lengthof(BadStrings); ++i) {
501     bool IsBadNumber = StringRef(BadStrings[i]).getAsInteger(0, U64);
502     ASSERT_TRUE(IsBadNumber);
503   }
504 }
505
506 static const char *join_input[] = { "a", "b", "c" };
507 static const char join_result1[] = "a";
508 static const char join_result2[] = "a:b:c";
509 static const char join_result3[] = "a::b::c";
510
511 TEST(StringRefTest, joinStrings) {
512   std::vector<StringRef> v1;
513   std::vector<std::string> v2;
514   for (size_t i = 0; i < array_lengthof(join_input); ++i) {
515     v1.push_back(join_input[i]);
516     v2.push_back(join_input[i]);
517   }
518
519   bool v1_join1 = join(v1.begin(), v1.begin() + 1, ":") == join_result1;
520   EXPECT_TRUE(v1_join1);
521   bool v1_join2 = join(v1.begin(), v1.end(), ":") == join_result2;
522   EXPECT_TRUE(v1_join2);
523   bool v1_join3 = join(v1.begin(), v1.end(), "::") == join_result3;
524   EXPECT_TRUE(v1_join3);
525
526   bool v2_join1 = join(v2.begin(), v2.begin() + 1, ":") == join_result1;
527   EXPECT_TRUE(v2_join1);
528   bool v2_join2 = join(v2.begin(), v2.end(), ":") == join_result2;
529   EXPECT_TRUE(v2_join2);
530   bool v2_join3 = join(v2.begin(), v2.end(), "::") == join_result3;
531   EXPECT_TRUE(v2_join3);
532 }
533
534 } // end anonymous namespace