FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test.cpp: also run tests with char buffer by firewave · Pull Request #261 · cppcheck-opensource/simplecpp · GitHub

test.cpp: also run tests with char buffer - #261

Merged
firewave merged 3 commits into
cppcheck-opensource:masterfrom
firewave:test-x
Apr 16, 2026
Merged

test.cpp: also run tests with char buffer#261
firewave merged 3 commits into
cppcheck-opensource:masterfrom
firewave:test-x

Conversation

Copy link
Copy Markdown
Collaborator

No description provided.

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 changed the title run tests with std::istringstream and std::ifstream run tests with std::istringstream and std::ifstream Apr 20, 2022
Comment thread 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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Great.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

yes it's more like a integration test.

firewave marked this pull request as draft October 20, 2022 12:58
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 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 force-pushed the test-x branch 2 times, most recently from 5d99779 to b196f5b Compare March 29, 2024 18:13
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

Copy link
Copy Markdown
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?

Copy link
Copy Markdown
Collaborator Author

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

firewave force-pushed the test-x branch 4 times, most recently from 929222a to 07a2beb Compare January 15, 2026 10:09
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

Copy link
Copy Markdown
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).

Tal500 commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Collaborator Author

sorry for the very late reply. see

No problem at all. Thanks for replying.

https://github.com/danmar/simplecpp/blob/10c96815e402299da1d3ab1f753dda4c1b0b12f8/integration_test.py#L37-L39

I do get have parameterizing works but this requires every simplecpp call to gain an additional parameter so this needs needs something global. Possibly requiring a fixture (or whatever it is called in Python).

BTW I moved that to #625.

firewave marked this pull request as ready for review April 13, 2026 11:36
firewave merged commit 316d4ee into cppcheck-opensource:master Apr 16, 2026
24 checks passed
firewave deleted the test-x branch April 16, 2026 22:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL