Skip to content

Commit 63b9b15

Browse files
committed
refactor: update input patterns in start and end of string anchor tests to include underscores for better clarity
1 parent 2a15d50 commit 63b9b15

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed

internal/stage_end_of_string_anchor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ func testEndOfStringAnchor(stageHarness *test_case_harness.TestCaseHarness) erro
1616
testCaseCollection := test_cases.StdinTestCaseCollection{
1717
{
1818
Pattern: fmt.Sprintf("%s$", words[1]),
19-
Input: words[0] + words[1],
19+
Input: words[0] + "_" + words[1],
2020
ExpectedExitCode: 0,
2121
},
2222
{
2323
Pattern: fmt.Sprintf("%s$", words[1]),
24-
Input: words[1] + words[0],
24+
Input: words[1] + "_" + words[0],
2525
ExpectedExitCode: 1,
2626
},
2727
{
@@ -31,7 +31,7 @@ func testEndOfStringAnchor(stageHarness *test_case_harness.TestCaseHarness) erro
3131
},
3232
{
3333
Pattern: fmt.Sprintf("^%s$", words[2]),
34-
Input: words[1] + words[2] + words[0],
34+
Input: words[1] + "_" + words[2] + "_" + words[0],
3535
ExpectedExitCode: 1,
3636
},
3737
}

internal/stage_start_of_string_anchor.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
package internal
22

33
import (
4+
"fmt"
5+
46
"github.com/codecrafters-io/grep-tester/internal/test_cases"
7+
"github.com/codecrafters-io/tester-utils/random"
58
"github.com/codecrafters-io/tester-utils/test_case_harness"
69
)
710

