Closed qrutyy closed 9 months ago
If I'm understanding you correctly, you are attempting to read from stdin and then use it in an assertion? If so, I have two pieces of feedback:
(1) Philosophical - This is probably a poor practice. stdin will change every time you run your unit tests and relies on outside data to be entered, making your unit tests far less useful. It'd be better to read something in with stdin and then pass it to a function which does the real work... you can test that function by injecting const strings instead.
(2) If you DO find that this is necessary, I'd use strncpy to copy the stdin input string into an array and then use TEST_ASSERT_EQUAL_STRING
to do the comparison.
Thank you for your reply!
I looked through the documentation and haven't found it to be mentioned. I tried to compare by reading a line and storing it, but the output was '' (using string compare) and 0x00 using memory assertion. So i thought that framework is blocking the stdin.
Am i right? And how to compare them if it is possible?