Trim some questionable stuff from style guide
This commit is contained in:
28
style.md
28
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
|
||||
|
||||
Reference in New Issue
Block a user