jdh-8
jdh-8 copied to clipboard
[WSL2] strstr assertion fails due to \n and \r\n file encoding
Expected behaviour
The following assertion should work on a Windows file format: test/test.c:78 --
assert(strstr(str, "; TEST\n") == str);
Current behaviour
The assertion fails because \n != \r\n
on Windows file formats, which include a carriage return.
Possible solution
Add check for carriage return using the 'or' operator, such as:
assert(strstr(str, "; TEST\n") == str || strstr(str, "; TEST\r\n") == str);
Steps to reproduce
- Clone repo into a Windows directory
- Build on WSL
- Execute
$ ./bin/test
- Assertion fails
Host OS: Windows 10 Pro x86_64 21H2 19044.1706 Guest OS: WSL2 Ubuntu 20.04 x86_64 Guest kernel: 5.10.16.3-microsoft-standard-WSL2