]> Cypherpunks repositories - gostls13.git/commit
encoding/xml: improve the test coverage, fix minor bugs
authorIskander Sharipov <quasilyte@gmail.com>
Wed, 17 Nov 2021 14:46:22 +0000 (17:46 +0300)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 4 Mar 2022 20:29:47 +0000 (20:29 +0000)
commite79c39f004769fc55e60c2fb052155486295d533
tree575f9c83b4a00b32a6fbe1de84dc537f4f12b8d3
parent2b8aa2b734721487bb718ee5fb6080f51b57efd9
encoding/xml: improve the test coverage, fix minor bugs

Improve the test coverage of encoding/xml package by adding
the test cases for the execution paths that were not covered before.

Since it reveals a couple of issues, fix them as well while we're at it.

As I used an `strings.EqualFold` instead of adding one more `strings.ToLower`,
our fix to `autoClose()` tends to run faster as well as a result.

name             old time/op    new time/op    delta
HTMLAutoClose-8    5.93µs ± 2%    5.75µs ± 3%  -3.16%  (p=0.000 n=10+10)
name             old alloc/op   new alloc/op   delta
HTMLAutoClose-8    2.60kB ± 0%    2.58kB ± 0%  -0.46%  (p=0.000 n=10+10)
name             old allocs/op  new allocs/op  delta
HTMLAutoClose-8      72.0 ± 0%      67.0 ± 0%  -6.94%  (p=0.000 n=10+10)

The overall `encoding/xml` test coverage increase is `88.1% -> 89.9%`;
although it may look insignificant, this CL covers some important corner cases,
like `autoClose()` functionality (that was not tested at all).

Fixes #49635
Fixes #49636

Change-Id: I50b2769896c197eb285672313b7148f4fe8bdb38
Reviewed-on: https://go-review.googlesource.com/c/go/+/364734
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/encoding/xml/xml.go
src/encoding/xml/xml_test.go