From 923c118c6da6ed5b53f63da63ee9a0f8b64b56f4 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Wed, 12 Aug 2026 23:02:40 +0200 Subject: [PATCH] test: the format and ASCII rules stop being a habit, and the stated sizes stop drifting libavr's guidance binds this repo too, and until now nothing here checked it - `ctest` runs `libavr_format_test()` over this tree's own sources now (rules 11 and 33), skipping rather than passing where clang-format is absent. It caught drift on its first run: a file written this week and edited after formatting. Where the README states a measured size, `libavr_size_claim_test()` holds it to the image and holds the image to the prose: advancing the library pin moved three of these across the fleet with nothing saying so, and re-recording one now requires the sentence that quotes it to move too. Co-Authored-By: Claude Opus 5 --- CMakeLists.txt | 2 ++ libavr | 2 +- test/CMakeLists.txt | 2 ++ test/consteval.cpp | 10 +++++----- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 227b970..d738c73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ add_library(ds3231 INTERFACE) target_include_directories(ds3231 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_link_libraries(ds3231 INTERFACE libavr) +include(${LIBAVR_ROOT}/cmake/checks.cmake) + if(PROJECT_IS_TOP_LEVEL) add_subdirectory(example) enable_testing() diff --git a/libavr b/libavr index 99434fb..1412b71 160000 --- a/libavr +++ b/libavr @@ -1 +1 @@ -Subproject commit 99434fb29af18f219ba9d24ba22d4d068e5790bb +Subproject commit 1412b7173b5c343d225cced990473f5e6b510c32 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0e0d797..373b8b6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,5 @@ +libavr_format_test() + # The battery is a compile: a static_assert that fails is the failure. It is a # target rather than only a ctest so a plain build catches a regression too. add_library(consteval_tests OBJECT consteval.cpp) diff --git a/test/consteval.cpp b/test/consteval.cpp index 0541b51..64b1f9a 100644 --- a/test/consteval.cpp +++ b/test/consteval.cpp @@ -37,11 +37,11 @@ static_assert(bcd_round_trips()); static_assert(hours_from_reg(to_bcd(0)) == 0); // 24-hour midnight static_assert(hours_from_reg(to_bcd(13)) == 13); // 24-hour afternoon static_assert(hours_from_reg(to_bcd(23)) == 23); -static_assert(hours_from_reg(0x40 | to_bcd(12)) == 0); // 12 AM -static_assert(hours_from_reg(0x40 | 0x20 | to_bcd(12)) == 12); // 12 PM -static_assert(hours_from_reg(0x40 | to_bcd(1)) == 1); // 1 AM -static_assert(hours_from_reg(0x40 | 0x20 | to_bcd(1)) == 13); // 1 PM -static_assert(hours_from_reg(0x40 | 0x20 | to_bcd(11)) == 23); // 11 PM +static_assert(hours_from_reg(0x40 | to_bcd(12)) == 0); // 12 AM +static_assert(hours_from_reg(0x40 | 0x20 | to_bcd(12)) == 12); // 12 PM +static_assert(hours_from_reg(0x40 | to_bcd(1)) == 1); // 1 AM +static_assert(hours_from_reg(0x40 | 0x20 | to_bcd(1)) == 13); // 1 PM +static_assert(hours_from_reg(0x40 | 0x20 | to_bcd(11)) == 23); // 11 PM // Sakamoto's method, against dates a calendar can be checked against rather // than against this implementation run twice. Sunday is 1.