trpc.group/trpc-go/trpc-go@v1.0.3/transport/internal/frame/frame_test.go (about) 1 // 2 // 3 // Tencent is pleased to support the open source community by making tRPC available. 4 // 5 // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 // All rights reserved. 7 // 8 // If you have downloaded a copy of the tRPC source code from Tencent, 9 // please note that tRPC source code is licensed under the Apache 2.0 License, 10 // A copy of the Apache 2.0 License is included in this file. 11 // 12 // 13 14 package frame_test 15 16 import ( 17 "testing" 18 19 "trpc.group/trpc-go/trpc-go/transport/internal/frame" 20 ) 21 22 func TestShouldCopy(t *testing.T) { 23 type args struct { 24 isCopyOption bool 25 serverAsync bool 26 isSafeFramer bool 27 } 28 tests := []struct { 29 name string 30 args args 31 want bool 32 }{ 33 {"is safe framer: not copy", args{false, false, true}, false}, 34 {"not safe framer, sync mod, option not copy: not copy", args{false, false, false}, false}, 35 {"not safe framer, sync mod, option copy: copy", args{true, false, false}, true}, 36 {"not safe framer, async mod, option not copy: copy", args{false, true, false}, true}, 37 {"not safe framer, async mod, option copy: copy", args{true, true, false}, true}, 38 } 39 for _, tt := range tests { 40 t.Run(tt.name, func(t *testing.T) { 41 if got := frame.ShouldCopy( 42 tt.args.isCopyOption, 43 tt.args.serverAsync, 44 tt.args.isSafeFramer, 45 ); got != tt.want { 46 t.Errorf("ShouldCopy() = %v, want %v", got, tt.want) 47 } 48 }) 49 } 50 }