Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions score/mw/com/impl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,15 @@ cc_unit_test(
],
)

cc_unit_test(
name = "method_type_test",
srcs = ["method_type_test.cpp"],
features = COMPILER_WARNING_FEATURES,
deps = [
":method_type",
],
)

cc_unit_test(
name = "sample_reference_tracker_test",
srcs = ["sample_reference_tracker_test.cpp"],
Expand Down
65 changes: 65 additions & 0 deletions score/mw/com/impl/method_type_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/********************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#include "score/mw/com/impl/method_type.h"

#include <gtest/gtest.h>

namespace score::mw::com::impl
{
namespace
{

TEST(MethodTypeToStringTest, ReturnsMethodForKMethod)
{
// Given a MethodType of kMethod
// When converting to string
// Then the result is "Method"
EXPECT_EQ(to_string(MethodType::kMethod), "Method");
}

TEST(MethodTypeToStringTest, ReturnsGetForKGet)
{
// Given a MethodType of kGet
// When converting to string
// Then the result is "Get"
EXPECT_EQ(to_string(MethodType::kGet), "Get");
}

TEST(MethodTypeToStringTest, ReturnsSetForKSet)
{
// Given a MethodType of kSet
// When converting to string
// Then the result is "Set"
EXPECT_EQ(to_string(MethodType::kSet), "Set");
}

TEST(MethodTypeToStringTest, ReturnsUnknownForKUnknown)
{
// Given a MethodType of kUnknown
// When converting to string
// Then the result is "Unknown"
EXPECT_EQ(to_string(MethodType::kUnknown), "Unknown");
}

TEST(MethodTypeToStringTest, ReturnsInvalidForOutOfRangeValue)
{
// Given an out-of-range MethodType value
const auto invalid_value = static_cast<MethodType>(255);

// When converting to string
// Then the result is "Invalid"
EXPECT_EQ(to_string(invalid_value), "Invalid");
}

} // namespace
} // namespace score::mw::com::impl
Loading