Skip to content

refactor: Extract test loop boilerplate and add type helpers#16766

Open
han-yan01 wants to merge 1 commit intofacebookincubator:mainfrom
han-yan01:export-D96376610
Open

refactor: Extract test loop boilerplate and add type helpers#16766
han-yan01 wants to merge 1 commit intofacebookincubator:mainfrom
han-yan01:export-D96376610

Conversation

@han-yan01
Copy link
Contributor

@han-yan01 han-yan01 commented Mar 13, 2026

Summary:

Reduced test LOC by extracting createIndexBoundEncodeTestCases + for-loop pattern
into runIndexBoundTests() helper. Replaced 149 occurrences with single-line calls.
Also fixed critical bug at line 158: was testing kDescNullsFirst
twice instead of kDescNullsFirst + kDescNullsLast, meaning
DESC_NULLS_LAST sort order was never tested.
Added type-specific row creation helpers (makeIntRow, makeBigIntRow,
makeSmallIntRow, makeTinyIntRow, makeStringRow) with overloads for single-column,
two-column, and nullable variants. Applied these systematically across all
encodeIndexBoundsWith* tests using automated refactoring script.
Removed 997 redundant sort order comments (e.g., "// ASC_NULLS_FIRST lower")
from runIndexBoundTests() calls. The parameter names (ascNullsFirstExpectedLowerBound, etc.)
are self-documenting, making the inline comments pure noise. Applied automated regex-based
removal followed by clang-format reflow, which collapsed multi-line expressions.

Differential Revision: D96376610

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 13, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 13, 2026

@han-yan01 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D96376610.

@netlify
Copy link

netlify bot commented Mar 13, 2026

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 82d35a7
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/69b4b59456fa7d0008222b0b

…elpers (facebookincubator#16766)

Summary:

**Phase 1:** Reduced test LOC by extracting createIndexBoundEncodeTestCases + for-loop pattern
into runIndexBoundTests() helper. Replaced 149 occurrences with single-line calls.

Also fixed critical bug at line 158: was testing kDescNullsFirst
twice instead of kDescNullsFirst + kDescNullsLast, meaning
DESC_NULLS_LAST sort order was never tested.

**Phase 2:** Added type-specific row creation helpers (makeIntRow, makeBigIntRow,
makeSmallIntRow, makeTinyIntRow, makeStringRow) with overloads for single-column,
two-column, and nullable variants. Applied these systematically across all
encodeIndexBoundsWith* tests using automated refactoring script.

**Phase 3:** Removed 997 redundant sort order comments (e.g., "// ASC_NULLS_FIRST lower")
from runIndexBoundTests() calls. The parameter names (ascNullsFirstExpectedLowerBound, etc.)
are self-documenting, making the inline comments pure noise. Applied automated regex-based
removal followed by clang-format reflow, which collapsed multi-line expressions for an
additional 241-line reduction.

**Net result:** Reduced KeyEncoderTest.cpp from 12,165 lines to 10,192 lines
(1,973 lines removed, 16.2% reduction) while maintaining 100% test coverage.

Differential Revision: D96376610
@meta-codesync meta-codesync bot changed the title Refactor KeyEncoderTest: extract test loop boilerplate Refactor KeyEncoderTest: extract test loop boilerplate and add type helpers (#16766) Mar 14, 2026
@han-yan01 han-yan01 changed the title Refactor KeyEncoderTest: extract test loop boilerplate and add type helpers (#16766) refactor: extract test loop boilerplate and add type helpers Mar 14, 2026
@han-yan01 han-yan01 changed the title refactor: extract test loop boilerplate and add type helpers refactor: Extract test loop boilerplate and add type helpers Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants