CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
// Copyright (c) Advanced Micro Devices, Inc.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include "common/join.hpp"
|
|
|
|
#include <gtest/gtest.h>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
using namespace rocprofsys::common;
|
|
|
|
TEST(join_test, basic_space_separated) { EXPECT_EQ(join(" ", "a", "b", "c"), "a b c"); }
|
|
|
|
TEST(join_test, custom_delimiter)
|
|
{
|
|
EXPECT_EQ(join(", ", "a", "b", "c"), "a, b, c");
|
|
EXPECT_EQ(join("/", "a", "b"), "a/b");
|
|
}
|
|
|
|
TEST(join_test, single_arg_has_no_delimiter) { EXPECT_EQ(join(", ", "only"), "only"); }
|
|
|
|
TEST(join_test, no_args_is_empty) { EXPECT_EQ(join(", "), ""); }
|
|
|
|
TEST(join_test, mixed_types)
|
|
{
|
|
EXPECT_EQ(join(" ", "count:", 42, "ratio:", 1.5), "count: 42 ratio: 1.5");
|
|
}
|
|
|
|
TEST(join_test, bool_renders_boolalpha)
|
|
{
|
|
EXPECT_EQ(join(" ", true, false), "true false");
|
|
}
|
|
|
|
TEST(join_test, std_string_argument)
|
|
{
|
|
EXPECT_EQ(join("-", std::string{ "x" }, std::string{ "y" }), "x-y");
|
|
}
|
|
|
|
TEST(join_test, unquoted_does_not_add_quotes) { EXPECT_EQ(join(", ", "a", "b"), "a, b"); }
|
|
|
|
TEST(join_test, empty_delimiter_concatenates)
|
|
{
|
|
EXPECT_EQ(join("", "a", "b", "c"), "abc");
|
|
}
|
|
|
|
TEST(join_test, quoted_wraps_string_args)
|
|
{
|
|
EXPECT_EQ(join_with_strings_quoted(", ", "a", 1, false), R"("a", 1, false)");
|
|
}
|
|
|
|
TEST(join_test, quoted_handles_null_char_ptr)
|
|
{
|
|
const char* null_str = nullptr;
|
|
EXPECT_EQ(join_with_strings_quoted(", ", null_str), R"("")");
|
|
}
|
|
|
|
TEST(join_test, quoted_quotes_std_string)
|
|
{
|
|
EXPECT_EQ(join_with_strings_quoted(" ", std::string{ "hi" }), R"("hi")");
|
|
}
|
|
|
|
TEST(join_test, quoted_quotes_string_view)
|
|
{
|
|
EXPECT_EQ(join_with_strings_quoted(" ", std::string_view{ "hi" }), R"("hi")");
|
|
}
|
|
|
|
TEST(join_test, quoted_bool_and_number_unquoted)
|
|
{
|
|
EXPECT_EQ(join_with_strings_quoted(" ", true, 7), "true 7");
|
|
}
|