Skip to content
Open
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
29 changes: 17 additions & 12 deletions score/component_example/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
24 changes: 24 additions & 0 deletions score/component_example/src/component_example.cpp
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions score/component_example/src/component_example.hpp
Original file line number Diff line number Diff line change
@@ -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 <string>

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_
28 changes: 28 additions & 0 deletions score/component_example/tests/component_example_test.cpp
Original file line number Diff line number Diff line change
@@ -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 <gtest/gtest.h>
#include <string>

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
Loading