Skip to content

standardize tests: template macros, c++20 ranges, naming conventions#226

Merged
cameroncuster merged 8 commits into
devfrom
test-standardization
Jul 6, 2026
Merged

standardize tests: template macros, c++20 ranges, naming conventions#226
cameroncuster merged 8 commits into
devfrom
test-standardization

Conversation

@cameroncuster

@cameroncuster cameroncuster commented Jul 6, 2026

Copy link
Copy Markdown
Member

Standardizes tests/library_checker_aizu_tests/ to the same conventions the library already follows: template macros, C++20 ranges/<bit>, and the naming conventions from #223. Test-only change — no library headers touched.

Tests already include kactl_macros.hpp (via template.hpp), so the macros were available everywhere but used inconsistently — e.g. 14 files used rep(...) while 108 used raw loops, and 84 files used vector<int> while 31 used vi, sometimes mixed within one file.

Template macros (matching library style)

  • for (int i = a; i < b; i++) -> rep(i, a, b) (~290 sites; loops with a second init variable, non-< conditions, or non-++ increments left as raw for)
  • vector<int> -> vi (175 sites), pair<int, int> -> pii (28)
  • long long / int64_t -> ll (33 sites; uint64_t untouched)
  • ssize(x) / (int)size(x) -> sz(x) (20)
  • begin(x), end(x) -> all(x) (47)

C++20 standardization (matching #221)

Use the ranges::/views::/<bit> form consistently wherever it applies:

  • full-range algo(all(x), ...) -> ranges::algo(x, ...) for sort, reverse, fill, count, find, min/max_element, generate, transform, lower_bound, etc. (~70 sites across 29 files)
  • membership checks use ranges::find(x, v) == end(x) / ranges::count; associative containers use .contains()
  • __lg -> <bit> (bit_width/bit_floor) in seg_tree_midpoint.test.cpp
  • left as-is: iota, accumulate, partial_sum (no C++20 ranges counterpart), genuinely offset/partial ranges
  • left as-is: unique/remove_if stay in iterator form (algo(all(x), ...)) — the ranges:: versions return a subrange needing a begin(...) unwrap and trip cppcheck mismatchingContainerExpression false positives (same rule as standardize on c++20: ranges/views and <bit> used consistently #221)

Naming conventions (matching #223)

  • ans -> res (range_parallel_dsu, count_paths)
  • curr -> cur, prev -> prv (5 files)
  • seen/used -> vis (3 files)
  • priority -> pri (pq_ds_undo_sliding_window)
  • next -> nxt (functional_graph, directed_cycle)

Verification

  • clang-format --dry-run --Werror (dev config) passes on all touched files
  • all changed test files compile with g++ -std=c++20 -O2 -Wall -Wextra
  • repo grep checks pass: no endl, no member-call .size()/.begin() forms, no long long/vector<int> stragglers, no __lg
  • cppcheck suppression list audited: all line-pinned test-file entries still point at the same statements (the suppressed lines did not shift); several entries reference files that no longer exist, which predates this PR

@cameroncuster cameroncuster merged commit f1f4f01 into dev Jul 6, 2026
7 of 8 checks passed
@cameroncuster cameroncuster deleted the test-standardization branch July 6, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant