Skip to content

Commit f2180af

Browse files
committed
Add examples directory and enable builds in CI
Created a directory of . In there I have a simple function to add these source files. It creates and executable and links to the library. Building of the examples was enabled in CI and then execute them to compare to the example output for verification they work.
1 parent 2c8acdb commit f2180af

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

.github/workflows/pipeline.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,14 @@ jobs:
229229
- name: Run build
230230
run: cmake --build build
231231

232+
test-examples:
233+
runs-on: ubuntu-latest
234+
235+
steps:
236+
- uses: actions/checkout@v4
237+
238+
- name: Make build directory
239+
run: cmake -Bbuild -DDBC_BUILD_EXAMPLES=ON -H$GITHUB_WORKSPACE
240+
241+
- name: Run example tests
242+
run: cmake --build build --target test-examples

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ option(DBC_ENABLE_TESTS "Enable Unittests" ON)
88
option(DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF)
99
option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF)
1010
option(DBC_GENERATE_SINGLE_HEADER "This will run the generator for the single header file version. Default is OFF since we make a static build. Requires cargo installed." OFF)
11+
option(DBC_BUILD_EXAMPLES "Build all the examples in the examples folder." OFF)
1112
# ---------------------- #
1213

1314
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -123,3 +124,5 @@ add_custom_target(clang-tidy-fix
123124
clang-tidy -fix-notes -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES}
124125
DEPENDS ${SOURCE_FILES} ${HEADER_FILES}
125126
)
127+
128+
add_subdirectory(examples)

src/message.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const std::string& Message::name() const {
111111
void Message::add_value_description(const std::string& signal_name, const std::vector<Signal::ValueDescription>& value_descriptor) {
112112
for (auto& signal : m_signals) {
113113
if (signal.name == signal_name) {
114-
signal.value_descriptions = value_descriptor;
114+
signal.value_descriptions = value_descriptor;
115115
return;
116116
}
117117
}
@@ -120,7 +120,7 @@ void Message::add_value_description(const std::string& signal_name, const std::v
120120
std::ostream& operator<<(std::ostream& out, const Message& msg) {
121121
out << "Message: {id: " << msg.id() << ", ";
122122
out << "name: " << msg.m_name << ", ";
123-
out << "size: " << msg.m_size << ", ";
123+
out << "size: " << std::to_string(msg.m_size) << ", ";
124124
out << "node: " << msg.m_node << "}";
125125
return out;
126126
}

src/signal.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ bool Signal::operator<(const Signal& rhs) const {
4242
}
4343

4444
std::ostream& operator<<(std::ostream& out, const Signal& sig) {
45-
out << "Signal {name: " << sig.name << ", ";
45+
out << "Signal: {name: " << sig.name << ", ";
4646
out << "Multiplexed: " << (sig.is_multiplexed ? "True" : "False") << ", ";
47-
out << "Start bit: " << sig.start_bit << ", ";
48-
out << "Size: " << sig.size << ", ";
47+
out << "Start bit: " << std::to_string(sig.start_bit) << ", ";
48+
out << "Size: " << std::to_string(sig.size) << ", ";
4949
out << "Endianness: " << (sig.is_bigendian ? "Big endian" : "Little endian") << ", ";
5050
out << "Value Type: " << (sig.is_signed ? "Signed" : "Unsigned") << ", ";
51-
out << "Min: " << sig.min << ", Max: " << sig.max << ", ";
51+
out << "Min: " << std::to_string(sig.min) << ", Max: " << std::to_string(sig.max) << ", ";
5252
out << "Unit: (" << sig.unit << "), ";
5353
out << "receivers: ";
5454
for (const auto& reciever : sig.receivers) {

0 commit comments

Comments
 (0)