Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 5, 2025

The char module lacked sufficient test coverage for character conversion methods, Unicode handling, and UTF-16 encoding behaviors.

Tests Added

  • Character conversions: Int::to_char(), Int::unsafe_to_char(), Char::to_int(), Char::to_uint()
  • UTF-16 encoding: Char::utf16_len() for BMP and supplementary plane characters, Char::is_bmp()
  • Surrogate detection: Int::is_surrogate() for UTF-16 surrogate pairs (0xD800-0xDFFF range)
  • ASCII operations: Char::is_ascii_digit() with boundary cases
  • Comparison operators: Equality and ordering for various character types
  • Unicode edge cases: Zero-width characters (ZWS, ZWJ, soft hyphen), emoji, CJK scripts, mathematical/currency symbols

Example Coverage

test "Char conversion from Int" {
  // Valid conversions
  inspect((65 : Int).to_char(), content="Some('A')")
  inspect((0x1F600 : Int).to_char(), content="Some('😀')")
  
  // Surrogate range returns None
  inspect((0xD800 : Int).to_char(), content="None")
  inspect((0xDFFF : Int).to_char(), content="None")
}

test "Char utf16_len" {
  inspect('A'.utf16_len(), content="1")      // BMP: single code unit
  inspect('😀'.utf16_len(), content="2")     // Supplementary: surrogate pair
}

Added 12 test blocks (~197 lines), increasing coverage from 28 to 40 test blocks.

Original prompt

write some tests for char


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add tests for character functionality Add comprehensive tests for char module Dec 5, 2025
Copilot AI requested a review from bobzhang December 5, 2025 07:23
@coveralls
Copy link
Collaborator

coveralls commented Dec 5, 2025

Pull Request Test Coverage Report for Build 2055

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 90.844%

Totals Coverage Status
Change from base Build 2052: 0.0%
Covered Lines: 10160
Relevant Lines: 11184

💛 - Coveralls

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.

3 participants