Skip to content

Commit

Permalink
Update docs & tests for backtracing support
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy-Gonzalez committed Feb 12, 2024
1 parent b9495e8 commit 10fd74c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Match specifiers are specified with `$`:
- `$s` = match a string (at least 1 character)
- `$$` = a literal $
- Anything else = literal match
- **Note:** Having two greedy operators like $s without a literal match between them (`$s$s`) will fail
- **Note:** Supports backtracing so `abc` will match `$s$s` but `a` won't

## Expect Assertions

Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ TEST("str - match")

EXPECT_STR("a 123c number char", match, "a $i$c number char");
EXPECT_STR("two nice looking - awesome beings strings", match, "two $s - $s strings");
EXPECT_STR("will backtrace", match, "$s$s");

EXPECT_STR("abc", not match, "def");
EXPECT_STR("the char is missing: ", not match, "the char is missing: $c");
EXPECT_STR("the no alpha 123 match", not match, "the no alpha $a match");
EXPECT_STR("the no whitespace \t match", not match, "the no whitespace $w match");
EXPECT_STR("the string is missing: ", not match, "the string is missing: $s");
EXPECT_STR("not a match", not match, "not a $s match");
EXPECT_STR("too greedy", not match, "$s$s");
}
```
Expand Down
10 changes: 9 additions & 1 deletion tests/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,22 @@ TEST("str - match")

EXPECT_STR("a 123c number char", match, "a $i$c number char");
EXPECT_STR("two nice looking - awesome beings strings", match, "two $s - $s strings");
EXPECT_STR("will backtrace", match, "$s$s");

EXPECT_STR("abc", not match, "def");
EXPECT_STR("the char is missing: ", not match, "the char is missing: $c");
EXPECT_STR("the no alpha 123 match", not match, "the no alpha $a match");
EXPECT_STR("the no whitespace \t match", not match, "the no whitespace $w match");
EXPECT_STR("the string is missing: ", not match, "the string is missing: $s");
EXPECT_STR("not a match", not match, "not a $s match");
EXPECT_STR("too greedy", not match, "$s$s");

// Evil test cases (not examples, stress testing verification only)
EXPECT_STR("ABC_ABC_ABC", match, "$s_$s_$s");
EXPECT_STR("ABC____ABC____ABC", match, "ABC$sABC$sABC");
EXPECT_STR("WOW This is cool! WOW This is cool! WOW This is cool! WOW This is cool!",
match, "WOW This is cool!$sWOW This is cool!$sWOW This is cool!$sWOW This is cool!");
EXPECT_STR("WOW This is cool! WOW This is cool! WOW This is cool! WOW This is cool",
not match, "WOW This is cool!$sWOW This is cool!$sWOW This is cool!$sWOW This is cool!");
}

TEST("str - ptrs")
Expand Down

0 comments on commit 10fd74c

Please sign in to comment.