mirror-llvm-project/orc-rt/test/unit/StringExtrasTest.cpp
Jared Wyles 30a1b346f5
[orc-rt] Add StringExtras::join from llvm/adt and tests (#212179)
Tests are appropriate to the use cases that will follow in a PR to
follow.
2026-07-27 08:08:34 +00:00

36 lines
1.1 KiB
C++

//===- StringExtrasTest.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Tests for string utility APIs.
//
//===----------------------------------------------------------------------===//
#include "orc-rt/StringExtras.h"
#include "gtest/gtest.h"
using namespace orc_rt;
TEST(StringExtrasTest, JoinSingleString) { EXPECT_EQ(join({"x"}, "-"), "x"); }
TEST(StringExtrasTest, JoinMultipleString) {
EXPECT_EQ(join({"a", "b", "c"}, "-"), "a-b-c");
}
TEST(StringExtrasTest, JoinMantainsEmptyString) {
EXPECT_EQ(join({"a", "", "c"}, "-"), "a--c");
EXPECT_EQ(join({"", "b"}, "-"), "-b");
EXPECT_EQ(join({"a", ""}, "-"), "a-");
}
TEST(StringExtrasTest, JoinEmptySeparator) {
EXPECT_EQ(join({"a", "b", "c"}, ""), "abc");
}
TEST(StringExtrasTest, JoinMultiSeparator) {
EXPECT_EQ(join({"a", "b", "c"}, ", "), "a, b, c");
}