1 //===- unittests/ADT/Interleave.cpp - Interleave unit tests ---------------===//
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
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"
19 TEST(InterleaveTest
, Interleave
) {
21 raw_string_ostream
OS(Str
);
23 // Check that interleave works on a SmallVector.
24 SmallVector
<const char *> Doodles
= {"golden", "berna", "labra"};
26 Doodles
, OS
, [&](const char *Name
) { OS
<< Name
<< "doodle"; }, ", ");
28 EXPECT_EQ(Str
, "goldendoodle, bernadoodle, labradoodle");
31 TEST(InterleaveTest
, InterleaveComma
) {
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