// Copyright © Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT #include #include #include #include #include using hipdnn_test_sdk::utilities::StreamVec; class TestVectorLoggingUtils : public ::testing::Test { protected: void SetUp() override { // Setup if needed } }; TEST_F(TestVectorLoggingUtils, FormatsEmptyVector) { const std::vector emptyVec; std::ostringstream oss; oss << StreamVec(emptyVec); EXPECT_EQ(oss.str(), "[]"); } TEST_F(TestVectorLoggingUtils, FormatsSingleElement) { const std::vector singleVec = {42}; std::ostringstream oss; oss << StreamVec(singleVec); EXPECT_EQ(oss.str(), "[42]"); } TEST_F(TestVectorLoggingUtils, FormatsMultipleElements) { const std::vector multiVec = {1, 2, 3, 4, 5}; std::ostringstream oss; oss << StreamVec(multiVec); EXPECT_EQ(oss.str(), "[1, 2, 3, 4, 5]"); } TEST_F(TestVectorLoggingUtils, FormatsNegativeNumbers) { const std::vector negativeVec = {-100, -50, 0, 50, 100}; std::ostringstream oss; oss << StreamVec(negativeVec); EXPECT_EQ(oss.str(), "[-100, -50, 0, 50, 100]"); } TEST_F(TestVectorLoggingUtils, FormatsLargeNumbers) { const std::vector largeVec = {1000000000000, 2000000000000, 3000000000000}; std::ostringstream oss; oss << StreamVec(largeVec); EXPECT_EQ(oss.str(), "[1000000000000, 2000000000000, 3000000000000]"); } TEST_F(TestVectorLoggingUtils, FormatsMinMaxValues) { const std::vector extremeVec = {std::numeric_limits::min(), std::numeric_limits::max()}; std::ostringstream oss; oss << StreamVec(extremeVec); std::ostringstream expected; expected << "[" << std::numeric_limits::min() << ", " << std::numeric_limits::max() << "]"; EXPECT_EQ(oss.str(), expected.str()); } TEST_F(TestVectorLoggingUtils, WorksWithFormatStrings) { const std::vector vec = {10, 20, 30}; std::ostringstream oss; oss << "Vector contents: " << StreamVec(vec); EXPECT_EQ(oss.str(), "Vector contents: [10, 20, 30]"); } TEST_F(TestVectorLoggingUtils, FormatsMultipleVectorsInSameString) { const std::vector vec1 = {1, 2}; const std::vector vec2 = {3, 4, 5}; std::ostringstream oss; oss << "First: " << StreamVec(vec1) << ", Second: " << StreamVec(vec2); EXPECT_EQ(oss.str(), "First: [1, 2], Second: [3, 4, 5]"); } TEST_F(TestVectorLoggingUtils, FormatsZeroValues) { const std::vector zeroVec = {0, 0, 0}; std::ostringstream oss; oss << StreamVec(zeroVec); EXPECT_EQ(oss.str(), "[0, 0, 0]"); } TEST_F(TestVectorLoggingUtils, PreservesElementOrder) { const std::vector orderedVec = {5, 3, 8, 1, 9}; std::ostringstream oss; oss << StreamVec(orderedVec); EXPECT_EQ(oss.str(), "[5, 3, 8, 1, 9]"); } TEST_F(TestVectorLoggingUtils, HandlesAlternatingSignValues) { const std::vector altVec = {1, -1, 2, -2, 3, -3}; std::ostringstream oss; oss << StreamVec(altVec); EXPECT_EQ(oss.str(), "[1, -1, 2, -2, 3, -3]"); }