diff --git a/score/component_example/BUILD b/score/component_example/BUILD index 15140558..2c96bbfa 100644 --- a/score/component_example/BUILD +++ b/score/component_example/BUILD @@ -13,22 +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", - scan_code = [ - ":all_sources", - ], source_dir = "docs", + 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..68cf9bf4 --- /dev/null +++ b/score/component_example/src/component_example.cpp @@ -0,0 +1,24 @@ +/******************************************************************************** + * 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 { + +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..d5937de1 --- /dev/null +++ b/score/component_example/src/component_example.hpp @@ -0,0 +1,27 @@ +/******************************************************************************** + * 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 { + +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