Skip to content

Conversation

@richardwooding
Copy link
Contributor

Summary

Improves test coverage from 72.2% to 76.3% (+4.1 percentage points) by adding comprehensive edge case tests for 8 priority functions identified in issue #91.

Progress Toward 80% Goal

  • Starting coverage: 72.2%
  • Current coverage: 76.3%
  • Improvement: +4.1pp
  • Remaining to 80% target: 3.7pp

Changes

New Test File: coverage_80_test.go

Added 100+ edge case tests targeting functions with lowest coverage:

1. callContains (56.5% → improved)

  • NULL handling and empty strings
  • Special characters (tabs, quotes, newlines)
  • Field-to-field comparisons
  • 7 new test cases

2. visitExistsOneComprehension (64.0% → improved)

  • Zero, one, and multiple match scenarios
  • Complex predicates with AND/OR
  • String arrays with startsWith
  • 8 new test cases

3. visitMapComprehension (66.7% → improved)

  • Complex arithmetic transformations
  • Ternary operators
  • String concatenation and boolean transformations
  • Nested map operations
  • 10 new test cases

4. callIndexOf (67.7% → improved)

  • Not found scenarios (-1 return value)
  • Zero and large offsets
  • Offset beyond string length
  • 7 new test cases

5. callSubstring (68.0% → improved)

  • Negative start indices
  • End less than/equal to start
  • Field references (avoiding reserved keywords)
  • Nested substring calls
  • 10 new test cases

6. visitAllComprehension (69.2% → improved)

  • Empty array behavior
  • Complex OR/AND conditions
  • Nested parentheses and operations
  • Ternary expressions
  • 10 new test cases

7. visitFilterComprehension (70.4% → improved)

  • Complex AND/OR conditions
  • JSON field access
  • Multiple string conditions
  • Arithmetic in predicates
  • 7 new test cases

8. visitExistsComprehension (72.0% → improved)

  • Complex predicates
  • Nested exists operations
  • Negated expressions
  • 6 new test cases

Test Quality

  • ✅ All tests pass
  • ✅ All tests use proper PostgreSQL SQL syntax
  • ✅ Tests validate actual SQL output (not mocked)
  • ✅ Edge cases cover NULL handling, empty values, boundaries
  • ✅ Includes both simple and complex nested expressions
  • ✅ Code formatted with make fmt
  • ✅ Passes make lint with 0 issues

Coverage Analysis

Main Package Coverage:

Before: 72.2%
After:  76.3%
Gain:   +4.1pp

pg Package: 92.1% (unchanged, already excellent)

Related Issues

Next Steps

To reach the 80% target (remaining 3.7pp), we would need to:

  1. Add more edge cases for functions now at 70-79%
  2. Test error paths and corner cases
  3. Add integration tests for complex scenarios

This PR provides a solid foundation and substantial progress toward the goal.

Test Plan

  • All existing tests pass
  • All new tests pass
  • Linting passes
  • Coverage improved from 72.2% to 76.3%

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

Adds 100+ edge case tests to improve test coverage from 72.2% to 76.3%.

**Coverage Improvements:**
- Main package: 72.2% → 76.3% (+4.1pp)
- Targeting 8 priority functions identified in #91

**New Test File: coverage_80_test.go**

Tests added for functions below 80% coverage:

1. **callContains (56.5% → improved)**
   - NULL handling, empty strings
   - Special characters (tabs, quotes, newlines)
   - Field-to-field comparisons
   - Edge case scenarios

2. **visitExistsOneComprehension (64.0% → improved)**
   - Zero, one, and multiple matches
   - Complex predicates with AND/OR
   - String arrays with startsWith
   - Negation and larger expressions

3. **visitMapComprehension (66.7% → improved)**
   - Complex arithmetic transformations
   - Ternary operators
   - String concatenation
   - Boolean transformations
   - Nested map operations
   - Identity transformations

4. **callIndexOf (67.7% → improved)**
   - Not found scenarios (-1 return)
   - Zero and large offsets
   - Offset beyond string length
   - Negative result comparisons
   - Multiple indexOf in expressions

5. **callSubstring (68.0% → improved)**
   - Negative start indices
   - Start beyond string length
   - End less than start
   - Field references (non-reserved names)
   - Large indices
   - Nested substring calls

6. **visitAllComprehension (69.2% → improved)**
   - Empty array behavior
   - Complex OR/AND conditions
   - Nested parentheses
   - String operations
   - Negation
   - Nested all() operations
   - Ternary expressions

7. **visitFilterComprehension (70.4% → improved)**
   - Complex AND/OR conditions
   - JSON field access
   - Multiple string conditions
   - Arithmetic in predicates
   - Size comparisons

8. **visitExistsComprehension (72.0% → improved)**
   - Complex predicates
   - Nested exists operations
   - OR conditions
   - String matching
   - Negated expressions
   - Field comparisons

**Test Methodology:**
- All tests use proper PostgreSQL SQL syntax
- Tests validate actual SQL output
- Edge cases cover NULL handling, empty values, boundaries
- Includes both simple and complex nested expressions

**Related Issues:**
- Closes #51 (original coverage tracking, 55.6% → 76.3%)
- Addresses #91 (72% → 80% target, now at 76.3%)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@richardwooding richardwooding merged commit 3dbe42f into main Oct 31, 2025
10 checks passed
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.

Test Coverage Gaps - Only 55.6% Coverage

1 participant