811
func testStartOfStringAnchor(stageHarness *test_case_harness.TestCaseHarness) error {
912
RelocateSystemGrep(stageHarness)
1013

14+
words := random.RandomWords(2)
15+
1116
testCaseCollection := test_cases.StdinTestCaseCollection{
1217
{
13-
Pattern: "^log",
14-
Input: "log",
18+
Pattern: fmt.Sprintf("^%s", words[0]),
19+
Input: words[0] + "_" + words[1],
1520
ExpectedExitCode: 0,
1621
},
1722
{
18-
Pattern: "^log",
19-
Input: "slog",
23+
Pattern: fmt.Sprintf("^%s", words[0]),
24+
Input: words[1] + "_" + words[0],
2025
ExpectedExitCode: 1,
2126
},
2227
}

internal/test_helpers/fixtures/base_stages/success

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@
5151
[tester::#FZ7] Test passed.
5252

5353
[tester::#AO7] Running tests for Stage #AO7 (ao7)
54-
[tester::#AO7] $ echo -n "appleblueberry" | ./your_grep.sh -E "blueberry$"
55-
[your_program] appleblueberry
54+
[tester::#AO7] $ echo -n "apple_blueberry" | ./your_grep.sh -E "blueberry$"
55+
[your_program] apple_blueberry
5656
[tester::#AO7] ✓ Received exit code 0.
57-
[tester::#AO7] $ echo -n "blueberryapple" | ./your_grep.sh -E "blueberry$"
57+
[tester::#AO7] $ echo -n "blueberry_apple" | ./your_grep.sh -E "blueberry$"
5858
[tester::#AO7] ✓ Received exit code 1.
5959
[tester::#AO7] $ echo -n "strawberry" | ./your_grep.sh -E "^strawberry$"
6060
[your_program] strawberry
6161
[tester::#AO7] ✓ Received exit code 0.
62-
[tester::#AO7] $ echo -n "blueberrystrawberryapple" | ./your_grep.sh -E "^strawberry$"
62+
[tester::#AO7] $ echo -n "blueberry_strawberry_apple" | ./your_grep.sh -E "^strawberry$"
6363
[tester::#AO7] ✓ Received exit code 1.
6464
[tester::#AO7] Test passed.
6565

6666
[tester::#RR8] Running tests for Stage #RR8 (rr8)
67-
[tester::#RR8] $ echo -n "log" | ./your_grep.sh -E "^log"
68-
[your_program] log
67+
[tester::#RR8] $ echo -n "blueberry_raspberry" | ./your_grep.sh -E "^blueberry"
68+
[your_program] blueberry_raspberry
6969
[tester::#RR8] ✓ Received exit code 0.
70-
[tester::#RR8] $ echo -n "slog" | ./your_grep.sh -E "^log"
70+
[tester::#RR8] $ echo -n "raspberry_blueberry" | ./your_grep.sh -E "^blueberry"
7171
[tester::#RR8] ✓ Received exit code 1.
7272
[tester::#RR8] Test passed.
7373

@@ -107,32 +107,32 @@
107107
[tester::#RK3] Test passed.
108108

109109
[tester::#TL6] Running tests for Stage #TL6 (tl6)
110-
[tester::#TL6] $ echo -n "b" | ./your_grep.sh -E "[blueberry]"
111-
[your_program] b
110+
[tester::#TL6] $ echo -n "l" | ./your_grep.sh -E "[blueberry]"
111+
[your_program] l
112112
[tester::#TL6] ✓ Received exit code 0.
113-
[tester::#TL6] $ echo -n "bac" | ./your_grep.sh -E "[blueberry]"
114-
[your_program] bac
113+
[tester::#TL6] $ echo -n "lac" | ./your_grep.sh -E "[blueberry]"
114+
[your_program] lac
115115
[tester::#TL6] ✓ Received exit code 0.
116-
[tester::#TL6] $ echo -n "raspberry" | ./your_grep.sh -E "[cdfghijkl]"
116+
[tester::#TL6] $ echo -n "mango" | ./your_grep.sh -E "[bcdef]"
117117
[tester::#TL6] ✓ Received exit code 1.
118-
[tester::#TL6] $ echo -n "[]" | ./your_grep.sh -E "[pineapple]"
118+
[tester::#TL6] $ echo -n "[]" | ./your_grep.sh -E "[banana]"
119119
[tester::#TL6] ✓ Received exit code 1.
120120
[tester::#TL6] Test passed.
121121

122122
[tester::#MR9] Running tests for Stage #MR9 (mr9)
123-
[tester::#MR9] $ echo -n "apple" | ./your_grep.sh -E "\w"
124-
[your_program] apple
123+
[tester::#MR9] $ echo -n "raspberry" | ./your_grep.sh -E "\w"
124+
[your_program] raspberry
125125
[tester::#MR9] ✓ Received exit code 0.
126-
[tester::#MR9] $ echo -n "ORANGE" | ./your_grep.sh -E "\w"
127-
[your_program] ORANGE
126+
[tester::#MR9] $ echo -n "MANGO" | ./your_grep.sh -E "\w"
127+
[your_program] MANGO
128128
[tester::#MR9] ✓ Received exit code 0.
129-
[tester::#MR9] $ echo -n "170" | ./your_grep.sh -E "\w"
130-
[your_program] 170
129+
[tester::#MR9] $ echo -n "300" | ./your_grep.sh -E "\w"
130+
[your_program] 300
131131
[tester::#MR9] ✓ Received exit code 0.
132-
[tester::#MR9] $ echo -n "=%×_=×+" | ./your_grep.sh -E "\w"
133-
[your_program] =%×_=×+
132+
[tester::#MR9] $ echo -n "-#%_%÷×" | ./your_grep.sh -E "\w"
133+
[your_program] -#%_%÷×
134134
[tester::#MR9] ✓ Received exit code 0.
135-
[tester::#MR9] $ echo -n "÷-×=#+" | ./your_grep.sh -E "\w"
135+
[tester::#MR9] $ echo -n "+=#÷%-" | ./your_grep.sh -E "\w"
136136
[tester::#MR9] ✓ Received exit code 1.
137137
[tester::#MR9] Test passed.
138138

0 commit comments

Comments
 (0)