[gcov] Bump default version to 11.1
[llvm-project.git] / llvm / unittests / ADT / Interleave.cpp
blob6c1be881497d10c9c0e617bd318976aa93549901
1 //===- unittests/ADT/Interleave.cpp - Interleave unit tests ---------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ADT/STLExtras.h"
10 #include "llvm/ADT/SmallVector.h"
11 #include "llvm/Support/raw_ostream.h"
13 #include "gtest/gtest.h"
15 using namespace llvm;
17 namespace {
19 TEST(InterleaveTest, Interleave) {
20 std::string Str;
21 raw_string_ostream OS(Str);
23 // Check that interleave works on a SmallVector.
24 SmallVector<const char *> Doodles = {"golden", "berna", "labra"};
25 interleave(
26 Doodles, OS, [&](const char *Name) { OS << Name << "doodle"; }, ", ");
28 EXPECT_EQ(Str, "goldendoodle, bernadoodle, labradoodle");
31 TEST(InterleaveTest, InterleaveComma) {
32 std::string Str;
33 raw_string_ostream OS(Str);
35 // Check that interleaveComma uses ADL to find begin/end on an array.
36 const StringRef LongDogs[] = {"dachshund", "doxie", "dackel", "teckel"};
37 interleaveComma(LongDogs, OS);
39 EXPECT_EQ(Str, "dachshund, doxie, dackel, teckel");
42 } // anonymous namespace