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

[printf] Test empty format string, and empty arg string #2018

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test_conformance/printf/util_printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,12 @@ testCase testCaseChar = {

std::vector<printDataGenParameters> printStringGenParameters = {

// empty format
{ {""}, "\"foo\"" },
Copy link
Member

Choose a reason for hiding this comment

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

This results in a printf call with an excess data argument (printf("\n","foo");), but that should be fine according to the spec:

If the format is exhausted while arguments remain, the excess arguments are evaluated (as always) but are otherwise ignored.


// empty argument
{ {"%s"}, "\"\"" },

//(Minimum)Four-wide,zero-filled,default(right)-justified

{ { "%4s" }, "\"foo\"" },
Expand Down Expand Up @@ -766,6 +772,10 @@ std::vector<printDataGenParameters> printStringGenParameters = {

std::vector<std::string> correctBufferString = {

"",

"",

" foo",

"f",
Expand Down
Loading