From b24793bce6f4052a4e61198243b87e57aa388b12 Mon Sep 17 00:00:00 2001 From: Moritz Martinius Date: Sun, 19 Oct 2025 14:47:52 +0200 Subject: [PATCH] Fix minor issues and create a .clangd config for different builddirs --- .clangd | 11 +++++++++++ .vscode/c_cpp_properties.json | 7 ++++--- .vscode/settings.json | 1 - tests/label_test/label_test.cpp | 2 +- tests/monochrome_test/monochrome_test.cpp | 3 --- tests/p700_printer_test/p700_printer_test.cpp | 6 +++--- tests/printer_service_test/printer_service_test.cpp | 2 -- 7 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 .clangd diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..fd3cac7 --- /dev/null +++ b/.clangd @@ -0,0 +1,11 @@ +--- +If: + PathMatch: tests/.* +CompileFlags: + CompilationDatabase: builddir-debug/ + +--- +If: + PathMatch: src/.* +CompileFlags: + CompilationDatabase: builddir/ diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index eb6a4b8..103ccfd 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -5,11 +5,12 @@ "compilerPath": "/usr/bin/clang", "cStandard": "c11", "cppStandard": "c++20", - "compileCommands": "${workspaceFolder}/builddir/compile_commands.json", "browse": { - "path": ["${workspaceFolder}"] + "path": [ + "${workspaceFolder}" + ] } } ], "version": 4 -} +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index bf6734c..7781d85 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,6 @@ { "clangd.arguments": [ "-background-index", - "-compile-commands-dir=builddir/" ], "editor.formatOnType": false, "editor.formatOnSave": true, diff --git a/tests/label_test/label_test.cpp b/tests/label_test/label_test.cpp index e0a3ea1..e678a3d 100644 --- a/tests/label_test/label_test.cpp +++ b/tests/label_test/label_test.cpp @@ -25,8 +25,8 @@ #include #include -#include "../../tests/mocks/MockCairoWrapper.hpp" #include "graphics/interface/ILabel.hpp" +#include "mocks/MockCairoWrapper.hpp" using ::testing::_; using ::testing::DoAll; diff --git a/tests/monochrome_test/monochrome_test.cpp b/tests/monochrome_test/monochrome_test.cpp index 8d5ce0b..29ec73c 100644 --- a/tests/monochrome_test/monochrome_test.cpp +++ b/tests/monochrome_test/monochrome_test.cpp @@ -57,9 +57,6 @@ TEST(basic_test, Monochrome_convertWithCustomThreshhold_yieldsMonochromeRespecti } TEST(basic_test, Monochrome_convertNonAlignedPixels_spillsOverIntoNewByte) { - // TODO: We need to find to access the vector without the possiblity of out-of-bounds access - // Ideas: constexpr? compile time check? - GTEST_SKIP() << "Skipping this test, as ASAN will halt as this is an out-of-bounds access"; const std::vector pixels( {0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF}); diff --git a/tests/p700_printer_test/p700_printer_test.cpp b/tests/p700_printer_test/p700_printer_test.cpp index 003de02..d310af1 100644 --- a/tests/p700_printer_test/p700_printer_test.cpp +++ b/tests/p700_printer_test/p700_printer_test.cpp @@ -22,9 +22,9 @@ #include -#include "../../tests/mocks/MockUsbDevice.hpp" #include "graphics/Bitmap.hpp" #include "graphics/Monochrome.hpp" +#include "mocks/MockUsbDevice.hpp" #include "printers/P700Printer.hpp" using ::testing::_; @@ -39,8 +39,8 @@ namespace ptprnt::printer { class P700PrinterTest : public ::testing::Test { protected: void SetUp() override { - printer = std::make_unique(); - mockUsbDev = std::make_shared>(); + printer = std::make_unique(); + mockUsbDev = std::make_shared>(); // Default mock behaviors ON_CALL(*mockUsbDev, open()).WillByDefault(Return(true)); diff --git a/tests/printer_service_test/printer_service_test.cpp b/tests/printer_service_test/printer_service_test.cpp index b8d0332..922adb6 100644 --- a/tests/printer_service_test/printer_service_test.cpp +++ b/tests/printer_service_test/printer_service_test.cpp @@ -23,8 +23,6 @@ #include #include -#include "../../tests/mocks/MockPrinterDriver.hpp" -#include "../../tests/mocks/MockUsbDevice.hpp" #include "core/PrinterDriverFactory.hpp" #include "core/PrinterService.hpp"