Skip to content

🧪 Add tests for RegExEscape in CitraConfigHelpers#82

Open
Ven0m0 wants to merge 1 commit intomainfrom
add-regexescape-tests-12592488209736619716
Open

🧪 Add tests for RegExEscape in CitraConfigHelpers#82
Ven0m0 wants to merge 1 commit intomainfrom
add-regexescape-tests-12592488209736619716

Conversation

@Ven0m0
Copy link
Copy Markdown
Owner

@Ven0m0 Ven0m0 commented Apr 28, 2026

🎯 What: Added tests for the RegExEscape pure string replacement function in CitraConfigHelpers_Test.ahk.
📊 Coverage: Tested empty strings, alphanumeric strings without special characters, and three different patterns covering all 14 PCRE special characters.
Result: RegExEscape is now fully unit-tested, improving codebase safety against future string manipulation modifications.


PR created automatically by Jules for task 12592488209736619716 started by @Ven0m0

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new test suite, TestRegExEscape, to verify the regex escaping functionality in the Citra configuration helpers. The test cases cover empty strings, alphanumeric characters, and various special characters. However, there is a concern that the current implementation of RegExEscape in CitraConfigHelpers.ahk may fail these tests due to how AutoHotkey v2 handles backslashes and dollar signs in RegExReplace replacement strings; specifically, the replacement string likely needs to use "\\$1" to correctly produce a literal backslash.

Comment on lines +20 to +38
TestRegExEscape() {
global stdout
stdout.WriteLine("Running TestRegExEscape...")

; Test 1: Empty string
AssertEqual(RegExEscape(""), "", "RegExEscape handles empty string")

; Test 2: No special characters
AssertEqual(RegExEscape("hello"), "hello", "RegExEscape leaves alphanumeric characters unchanged")

; Test 3: Some special characters
AssertEqual(RegExEscape("h.e*l+l?o"), "h\.e\*l\+l\?o", "RegExEscape escapes dot, star, plus, question mark")

; Test 4: Brackets and braces
AssertEqual(RegExEscape("(hello)[world]{test}"), "\(hello\)\[world\]\{test\}", "RegExEscape escapes brackets and braces")

; Test 5: Caret, dollar, pipe, backslash
AssertEqual(RegExEscape("^hello$|world\"), "\^hello\$\|world\\", "RegExEscape escapes caret, dollar, pipe, backslash")
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The test cases correctly define the expected behavior for RegExEscape. However, the current implementation of RegExEscape in CitraConfigHelpers.ahk (line 21) is likely to cause these tests to fail.

In AutoHotkey v2, the RegExReplace replacement string treats \ as a literal backslash and $$ as a literal dollar sign. A single backslash preceding a backreference (like \$1) is consumed as an escape character. Therefore, "\$1" results in the match of the first subpattern without a preceding backslash. To correctly escape characters with a literal backslash, the replacement string should be "\\$1".

You should verify the test results; if they are failing as expected, the fix should be applied to the RegExEscape function in CitraConfigHelpers.ahk.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 28, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • Other/Citra_per_game_config/v2/CitraConfigHelpers_Test.ahk

Reviewed by step-3.5-flash · 180,174 tokens

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.

1 participant