From db898499efe33e9a04ff7c3321991d5176433207 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Sat, 9 Nov 2024 23:54:03 -0500 Subject: [PATCH] Add unit test --- cpp/tests/test_defaults.cpp | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 cpp/tests/test_defaults.cpp diff --git a/cpp/tests/test_defaults.cpp b/cpp/tests/test_defaults.cpp new file mode 100644 index 0000000000..8c6a91ff89 --- /dev/null +++ b/cpp/tests/test_defaults.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include + +TEST(Defaults, parse_compat_mode_str) +{ + { + std::vector inputs{"ON", "on", "On"}; + for (const auto& input : inputs) { + EXPECT_EQ(kvikio::detail::parse_compat_mode_str(input), kvikio::detail::CompatMode::ON); + } + } + + { + std::vector inputs{"OFF", "off", "oFf"}; + for (const auto& input : inputs) { + EXPECT_EQ(kvikio::detail::parse_compat_mode_str(input), kvikio::detail::CompatMode::OFF); + } + } + + { + std::vector inputs{"AUTO", "auto", "aUtO"}; + for (const auto& input : inputs) { + EXPECT_EQ(kvikio::detail::parse_compat_mode_str(input), kvikio::detail::CompatMode::AUTO); + } + } + + { + std::vector inputs{"", "invalidOption"}; + for (const auto& input : inputs) { + EXPECT_THROW(kvikio::detail::parse_compat_mode_str(input), std::invalid_argument); + } + } +} \ No newline at end of file