github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/encoders_test.go (about) 1 // Copyright (C) 2021-2022 Talos, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package codecs 16 17 import ( 18 "testing" 19 ) 20 21 var channel = "aeron:udp?endpoint=localhost:20121" 22 var stream = int32(1001) 23 24 // Execute all the encoders as a sanity check 25 func TestEncoders(t *testing.T) { 26 marshaller := NewSbeGoMarshaller() 27 rangeChecking := true 28 29 packet, err := ConnectRequestPacket(marshaller, rangeChecking, 99, stream, channel) 30 if err != nil { 31 t.Log("ConnectRequestPacket() failed") 32 t.Fail() 33 } 34 if len(packet) != 62 { // Look for unexepected change 35 t.Logf("ConnectRequestPacket failed length check: %d", len(packet)) 36 t.Fail() 37 } 38 packet, err = StartRecordingRequest2Packet(marshaller, rangeChecking, 1234, 5678, stream, true, true, channel) 39 if err != nil { 40 t.Log("StartRecordingRequestPacket() failed") 41 t.Fail() 42 } 43 if len(packet) != 74 { // Look for unexpected change 44 t.Logf("StartRecordingRequestPacket() failed length check: %d", len(packet)) 45 t.Fail() 46 } 47 }