From 23b0e7f39ae25c52144dce29ef4c8b238c4854c6 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Sat, 23 Aug 2025 20:48:31 -0400 Subject: [PATCH] Trim some questionable stuff from style guide --- style.md | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/style.md b/style.md index 4484231..d04ca8c 100644 --- a/style.md +++ b/style.md @@ -56,10 +56,9 @@ signal(SIGTERM, handler); ``` ### Data Types -- **Almost always signed** - prefer `int`, `int64_t`, `size_t` over unsigned types except for: +- **Almost always signed** - prefer `int`, `int64_t`, `ssize_t` over unsigned types except for: - Bit manipulation operations - Interfacing with APIs that require unsigned types - - Memory sizes where overflow is impossible (`size_t`, `uint32_t` for arena block sizes) - Where defined unsigned overflow behavior (wraparound) is intentional and desired - **Almost always auto** - let the compiler deduce types except when: - The type is not obvious from context (prefer explicit for clarity) @@ -480,9 +479,7 @@ TEST_CASE("ArenaAllocator basic allocation") { ``` ### Test Design Principles -- **Prefer testing through public interfaces** - focus on observable behavior rather than implementation details -- **Test the contract, not the implementation** - validate what the API promises to deliver -- **Avoid testing private methods directly** - if private functionality needs testing, consider if it should be public or extracted +- **Test the contract, not the implementation** - validate what the API promises to deliver, not implementation details - **Both integration and unit tests** - test components in isolation and working together - **Prefer fakes to mocks** - use real implementations for internal components, fake external dependencies - **Always enable assertions in tests** - use `-UNDEBUG` pattern to ensure assertions are checked (see Build Integration section) @@ -509,7 +506,6 @@ TEST_CASE("Server accepts connections") { - `condition_variable.wait()` without timeout - `std::latch`, `std::barrier`, futures/promises - **Force concurrent execution** using `std::latch` to synchronize thread startup -- **Tests should pass or hang** - no flaky timeout behavior ```cpp // BAD: Race likely over before threads start @@ -559,22 +555,4 @@ add_executable(example src/example.cpp src/main.cpp) ``` ### Code Generation -- **gperf** for perfect hash table generation -- **Build-time generation** of token lookup tables -- **Include generated headers** from build directory - ---- - -## Style Enforcement - -### Consistency -- Follow existing patterns in the codebase -- Use the same style for similar constructs -- Maintain consistency within each translation unit - -### Tools -- **clang-format** configuration (when available) -- **Static analysis** tools for code quality -- **Address sanitizer** for memory safety testing - -This style guide reflects the existing codebase patterns and should be followed for all new code contributions to maintain consistency and readability. +- Generated files go in build directory, not source