Files
TheRock/rocm-libraries/projects/hipdnn/test_sdk/tests/utilities/TestVectorLoggingUtils.cpp
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

113 lines
3.2 KiB
C++

// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <hipdnn_test_sdk/utilities/VectorLoggingUtils.hpp>
#include <limits>
#include <sstream>
#include <vector>
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<int64_t> emptyVec;
std::ostringstream oss;
oss << StreamVec(emptyVec);
EXPECT_EQ(oss.str(), "[]");
}
TEST_F(TestVectorLoggingUtils, FormatsSingleElement)
{
const std::vector<int64_t> singleVec = {42};
std::ostringstream oss;
oss << StreamVec(singleVec);
EXPECT_EQ(oss.str(), "[42]");
}
TEST_F(TestVectorLoggingUtils, FormatsMultipleElements)
{
const std::vector<int64_t> 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<int64_t> 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<int64_t> largeVec = {1000000000000, 2000000000000, 3000000000000};
std::ostringstream oss;
oss << StreamVec(largeVec);
EXPECT_EQ(oss.str(), "[1000000000000, 2000000000000, 3000000000000]");
}
TEST_F(TestVectorLoggingUtils, FormatsMinMaxValues)
{
const std::vector<int64_t> extremeVec
= {std::numeric_limits<int64_t>::min(), std::numeric_limits<int64_t>::max()};
std::ostringstream oss;
oss << StreamVec(extremeVec);
std::ostringstream expected;
expected << "[" << std::numeric_limits<int64_t>::min() << ", "
<< std::numeric_limits<int64_t>::max() << "]";
EXPECT_EQ(oss.str(), expected.str());
}
TEST_F(TestVectorLoggingUtils, WorksWithFormatStrings)
{
const std::vector<int64_t> 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<int64_t> vec1 = {1, 2};
const std::vector<int64_t> 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<int64_t> zeroVec = {0, 0, 0};
std::ostringstream oss;
oss << StreamVec(zeroVec);
EXPECT_EQ(oss.str(), "[0, 0, 0]");
}
TEST_F(TestVectorLoggingUtils, PreservesElementOrder)
{
const std::vector<int64_t> 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<int64_t> altVec = {1, -1, 2, -2, 3, -3};
std::ostringstream oss;
oss << StreamVec(altVec);
EXPECT_EQ(oss.str(), "[1, -1, 2, -2, 3, -3]");
}