nanomsg.org/go/mangos/v2@v2.0.9-0.20200203084354-8a092611e461/protocol/pair/pair_test.go (about) 1 /* 2 * Copyright 2019 The Mangos Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use file except in compliance with the License. 6 * You may obtain a copy of the license at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 package pair 19 20 import ( 21 "testing" 22 23 "nanomsg.org/go/mangos/v2" 24 25 . "nanomsg.org/go/mangos/v2/internal/test" 26 _ "nanomsg.org/go/mangos/v2/transport/inproc" 27 ) 28 29 func TestPairIdentity(t *testing.T) { 30 s, e := NewSocket() 31 MustSucceed(t, e) 32 id := s.Info() 33 MustBeTrue(t, id.Self == mangos.ProtoPair) 34 MustBeTrue(t, id.Peer == mangos.ProtoPair) 35 MustBeTrue(t, id.SelfName == "pair") 36 MustBeTrue(t, id.PeerName == "pair") 37 MustSucceed(t, s.Close()) 38 } 39 40 func TestPairCooked(t *testing.T) { 41 VerifyCooked(t, NewSocket) 42 } 43 44 func TestPairClosed(t *testing.T) { 45 VerifyClosedSend(t, NewSocket) 46 VerifyClosedRecv(t, NewSocket) 47 VerifyClosedClose(t, NewSocket) 48 VerifyClosedDial(t, NewSocket) 49 VerifyClosedListen(t, NewSocket) 50 VerifyClosedAddPipe(t, NewSocket) 51 } 52 53 func TestPairOptions(t *testing.T) { 54 VerifyInvalidOption(t, NewSocket) 55 VerifyOptionDuration(t, NewSocket, mangos.OptionRecvDeadline) 56 VerifyOptionDuration(t, NewSocket, mangos.OptionSendDeadline) 57 VerifyOptionInt(t, NewSocket, mangos.OptionReadQLen) 58 VerifyOptionInt(t, NewSocket, mangos.OptionWriteQLen) 59 VerifyOptionBool(t, NewSocket, mangos.OptionBestEffort) 60 }