Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run tests with std::istringstream,std::ifstream, buffer and file input #261

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

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
@@ -77,17 +93,39 @@ static void testcase(const std::string &name, void (*f)(), int argc, char * cons

#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 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 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
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