Skip to content

Commit 18b06e5

Browse files
unhappychoiceclaude
andcommitted
test: add validation for chunk_counts sum in test macro
Add assertion to verify that the sum of chunk_counts equals total_chunks. This ensures all chunk types are properly accounted for in test expectations. Also improve error messages to show actual chunk_counts distribution when assertion fails, making it easier to fix test expectations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 737e05b commit 18b06e5

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

tests/integration/languages/extractor.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,33 @@ macro_rules! test_language_extractor {
3434
test_extraction_options()
3535
).unwrap();
3636

37+
38+
// Check chunk counts by type
39+
let mut chunk_counts: HashMap<ChunkType, usize> = HashMap::new();
40+
for chunk in &chunks {
41+
*chunk_counts.entry(chunk.chunk_type.clone()).or_insert(0) += 1;
42+
}
43+
3744
// Check total chunk count
3845
assert_eq!(
3946
chunks.len(),
4047
$total,
41-
"Expected {} total chunks, got {}",
48+
"Expected {} total chunks, got {}\nExpected: {:?}",
4249
$total,
43-
chunks.len()
50+
chunks.len(),
51+
chunk_counts
4452
);
4553

46-
// Check chunk counts by type
47-
let mut chunk_counts: HashMap<ChunkType, usize> = HashMap::new();
48-
for chunk in &chunks {
49-
*chunk_counts.entry(chunk.chunk_type.clone()).or_insert(0) += 1;
50-
}
54+
// Verify that the sum of expected chunk counts equals total_chunks
55+
let expected_sum: usize = 0 $(+ $count)*;
56+
assert_eq!(
57+
expected_sum,
58+
$total,
59+
"Sum of chunk_counts ({}) must equal total_chunks ({}).\nThis ensures all chunk types are accounted for.\nExpected: {:?}",
60+
expected_sum,
61+
$total,
62+
chunk_counts
63+
);
5164

5265
$(
5366
let expected_count = $count;

0 commit comments

Comments
 (0)