Skip to content

Conversation

@firewave
Copy link
Collaborator

No description provided.

@firewave firewave changed the title test.cpp: run tests with std::istringstream and std::ifstream run tests with std::istringstream and std::ifstream Apr 20, 2022
@firewave firewave changed the title run tests with std::istringstream and std::ifstream run tests with std::istringstream and std::ifstream Apr 20, 2022
test.cpp Outdated

#define TEST_CASE(F) (testcase(#F, F, argc, argv))

static std::string writeFile(const char code[], std::size_t size, const std::string &filename) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that it's a good idea to avoid using real files in tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I totally agree with you. But we allow the input of actual files so we should actually test this.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still feel skeptic. if we assume that the stream input is bug free then the test should work the same with a string input or a file. if we extrapolate this then this should be done in cppcheck also. I fear I don't like this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply.

Keeping tests simple is great but I think there should be proper coverage and historically that is something we don't have in either Cppcheck or simplecpp. 😐

Also all the include files are always being read from the disk and not from memory. Not having any tests which rely on temporary files indicates that there is no coverage for reading includes at all. I have not looked into this yet.

So it seems instead of avoiding tests with files on disk we actually need to add much more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having some system test that uses files is good but we do have some such system tests. Testing that APIs work as they should is out of scope.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this I am not able to test the changes in #244. If that is fine with you I will try to finish up that PR without any unit tests.

I will prepare another PR to highlight with more tests to highlight the underlying testing issue.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is fine with you I will try to finish up that PR without any unit tests.

yes I would prefer that in this case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.

After thinking about it a bit more the usage with Cppcheck could be considered an integration test.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it's more like a integration test.

@firewave firewave marked this pull request as draft October 20, 2022 12:58
@firewave firewave changed the title run tests with std::istringstream and std::ifstream run tests with std::istringstream,std::ifstream and file input Mar 21, 2023
@firewave firewave changed the title run tests with std::istringstream,std::ifstream and file input run tests with std::istringstream,std::ifstream,std::string and file input Mar 28, 2024
@firewave firewave force-pushed the test-x branch 2 times, most recently from 5d99779 to b196f5b Compare March 29, 2024 18:13
@firewave firewave changed the title run tests with std::istringstream,std::ifstream,std::string and file input run tests with std::istringstream,std::ifstream, buffer and file input Mar 29, 2024
@firewave
Copy link
Collaborator Author

This could be implemented in the Python tests instead by making this modes available via simplecpp (as already is via -is). That would require to parameterize each invocation but I am not sure how to do this. @Tal500 any idea?

@firewave
Copy link
Collaborator Author

Thinking about it I think this is still valid except for the file input.

@firewave firewave force-pushed the test-x branch 4 times, most recently from 929222a to 07a2beb Compare January 15, 2026 10:09
@firewave firewave changed the title run tests with std::istringstream,std::ifstream, buffer and file input test.cpp: also run tests with char buffer Jan 15, 2026
@firewave
Copy link
Collaborator Author

I removed everything which generates a file.

I will add flags to the CLI to be able to use those in the Python tests but that won't have the same coverage as using it in the unit tests and might detect some issues only as in drive-by way (as experienced in #566).

@firewave firewave force-pushed the test-x branch 2 times, most recently from 447bb72 to 90e5701 Compare January 15, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants