github.com/devops-filetransfer/sshego@v7.0.4+incompatible/cli_gen_test.go (about) 1 package sshego 2 3 // NOTE: THIS FILE WAS PRODUCED BY THE 4 // GREENPACK CODE GENERATION TOOL (github.com/glycerine/greenpack) 5 // DO NOT EDIT 6 7 import ( 8 "bytes" 9 "testing" 10 11 "github.com/glycerine/greenpack/msgp" 12 ) 13 14 func TestMarshalUnmarshalKeepAlivePing(t *testing.T) { 15 v := KeepAlivePing{} 16 bts, err := v.MarshalMsg(nil) 17 if err != nil { 18 t.Fatal(err) 19 } 20 left, err := v.UnmarshalMsg(bts) 21 if err != nil { 22 t.Fatal(err) 23 } 24 if len(left) > 0 { 25 t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) 26 } 27 28 left, err = msgp.Skip(bts) 29 if err != nil { 30 t.Fatal(err) 31 } 32 if len(left) > 0 { 33 t.Errorf("%d bytes left over after Skip(): %q", len(left), left) 34 } 35 } 36 37 func BenchmarkMarshalMsgKeepAlivePing(b *testing.B) { 38 v := KeepAlivePing{} 39 b.ReportAllocs() 40 b.ResetTimer() 41 for i := 0; i < b.N; i++ { 42 v.MarshalMsg(nil) 43 } 44 } 45 46 func BenchmarkAppendMsgKeepAlivePing(b *testing.B) { 47 v := KeepAlivePing{} 48 bts := make([]byte, 0, v.Msgsize()) 49 bts, _ = v.MarshalMsg(bts[0:0]) 50 b.SetBytes(int64(len(bts))) 51 b.ReportAllocs() 52 b.ResetTimer() 53 for i := 0; i < b.N; i++ { 54 bts, _ = v.MarshalMsg(bts[0:0]) 55 } 56 } 57 58 func BenchmarkUnmarshalKeepAlivePing(b *testing.B) { 59 v := KeepAlivePing{} 60 bts, _ := v.MarshalMsg(nil) 61 b.ReportAllocs() 62 b.SetBytes(int64(len(bts))) 63 b.ResetTimer() 64 for i := 0; i < b.N; i++ { 65 _, err := v.UnmarshalMsg(bts) 66 if err != nil { 67 b.Fatal(err) 68 } 69 } 70 } 71 72 func TestEncodeDecodeKeepAlivePing(t *testing.T) { 73 v := KeepAlivePing{} 74 var buf bytes.Buffer 75 msgp.Encode(&buf, &v) 76 77 m := v.Msgsize() 78 if buf.Len() > m { 79 t.Logf("WARNING: Msgsize() for %v is inaccurate", v) 80 } 81 82 vn := KeepAlivePing{} 83 err := msgp.Decode(&buf, &vn) 84 if err != nil { 85 t.Error(err) 86 } 87 88 buf.Reset() 89 msgp.Encode(&buf, &v) 90 err = msgp.NewReader(&buf).Skip() 91 if err != nil { 92 t.Error(err) 93 } 94 } 95 96 func BenchmarkEncodeKeepAlivePing(b *testing.B) { 97 v := KeepAlivePing{} 98 var buf bytes.Buffer 99 msgp.Encode(&buf, &v) 100 b.SetBytes(int64(buf.Len())) 101 en := msgp.NewWriter(msgp.Nowhere) 102 b.ReportAllocs() 103 b.ResetTimer() 104 for i := 0; i < b.N; i++ { 105 v.EncodeMsg(en) 106 } 107 en.Flush() 108 } 109 110 func BenchmarkDecodeKeepAlivePing(b *testing.B) { 111 v := KeepAlivePing{} 112 var buf bytes.Buffer 113 msgp.Encode(&buf, &v) 114 b.SetBytes(int64(buf.Len())) 115 rd := msgp.NewEndlessReader(buf.Bytes(), b) 116 dc := msgp.NewReader(rd) 117 b.ReportAllocs() 118 b.ResetTimer() 119 for i := 0; i < b.N; i++ { 120 err := v.DecodeMsg(dc) 121 if err != nil { 122 b.Fatal(err) 123 } 124 } 125 }