Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 31, 2025

This PR fixes critical logical errors in FilenameUtils functions, renames a function for clarity, and adds comprehensive test coverage for edge cases based on review feedback.

Key Function Logic Changes

Renamed and Fixed getPathNoEndSeparators() - Changed function name to reflect that it removes multiple trailing separators:

  • Function now properly removes multiple trailing slashes: "C:\folder\\\""C:\folder"
  • Maintains original input when no trailing separators exist
  • Updated all references and tests to use new function name

Fixed getPathWithEndSeparator() - Removed unsupported string concatenation operation:

  • Before: Attempted to add trailing separator using filename + L"\\"
  • After: Returns input unchanged since USimpleString doesn't support concatenation
  • Function can no longer add separators, only ensures existing separators are preserved

Enhanced getServerAndShareName() - Now only returns results when both server AND share exist:

  • Removed server-only extraction logic that violated function naming contract
  • Only returns complete server+share combinations: "\device\mup\server\share""\server\share"
  • Returns empty result for server-only paths to maintain function purpose

Fixed Code Style - Added curly braces to all if statements for consistency:

// Before
if (condition)
    statement;

// After  
if (condition)
{
    statement;
}

Simplified dosNameToNative() - Streamlined empty path handling:

  • Changed return UString<poolType>{} to return {} for cleaner code

Enhanced Test Coverage

Updated all tests to reflect new function behaviors:

  • Function renaming: All getPathNoEndSeparator calls updated to getPathNoEndSeparators
  • Separator handling: Tests now expect input unchanged when separators cannot be added
  • Server-only paths: Added test case expecting empty result for server-only MUP paths
  • Edge case validation: All existing edge cases maintained with corrected expectations

Test Strategy

Tests continue using kernel-mode path formats (\Device\HarddiskVolume1\, \Device\Mup\) and focus on essential edge cases. The BDD-style structure with separated WHEN/THEN blocks maintains test readability while ensuring all function behaviors are properly validated.

These changes ensure FilenameUtils functions behave according to their intended purpose and naming conventions while maintaining backward compatibility for valid use cases.

Fixes #30.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits July 31, 2025 15:59
Co-authored-by: SergiusTheBest <4660722+SergiusTheBest@users.noreply.github.com>
Co-authored-by: SergiusTheBest <4660722+SergiusTheBest@users.noreply.github.com>
Copilot AI changed the title [WIP] Test kf/FilenameUtils.h Add comprehensive tests for kf/FilenameUtils.h Jul 31, 2025
Copilot AI requested a review from SergiusTheBest July 31, 2025 16:04
Copilot finished work on behalf of SergiusTheBest July 31, 2025 16:04
Copilot AI and others added 2 commits July 31, 2025 16:26
…rate WHEN/THEN blocks

Co-authored-by: belyshevdenis <47354295+belyshevdenis@users.noreply.github.com>
…/THEN separation for all scenarios

Co-authored-by: belyshevdenis <47354295+belyshevdenis@users.noreply.github.com>
Copilot AI requested a review from belyshevdenis July 31, 2025 16:33
Copilot finished work on behalf of belyshevdenis July 31, 2025 16:33
… kf; and focus on edge cases

Co-authored-by: belyshevdenis <47354295+belyshevdenis@users.noreply.github.com>
Copilot AI changed the title Add comprehensive tests for kf/FilenameUtils.h Add focused edge case tests for kf/FilenameUtils.h Jul 31, 2025
Copilot finished work on behalf of belyshevdenis July 31, 2025 16:52
Copilot AI requested a review from belyshevdenis July 31, 2025 16:52
…s found

Co-authored-by: belyshevdenis <47354295+belyshevdenis@users.noreply.github.com>
Copilot AI changed the title Add focused edge case tests for kf/FilenameUtils.h Add focused edge case tests for kf/FilenameUtils.h and fix logical errors Jul 31, 2025
Copilot AI requested a review from belyshevdenis July 31, 2025 17:51
Copilot finished work on behalf of belyshevdenis July 31, 2025 17:51
Copilot AI requested a review from belyshevdenis July 31, 2025 19:40
Copilot finished work on behalf of belyshevdenis July 31, 2025 19:40
Co-authored-by: belyshevdenis <47354295+belyshevdenis@users.noreply.github.com>
Copilot AI changed the title Fix FilenameUtils function logic and add comprehensive edge case tests Fix FilenameUtils function logic, rename function, and add comprehensive edge case tests Jul 31, 2025
Copilot finished work on behalf of belyshevdenis July 31, 2025 20:00
Copilot AI requested a review from belyshevdenis July 31, 2025 20:00
…second parameter

Co-authored-by: belyshevdenis <47354295+belyshevdenis@users.noreply.github.com>
Copilot finished work on behalf of belyshevdenis July 31, 2025 20:08
Copilot AI requested a review from belyshevdenis July 31, 2025 20:08
…nd operator[] with charAt()

Co-authored-by: belyshevdenis <47354295+belyshevdenis@users.noreply.github.com>
Copilot AI requested a review from belyshevdenis July 31, 2025 20:36
Copilot finished work on behalf of belyshevdenis July 31, 2025 20:36
@belyshevdenis belyshevdenis self-requested a review August 7, 2025 11:26
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 kf/FilenameUtils.h

3 participants