From 8fbec4b386aefa6e3a42bc1b0f3871f70d8baa43 Mon Sep 17 00:00:00 2001 From: Naveena Panne Date: Thu, 3 Sep 2026 14:31:23 +0530 Subject: [PATCH 1/3] Added code and test for example component --- score/component_example/BUILD | 21 ++++++++++---- .../src/component_example.cpp | 25 +++++++++++++++++ .../src/component_example.hpp | 28 +++++++++++++++++++ .../tests/component_example_test.cpp | 28 +++++++++++++++++++ 4 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 score/component_example/src/component_example.cpp create mode 100644 score/component_example/src/component_example.hpp create mode 100644 score/component_example/tests/component_example_test.cpp diff --git a/score/component_example/BUILD b/score/component_example/BUILD index 3409fd0f..2c96bbfa 100644 --- a/score/component_example/BUILD +++ b/score/component_example/BUILD @@ -13,16 +13,27 @@ load("@score_docs_as_code//:docs.bzl", "docs_bundle") -filegroup( - name = "all_sources", - srcs = glob(["src/**/*.cpp", "src/**/*.hpp"], allow_empty = True), +cc_library( + name = "component_example", + srcs = ["src/component_example.cpp"], + hdrs = ["src/component_example.hpp"], + visibility = ["//visibility:public"], +) + +cc_test( + name = "component_example_test", + srcs = ["tests/component_example_test.cpp"], + deps = [ + ":component_example", + "@googletest//:gtest_main", + ], ) docs_bundle( name = "docs", source_dir = "docs", - scan_code = [ - ":all_sources", + code_targets = [ + ":component_example", ], visibility = ["//visibility:public"], ) diff --git a/score/component_example/src/component_example.cpp b/score/component_example/src/component_example.cpp new file mode 100644 index 00000000..5bae582c --- /dev/null +++ b/score/component_example/src/component_example.cpp @@ -0,0 +1,25 @@ +/******************************************************************************** + * 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/component_example/src/component_example.hpp" + +namespace score { +namespace component_example { + +// req-traceability: comp_req__component_example__hello_message +std::string make_hello_message(const std::string& name) { + return "Hello, " + name + "!"; +} + +} // namespace component_example +} // namespace score diff --git a/score/component_example/src/component_example.hpp b/score/component_example/src/component_example.hpp new file mode 100644 index 00000000..f815cbf3 --- /dev/null +++ b/score/component_example/src/component_example.hpp @@ -0,0 +1,28 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + +#ifndef SCORE_COMPONENT_EXAMPLE_COMPONENT_EXAMPLE_HPP_ +#define SCORE_COMPONENT_EXAMPLE_COMPONENT_EXAMPLE_HPP_ + +#include + +namespace score { +namespace component_example { + +// req-traceability: comp_req__component_example__hello_message +std::string make_hello_message(const std::string& name); + +} // namespace component_example +} // namespace score + +#endif // SCORE_COMPONENT_EXAMPLE_COMPONENT_EXAMPLE_HPP_ diff --git a/score/component_example/tests/component_example_test.cpp b/score/component_example/tests/component_example_test.cpp new file mode 100644 index 00000000..0d6c9bb2 --- /dev/null +++ b/score/component_example/tests/component_example_test.cpp @@ -0,0 +1,28 @@ +/******************************************************************************** + * 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/component_example/src/component_example.hpp" + +#include +#include + +namespace score { +namespace component_example { + +TEST(ComponentExampleTest, MakeHelloMessageReturnsExpectedGreeting) { + EXPECT_EQ(make_hello_message("World"), "Hello, World!"); + EXPECT_EQ(make_hello_message("SCORE"), "Hello, SCORE!"); +} + +} // namespace component_example +} // namespace score From bb28e398b4543ad98df5e772a83a1239e5bbeb51 Mon Sep 17 00:00:00 2001 From: Naveena Panne Date: Thu, 3 Sep 2026 15:16:04 +0530 Subject: [PATCH 2/3] Fix document CI failure Signed-off-by: Naveena Panne --- score/component_example/src/component_example.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/score/component_example/src/component_example.cpp b/score/component_example/src/component_example.cpp index 5bae582c..68cf9bf4 100644 --- a/score/component_example/src/component_example.cpp +++ b/score/component_example/src/component_example.cpp @@ -16,7 +16,6 @@ namespace score { namespace component_example { -// req-traceability: comp_req__component_example__hello_message std::string make_hello_message(const std::string& name) { return "Hello, " + name + "!"; } From 511c23dee74cb653d9aa0d33b2e7f3f5a4691e86 Mon Sep 17 00:00:00 2001 From: Naveena Panne Date: Thu, 3 Sep 2026 15:16:27 +0530 Subject: [PATCH 3/3] Fix document CI failure Signed-off-by: Naveena Panne --- score/component_example/src/component_example.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/score/component_example/src/component_example.hpp b/score/component_example/src/component_example.hpp index f815cbf3..d5937de1 100644 --- a/score/component_example/src/component_example.hpp +++ b/score/component_example/src/component_example.hpp @@ -19,7 +19,6 @@ namespace score { namespace component_example { -// req-traceability: comp_req__component_example__hello_message std::string make_hello_message(const std::string& name); } // namespace component_example