|
| 1 | +// Copyright © Advanced Micro Devices, Inc., or its affiliates. |
| 2 | +// SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +#include <gtest/gtest.h> |
| 5 | + |
| 6 | +#include "harness/TomlGuards.hpp" |
| 7 | + |
| 8 | +using hipdnn_integration_tests::applyTomlToleranceOverride; |
| 9 | +using hipdnn_integration_tests::checkTomlSkip; |
| 10 | +using hipdnn_integration_tests::currentTestName; |
| 11 | + |
| 12 | +// NOLINTBEGIN(readability-identifier-naming) -- gtest macro-generated names |
| 13 | + |
| 14 | +// --------------------------------------------------------------------------- |
| 15 | +// currentTestName — pure gtest, no TestConfig dependency |
| 16 | +// --------------------------------------------------------------------------- |
| 17 | + |
| 18 | +TEST(TestTomlGuards, NameReturnsExpectedFormat) |
| 19 | +{ |
| 20 | + const auto name = currentTestName(); |
| 21 | + EXPECT_EQ(name, "TestTomlGuards.NameReturnsExpectedFormat"); |
| 22 | +} |
| 23 | + |
| 24 | +TEST(TestTomlGuards, NameContainsDot) |
| 25 | +{ |
| 26 | + const auto name = currentTestName(); |
| 27 | + EXPECT_NE(name.find('.'), std::string::npos); |
| 28 | +} |
| 29 | + |
| 30 | +// --------------------------------------------------------------------------- |
| 31 | +// checkTomlSkip / applyTomlToleranceOverride — empty-name early-return path |
| 32 | +// --------------------------------------------------------------------------- |
| 33 | + |
| 34 | +TEST(TestTomlGuards, CheckTomlSkipReturnsNulloptForEmptyName) |
| 35 | +{ |
| 36 | + EXPECT_EQ(checkTomlSkip(""), std::nullopt); |
| 37 | +} |
| 38 | + |
| 39 | +TEST(TestTomlGuards, ApplyTomlToleranceOverrideReturnsFalseForEmptyName) |
| 40 | +{ |
| 41 | + float atol = 1.0f; |
| 42 | + float rtol = 1.0f; |
| 43 | + EXPECT_FALSE(applyTomlToleranceOverride("", atol, rtol)); |
| 44 | + EXPECT_FLOAT_EQ(atol, 1.0f); |
| 45 | + EXPECT_FLOAT_EQ(rtol, 1.0f); |
| 46 | +} |
| 47 | + |
| 48 | +// --------------------------------------------------------------------------- |
| 49 | +// checkTomlSkip / applyTomlToleranceOverride — no TOML loaded |
| 50 | +// |
| 51 | +// TestConfig is initialized (by TestConfigInitialized in TestTestConfig.cpp, |
| 52 | +// same binary) without a settings file, so findSkipForTest / findToleranceOverride |
| 53 | +// return nullopt for any test name. |
| 54 | +// --------------------------------------------------------------------------- |
| 55 | + |
| 56 | +TEST(TestTomlGuards, CheckTomlSkipReturnsNulloptWhenNoSettings) |
| 57 | +{ |
| 58 | + EXPECT_EQ(checkTomlSkip("SomeTest.Name"), std::nullopt); |
| 59 | +} |
| 60 | + |
| 61 | +TEST(TestTomlGuards, ApplyTomlToleranceOverrideReturnsFalseWhenNoSettings) |
| 62 | +{ |
| 63 | + float atol = 1.0f; |
| 64 | + float rtol = 1.0f; |
| 65 | + EXPECT_FALSE(applyTomlToleranceOverride("SomeTest.Name", atol, rtol)); |
| 66 | + EXPECT_FLOAT_EQ(atol, 1.0f); |
| 67 | + EXPECT_FLOAT_EQ(rtol, 1.0f); |
| 68 | +} |
| 69 | + |
| 70 | +// NOLINTEND(readability-identifier-naming) |
0 commit comments