github.com/pion/dtls/v2@v2.2.12/pkg/protocol/extension/server_name_test.go (about)

     1  // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
     2  // SPDX-License-Identifier: MIT
     3  
     4  package extension
     5  
     6  import "testing"
     7  
     8  func TestServerName(t *testing.T) {
     9  	extension := ServerName{ServerName: "test.domain"}
    10  
    11  	raw, err := extension.Marshal()
    12  	if err != nil {
    13  		t.Fatal(err)
    14  	}
    15  
    16  	newExtension := ServerName{}
    17  	err = newExtension.Unmarshal(raw)
    18  	if err != nil {
    19  		t.Fatal(err)
    20  	}
    21  
    22  	if newExtension.ServerName != extension.ServerName {
    23  		t.Errorf("extensionServerName marshal: got %s expected %s", newExtension.ServerName, extension.ServerName)
    24  	}
    25  }