aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/base32/base32_test.go
AgeCommit message (Collapse)Author
2022-10-06all: remove redundant type conversioncui fliter
Change-Id: I375233dc700adbc58a6d4af995d07b352bf85b11 GitHub-Last-Rev: ef129205231b892f61b0135c87bb791a5e1a126c GitHub-Pull-Request: golang/go#55994 Reviewed-on: https://go-review.googlesource.com/c/go/+/437715 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2022-09-06encoding: use strings.Buildercuiweixie
Change-Id: Ib07699df8ea41fd8d1bca8ad050859fac24623de Reviewed-on: https://go-review.googlesource.com/c/go/+/428258 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-03encoding/base32: decoder output depends on chunking of underlying readerteivah
After an analysis, I figured that a way to do it could be to check, after the call to readEncodedData whether the decoder already saw the end or not. Fixes #38657 Change-Id: I06fd718ea4ee6ded2cb26c2866b28581ad86e271 GitHub-Last-Rev: d0b7bb38e4301a2ae9b8e588944488dbd88b39c4 GitHub-Pull-Request: golang/go#52631 Reviewed-on: https://go-review.googlesource.com/c/go/+/403315 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2021-12-13all: gofmt -w -r 'interface{} -> any' srcRuss Cox
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-09-11encoding/base32: increase performance and code reuseSven Taute
Add benchmarks for the Encode/Decode functions operating on []byte and increase decoding performance by removing the calls to strings.Map/bytes.Map and reusing the newline filtering code that is used by NewDecoder. Cut allocations in half for DecodeString. Comparison using the new benchmarks: name old time/op new time/op delta Encode 16.7µs ± 1% 17.0µs ± 2% +2.25% (p=0.000 n=9+9) EncodeToString 21.1µs ± 1% 20.9µs ± 1% -0.96% (p=0.000 n=10+10) Decode 141µs ± 1% 54µs ± 1% -61.51% (p=0.000 n=10+10) DecodeString 81.4µs ± 0% 54.7µs ± 1% -32.79% (p=0.000 n=9+10) name old speed new speed delta Encode 492MB/s ± 1% 481MB/s ± 2% -2.19% (p=0.000 n=9+9) EncodeToString 389MB/s ± 1% 392MB/s ± 1% +0.97% (p=0.000 n=10+10) Decode 93.0MB/s ± 1% 241.6MB/s ± 1% +159.82% (p=0.000 n=10+10) DecodeString 161MB/s ± 0% 240MB/s ± 1% +48.78% (p=0.000 n=9+10) Change-Id: Id53633514a9e14ecd0389d52114b2b8ca64370cb GitHub-Last-Rev: f4be3cf55caf5b89d76d14b7f32422faff39e3c3 GitHub-Pull-Request: golang/go#30376 Reviewed-on: https://go-review.googlesource.com/c/go/+/163598 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-06all: simplify code using "gofmt -s -w"Shulhan
Most changes are removing redundant declaration of type when direct instantiating value of map or slice, e.g. []T{T{}} become []T{{}}. Small changes are removing the high order of subslice if its value is the length of slice itself, e.g. T[:len(T)] become T[:]. The following file is excluded due to incompatibility with go1.4, - src/cmd/compile/internal/gc/ssa.go Change-Id: Id3abb09401795ce1e6da591a89749cba8502fb26 Reviewed-on: https://go-review.googlesource.com/c/go/+/166437 Run-TryBot: Dave Cheney <dave@cheney.net> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-02encoding/base32: remove ineffectual assignment in testLeon Klingele
Change-Id: I8aaa3d1d2797f3ace34bc09f5123538f6a77efce GitHub-Last-Rev: 2758c462041ff5e444651b7927d53e809d2efe4d GitHub-Pull-Request: golang/go#30009 Reviewed-on: https://go-review.googlesource.com/c/160433 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-26all: use strings.ReplaceAll and bytes.ReplaceAll where applicableBrad Fitzpatrick
I omitted vendor directories and anything necessary for bootstrapping. (Tested by bootstrapping with Go 1.4) Updates #27864 Change-Id: I7d9b68d0372d3a34dee22966cca323513ece7e8a Reviewed-on: https://go-review.googlesource.com/137856 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-16encoding/base32: handle NoPadding in NewDecoderGustav Westling
This change adds functionality to properly handle NoPadding in NewDecoder. Removes the following expectations when using NoPadding: * the input message length is a multiple of 8 * the input message length is 0, or longer than 7 characters Fixes #25332 Change-Id: I7c38160df23f7e8da4f85a5629530016e7bf71f3 GitHub-Last-Rev: 68ab8d2291df5c69e647620f8ef82cc90e06db28 GitHub-Pull-Request: golang/go#25394 Reviewed-on: https://go-review.googlesource.com/113215 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-09encoding/base32: handle NoPadding when using buffered encoding in CloseGustav Westling
This changes makes encoder.Close aware of how many bytes to write if there is any data left in the buffer. Fixes #25295 Change-Id: I4138891359935509cb561c453b8059ba2b9e576b GitHub-Last-Rev: f374096d2f3cae8635506074f59e1cd440c14844 GitHub-Pull-Request: golang/go#25316 Reviewed-on: https://go-review.googlesource.com/112515 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-09encoding/base32: handle surplus padding consistentlyGustav Westling
This changes decoder.Read to always return io.ErrUnexpectedEOF if the input contains surplus padding or unexpected content. Previously the error could be io.EOF or io.ErrUnexpectedEOF depending on how the input was chunked. Fixes #25296 Change-Id: I07c36c35e6c83e795c3991bfe45647a35aa58aa4 GitHub-Last-Rev: 818dfda90b0edf9fc415da4579c5810268c1cdba GitHub-Pull-Request: golang/go#25319 Reviewed-on: https://go-review.googlesource.com/112516 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-07-06encoding/base32: make NoPadding Encoding's DecodedLen return exact sizeGustav Westling
CL 47341 added support for decoding non-padded messages. But DecodedLen still returned a multiple of 5 for messages without a padding, even though it is possible to calculate the len exactly when using NoPadding. This change makes DecodedLen return the exact number of bytes that will be written. A change to the decoding logic is also made so that it can handle this case. DecodedLen now has the same behaviour as DecodedLen in encoding/base64. Fixes #20854 Change-Id: I729e0b1c0946c866fb675c854f835f366dd4b5a4 Reviewed-on: https://go-review.googlesource.com/47710 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-06encoding/base32: support custom and disabled padding when decodingGustav Westling
CL 38634 added support for custom (and disabled) padding characters when encoding, but didn't update the decoding paths. This adds decoding support. Fixes #20854 Change-Id: I9fb1a0aaebb27f1204c9f726a780d5784eb71024 Reviewed-on: https://go-review.googlesource.com/47341 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-16encoding: fix endless loop in TestDecoderBufferingMark Ryan
The ascii85, base32 and base64 packages all contain a test called TestDecoderBuffering. Each of these tests contain a loop that ignores the error returned from the Read method of their decoders. The result being that the tests loop for ever if the decoders actually return an error. This commit fixes the issue by terminating the loops if an error occurs and failing the tests with a suitable error message. Change-Id: Idb385673cf9f3f6f8befe4288b4be366ab0985fd Reviewed-on: https://go-review.googlesource.com/46010 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-15encoding: report correct line numbers in testsMark Ryan
Some of the _test.go files in the encoding packages contain a private function called testEqual that calls testing.Errorf if the arguments passed to it are unequal. The line numbers output by such calls to Errorf identify the failure as being in testEqual itself which is not very useful. This commit fixes the problem by adding a call to the new t.Helper method in each of the testEqual functions. The line numbers output when errors do occur now identify the real source of the error. Change-Id: I582d1934f40ef2b788116c3811074c67ea882021 Reviewed-on: https://go-review.googlesource.com/45871 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-22encoding/base32: add Encoding.WithPadding, StdPadding, NoPaddingGustav Westling
Fixes #19478 Change-Id: I9fc186610d79fd003e7b5d88c0955286ebe7d3cf Reviewed-on: https://go-review.googlesource.com/38634 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-18encoding/base32: ensure base32 decoder propagates errors correctlyMark Ryan
A number of issues in decoder.Read and newlineFilteringReader.Read were preventing errors from the reader supplying the encoded data from being propagated to the caller. Fixing these issues revealed some additional problems in which valid decoded data was not always returned to the user when errors were actually propagated. This commit fixes both the error propagation and the lost decoded data problems. It also adds some new unit tests to ensure errors are handled correctly by decoder.Read. The new unit tests increase the test coverage of this package from 96.2% to 97.9%. Fixes #20044 Change-Id: I1a8632da20135906e2d191c2a8825b10e7ecc4c5 Reviewed-on: https://go-review.googlesource.com/42094 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24all: fix typos and spellingMartin Möhrmann
Change-Id: Icd06d99c42b8299fd931c7da821e1f418684d913 Reviewed-on: https://go-review.googlesource.com/19829 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.