fiber/redirect_msgp_test.go
RW c2eee63183
🧹 chore: Update minimum go version to 1.24 (#3481)
* chore: update docs and workflows for go1.24

* Fix listen bug

* Use b.Loop() for benchmarks https://go.dev/blog/testing-b-loop

* Use b.Loop() for benchmarks https://go.dev/blog/testing-b-loop

* Revert b.Loop() for some benchmarks

* Change genericParser benchmarks (runParallel)

* Change Benchmark_Router_Github_API benchmarks (runParallel)
2025-05-27 13:23:02 +02:00

227 lines
4.3 KiB
Go

package fiber
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
import (
"bytes"
"testing"
"github.com/tinylib/msgp/msgp"
)
func TestMarshalUnmarshalredirectionMsg(t *testing.T) {
v := redirectionMsg{}
bts, err := v.MarshalMsg(nil)
if err != nil {
t.Fatal(err)
}
left, err := v.UnmarshalMsg(bts)
if err != nil {
t.Fatal(err)
}
if len(left) > 0 {
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
}
left, err = msgp.Skip(bts)
if err != nil {
t.Fatal(err)
}
if len(left) > 0 {
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
}
}
func BenchmarkMarshalMsgredirectionMsg(b *testing.B) {
v := redirectionMsg{}
b.ReportAllocs()
for b.Loop() {
v.MarshalMsg(nil)
}
}
func BenchmarkAppendMsgredirectionMsg(b *testing.B) {
v := redirectionMsg{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalMsg(bts[0:0])
b.SetBytes(int64(len(bts)))
b.ReportAllocs()
for b.Loop() {
bts, _ = v.MarshalMsg(bts[0:0])
}
}
func BenchmarkUnmarshalredirectionMsg(b *testing.B) {
v := redirectionMsg{}
bts, _ := v.MarshalMsg(nil)
b.ReportAllocs()
b.SetBytes(int64(len(bts)))
for b.Loop() {
_, err := v.UnmarshalMsg(bts)
if err != nil {
b.Fatal(err)
}
}
}
func TestEncodeDecoderedirectionMsg(t *testing.T) {
v := redirectionMsg{}
var buf bytes.Buffer
msgp.Encode(&buf, &v)
m := v.Msgsize()
if buf.Len() > m {
t.Log("WARNING: TestEncodeDecoderedirectionMsg Msgsize() is inaccurate")
}
vn := redirectionMsg{}
err := msgp.Decode(&buf, &vn)
if err != nil {
t.Error(err)
}
buf.Reset()
msgp.Encode(&buf, &v)
err = msgp.NewReader(&buf).Skip()
if err != nil {
t.Error(err)
}
}
func BenchmarkEncoderedirectionMsg(b *testing.B) {
v := redirectionMsg{}
var buf bytes.Buffer
msgp.Encode(&buf, &v)
b.SetBytes(int64(buf.Len()))
en := msgp.NewWriter(msgp.Nowhere)
b.ReportAllocs()
for b.Loop() {
v.EncodeMsg(en)
}
en.Flush()
}
func BenchmarkDecoderedirectionMsg(b *testing.B) {
v := redirectionMsg{}
var buf bytes.Buffer
msgp.Encode(&buf, &v)
b.SetBytes(int64(buf.Len()))
rd := msgp.NewEndlessReader(buf.Bytes(), b)
dc := msgp.NewReader(rd)
b.ReportAllocs()
for b.Loop() {
err := v.DecodeMsg(dc)
if err != nil {
b.Fatal(err)
}
}
}
func TestMarshalUnmarshalredirectionMsgs(t *testing.T) {
v := redirectionMsgs{}
bts, err := v.MarshalMsg(nil)
if err != nil {
t.Fatal(err)
}
left, err := v.UnmarshalMsg(bts)
if err != nil {
t.Fatal(err)
}
if len(left) > 0 {
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
}
left, err = msgp.Skip(bts)
if err != nil {
t.Fatal(err)
}
if len(left) > 0 {
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
}
}
func BenchmarkMarshalMsgredirectionMsgs(b *testing.B) {
v := redirectionMsgs{}
b.ReportAllocs()
for b.Loop() {
v.MarshalMsg(nil)
}
}
func BenchmarkAppendMsgredirectionMsgs(b *testing.B) {
v := redirectionMsgs{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalMsg(bts[0:0])
b.SetBytes(int64(len(bts)))
b.ReportAllocs()
for b.Loop() {
bts, _ = v.MarshalMsg(bts[0:0])
}
}
func BenchmarkUnmarshalredirectionMsgs(b *testing.B) {
v := redirectionMsgs{}
bts, _ := v.MarshalMsg(nil)
b.ReportAllocs()
b.SetBytes(int64(len(bts)))
for b.Loop() {
_, err := v.UnmarshalMsg(bts)
if err != nil {
b.Fatal(err)
}
}
}
func TestEncodeDecoderedirectionMsgs(t *testing.T) {
v := redirectionMsgs{}
var buf bytes.Buffer
msgp.Encode(&buf, &v)
m := v.Msgsize()
if buf.Len() > m {
t.Log("WARNING: TestEncodeDecoderedirectionMsgs Msgsize() is inaccurate")
}
vn := redirectionMsgs{}
err := msgp.Decode(&buf, &vn)
if err != nil {
t.Error(err)
}
buf.Reset()
msgp.Encode(&buf, &v)
err = msgp.NewReader(&buf).Skip()
if err != nil {
t.Error(err)
}
}
func BenchmarkEncoderedirectionMsgs(b *testing.B) {
v := redirectionMsgs{}
var buf bytes.Buffer
msgp.Encode(&buf, &v)
b.SetBytes(int64(buf.Len()))
en := msgp.NewWriter(msgp.Nowhere)
b.ReportAllocs()
for b.Loop() {
v.EncodeMsg(en)
}
en.Flush()
}
func BenchmarkDecoderedirectionMsgs(b *testing.B) {
v := redirectionMsgs{}
var buf bytes.Buffer
msgp.Encode(&buf, &v)
b.SetBytes(int64(buf.Len()))
rd := msgp.NewEndlessReader(buf.Bytes(), b)
dc := msgp.NewReader(rd)
b.ReportAllocs()
for b.Loop() {
err := v.DecodeMsg(dc)
if err != nil {
b.Fatal(err)
}
}
}