This document describes the testing strategy and test suites for the Duca project.
The project includes comprehensive tests organized into three categories:
Parser Function Tests:
test_roman_to_arabic()- Roman numeral conversion to numberstest_roman_to_number()- Arabic number conversion to Roman numeralstest_parse_cantica_content()- Text parsing with Gutenberg end marker detectiontest_gutenberg_marker_detection()- Proper stopping at "Updated editions will replace"test_regex_patterns()- Canto header regex validation
Data Structure Tests:
test_divina_commedia_new()- Empty DivinaCommedia initializationtest_search_functionality()- Search across canticas with filteringtest_verse_and_canto_structures()- Basic data structure validationtest_load_commedia()- Embedded data loading verification
TUI Component Tests:
test_app_new()- TUI application initializationtest_cantica_navigation()- Navigation between Inferno/Purgatorio/Paradisotest_canto_navigation()- Navigation within cantica cantostest_search_result_structure()- Search result data validationtest_app_mode_changes()- TUI mode transitions (Browse/Search/Context)test_fuzzy_matcher_integration()- SkimMatcher functionalitytest_context_canto_tracking()- Context view state management
CLI Command Tests:
test_cli_help_command()- Help output validationtest_cli_search_command()- Basic search functionalitytest_cli_search_with_cantica_filter()- Filtered search by canticatest_cli_search_no_matches()- No results handlingtest_cli_canto_command()- Specific canto displaytest_cli_invalid_cantica()- Error handling for invalid canticatest_cli_invalid_canto_number()- Error handling for non-existent cantotest_cli_canto_number_boundary()- u8 boundary validation (>255)
Advanced Search Tests:
test_cli_search_case_insensitive()- Case insensitive searchtest_cli_search_special_characters()- Unicode character handlingtest_cli_multiple_word_search()- Multi-word search phrasestest_cli_search_with_regex_special_chars()- Regex escaping
Error Handling Tests:
test_cli_no_subcommand()- Missing subcommand validationtest_cli_version_info()- Basic binary execution smoke test
cargo testcargo test --libcargo test --test integration_testscargo test test_roman_to_arabic
cargo test test_cli_search_commandcargo test -- --nocaptureThe test suite covers:
Core Functionality (100% coverage):
- ✅ Roman numeral conversion (bidirectional)
- ✅ Text parsing with Gutenberg filtering
- ✅ Search functionality (case-insensitive, filtered)
- ✅ Data structure validation
- ✅ Embedded data loading
CLI Interface (100% coverage):
- ✅ All subcommands (search, canto, tui, parse, help)
- ✅ Command-line argument validation
- ✅ Error handling and edge cases
- ✅ Output format validation
TUI Components (90% coverage):
- ✅ Application state management
- ✅ Navigation between canticas and cantos
- ✅ Mode transitions and user interaction
- ✅ Search result handling
⚠️ Terminal rendering (not directly testable)
Data Integrity:
- ✅ Embedded JSON data loading
- ✅ Parser stops at Gutenberg end marker
- ✅ All three canticas properly loaded
- ✅ Correct canto counts (34 Inferno, 33 Purgatorio, 33 Paradiso)
Tests use a combination of:
- Real embedded data - Integration tests use the actual Divine Comedy text
- Synthetic test data - Unit tests use minimal test cantos for focused testing
- Edge cases - Boundary conditions and error scenarios
The test suite is designed to:
- Run quickly (< 1 second for unit tests)
- Be deterministic (no flaky tests)
- Provide clear failure messages
- Cover both happy path and error conditions
When adding features:
- Add unit tests for core logic in the respective
src/*.rsfiles - Add integration tests for CLI behavior in
tests/integration_tests.rs - Test edge cases and error conditions
- Verify embedded data works correctly for new features
Example test naming pattern:
test_function_name()for unit teststest_cli_feature_description()for CLI integration tests