Skip to content

Commit

Permalink
Merge pull request #30 from codecrafters-io/add-testcase-to-fz7
Browse files Browse the repository at this point in the history
CC-1445: Improve Grep tests: where the mandatory chars after the + operator are missing or wrong
  • Loading branch information
andy1li authored Oct 14, 2024
2 parents 9912768 + 8e8f7bb commit d9e7727
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
go-version: 1.21.x

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.12'

# The build from installing through the package manager doesn't have support for PCRE2
- name: Set up Ripgrep with PCRE2
Expand Down
5 changes: 5 additions & 0 deletions internal/stage_one_or_more_quantifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ func testOneOrMoreQuantifier(stageHarness *test_case_harness.TestCaseHarness) er
Input: "act",
ExpectedExitCode: 1,
},
{
Pattern: "ca+t",
Input: "ca",
ExpectedExitCode: 1,
},
}

return RunTestCases(testCases, stageHarness)
Expand Down
2 changes: 2 additions & 0 deletions internal/test_helpers/fixtures/alternation/success
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
[stage-9] ✓ Received exit code 0.
[stage-9] $ echo -n "act" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] $ echo -n "ca" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] Test passed.

[stage-8] Running tests for Stage #8: ao7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
[stage-9] ✓ Received exit code 0.
[stage-9] $ echo -n "act" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] $ echo -n "ca" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] Test passed.

[stage-8] Running tests for Stage #8: ao7
Expand Down
2 changes: 2 additions & 0 deletions internal/test_helpers/fixtures/backreferences_nested/success
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@
[stage-9] ✓ Received exit code 0.
[stage-9] $ echo -n "act" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] $ echo -n "ca" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] Test passed.

[stage-8] Running tests for Stage #8: ao7
Expand Down
2 changes: 2 additions & 0 deletions internal/test_helpers/fixtures/backreferences_single/success
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
[stage-9] ✓ Received exit code 0.
[stage-9] $ echo -n "act" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] $ echo -n "ca" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] Test passed.

[stage-8] Running tests for Stage #8: ao7
Expand Down
2 changes: 2 additions & 0 deletions internal/test_helpers/fixtures/one_or_more_quantifier/success
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
[stage-9] ✓ Received exit code 0.
[stage-9] $ echo -n "act" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] $ echo -n "ca" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] Test passed.

[stage-8] Running tests for Stage #8: ao7
Expand Down
2 changes: 2 additions & 0 deletions internal/test_helpers/fixtures/wildcard/success
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
[stage-9] ✓ Received exit code 0.
[stage-9] $ echo -n "act" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] $ echo -n "ca" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] Test passed.

[stage-8] Running tests for Stage #8: ao7
Expand Down
2 changes: 2 additions & 0 deletions internal/test_helpers/fixtures/zero_or_one_quantifier/success
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
[stage-9] ✓ Received exit code 0.
[stage-9] $ echo -n "act" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] $ echo -n "ca" | ./your_grep.sh -E "ca+t"
[stage-9] ✓ Received exit code 1.
[stage-9] Test passed.

[stage-8] Running tests for Stage #8: ao7
Expand Down

0 comments on commit d9e7727

Please sign in to comment.