diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-28 23:00:10 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-28 23:00:10 +0200 |
commit | 974a1c99ce30e20a0353e5ba7623e46164d88640 (patch) | |
tree | 6cf7a19ef663b802eba1fadcb272d83c289e4995 /bytesconv_test.go | |
parent | Added timing test for AppendUint (diff) | |
download | fasthttp-974a1c99ce30e20a0353e5ba7623e46164d88640.tar.gz fasthttp-974a1c99ce30e20a0353e5ba7623e46164d88640.tar.bz2 fasthttp-974a1c99ce30e20a0353e5ba7623e46164d88640.zip |
Optimized AppendUint by using stack-based buffer instead of uintBufPool
Diffstat (limited to 'bytesconv_test.go')
-rw-r--r-- | bytesconv_test.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/bytesconv_test.go b/bytesconv_test.go index bbf4d41..8ccae8b 100644 --- a/bytesconv_test.go +++ b/bytesconv_test.go @@ -3,6 +3,7 @@ package fasthttp import ( "bufio" "bytes" + "fmt" "testing" "time" ) @@ -14,6 +15,14 @@ func TestWriteHexInt(t *testing.T) { testWriteHexInt(t, 0x7fffffff, "7fffffff") } +func testAppendUint(t *testing.T, n int) { + expectedS := fmt.Sprintf("%d", n) + s := AppendUint(nil, n) + if string(s) != expectedS { + t.Fatalf("unexpected uint %q. Expecting %q. n=%d", s, expectedS, n) + } +} + func testWriteHexInt(t *testing.T, n int, expectedS string) { var w bytes.Buffer bw := bufio.NewWriter(&w) |