Skip to content

fmt: add TestCustomFormatterVerbEdgeCase for custom formatting verifi… - #82432

Open
RyanXi11 wants to merge 1 commit into
golang:masterfrom
RyanXi11:master
Open

RyanXi11 wants to merge 1 commit into
golang:masterfrom
RyanXi11:master

Conversation

@RyanXi11

Copy link
Copy Markdown

…cation

This PR will be imported into Gerrit with the title and first
comment (this text) used to generate the subject and body of
the Gerrit change.

Please ensure you adhere to every item in this list.

More info can be found at https://go.dev/wiki/CommitMessage

  • The PR title is formatted as follows: net/http: frob the quux before blarfing
    • The package name goes before the colon
    • The part after the colon uses the verb tense + phrase that completes the blank in,
      "This change modifies Go to ___________"
    • Lowercase verb after the colon
    • No trailing period
    • Keep the title as short as possible, ideally 72 characters or shorter
  • No Markdown
  • The first PR comment (this one) is wrapped at around 72 characters, unless it's
    really needed (ASCII art, table, or long link)
  • If there is a corresponding issue, add either Fixes #1234 or Updates #1234
    (the latter if this is not a complete fix) to this comment
  • If referring to a repo other than golang/go you can use the
    owner/repo#issue_number syntax: Fixes golang/vscode-go#1234
  • We do not use Signed-off-by lines in Go. Please don't add them.
    Our Gerrit server & GitHub bots enforce CLA compliance instead.
  • Delete these instructions once you have read and applied them

@google-cla

google-cla Bot commented Oct 22, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ege-arhan ege-arhan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new test in src/fmt/fmt_test.go is not gofmted, so all.bash/the fmt CI shard will fail before the test can report anything:

$ gofmt -d src/fmt/fmt_test.go
@@ -2044,9 +2044,9 @@
-    got := Sprintf("[%v]", "test-edge-case")
-    want := "[test-edge-case]"
-    if got != want {
-        t.Errorf("Sprintf edge case failed: got %q, want %q", got, want)
-    }
+	got := Sprintf("[%v]", "test-edge-case")
...

The file also lacks the trailing newline (the diff ends with \ No newline at end of file).

Beyond formatting: fmt.Sprintf("[%v]", "test-edge-case") is already covered by the fmtTests table ({"[%v]", []any{"hi"}, "[hi]"} and friends), so the assertion cannot fail for any implementation that passes the existing table, including a deliberately broken %v. A test for the described scenario ("malformed verb wrapping") needs input that the table does not already pin, and it belongs in the table as a new entry rather than a standalone Test* function. Sprintf is also referenced without the fmt. qualifier — that only compiles inside package fmt, not in fmt_test.go (package fmt_test).

Also please drop the unedited PR template text in the description, per CONTRIBUTING.md.

@ege-arhan

Copy link
Copy Markdown

Correction to my previous comment: Sprintf without the package qualifier is fine here — src/fmt/fmt_test.go dot-imports fmt (. "fmt"), so that part of my note was wrong.

The rest stands: the trailing-newline/gofmt failure is real (gofmt -d on the added hunk shows the space-indentation diff), and the assertion duplicates an existing fmtTests entry, so it cannot catch the regression the commit message describes.

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