Skip to content
This repository was archived by the owner on Jul 17, 2019. It is now read-only.

Misleading documentation about regular expression matcher #221

Open
radekg1000 opened this issue Jan 16, 2019 · 2 comments
Open

Misleading documentation about regular expression matcher #221

radekg1000 opened this issue Jan 16, 2019 · 2 comments

Comments

@radekg1000
Copy link

radekg1000 commented Jan 16, 2019

The documentation for CookBook.md contains the following phrase:

EXPECT_THAT(Bar(), MatchesRegex("Line \\d+"));

This phrase is misleading on linux because \d metacharacter (for digit) is not supported on linux (just tested on my latest Mint linux). The same applies to advanced.md file which also mentions \d+ a few times.

Consider adding a unit test that would verify if they are really supported or change the documentation to match reality.

Additional comment: I lost a few hours today chasing up why the matcher does not work. Even if it does not work when using the correct syntax I find this library very, very use full. Thank you for any ones effort in its creation.

@radekg1000
Copy link
Author

radekg1000 commented Jan 16, 2019

These files (in C++) contain native linux programs to verify simple regular expression.
regme_with_digit.txt
regme_without_digit.txt

@radekg1000
Copy link
Author

Run this as a proof:

TEST(Matcher, general)
{
    EXPECT_THAT("1", MatchesRegex("\\d"));  // <- this line is failing
    EXPECT_THAT("1", MatchesRegex("[0-9]"));
}

Result:

00:37:12: Debugging starts
Note: Google Test filter = Matcher*
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from Matcher
[ RUN      ] Matcher.general
/home/radek/Projects/super-hat/test/src/model/streaminglivedata/streaminglivedataformatter_test.cpp:76: Failure
Value of: "1"
Expected: matches regular expression "\\d"
  Actual: "1" (of type char [2])
[  FAILED  ] Matcher.general (0 ms)
[----------] 1 test from Matcher (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (0 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] Matcher.general

 1 FAILED TEST

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant