Source file src/net/ipsock_plan9_test.go

     1  // Copyright 2020 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package net
     6  
     7  import "testing"
     8  
     9  func TestTCP4ListenZero(t *testing.T) {
    10  	l, err := Listen("tcp4", "0.0.0.0:0")
    11  	if err != nil {
    12  		t.Fatal(err)
    13  	}
    14  	defer l.Close()
    15  	if a := l.Addr(); isNotIPv4(a) {
    16  		t.Errorf("address does not contain IPv4: %v", a)
    17  	}
    18  }
    19  
    20  func TestUDP4ListenZero(t *testing.T) {
    21  	c, err := ListenPacket("udp4", "0.0.0.0:0")
    22  	if err != nil {
    23  		t.Fatal(err)
    24  	}
    25  	defer c.Close()
    26  	if a := c.LocalAddr(); isNotIPv4(a) {
    27  		t.Errorf("address does not contain IPv4: %v", a)
    28  	}
    29  }
    30  

View as plain text