github.com/vmware/govmomi@v0.51.0/vim25/types/registry_test.go (about)

     1  // © Broadcom. All Rights Reserved.
     2  // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package types
     6  
     7  import (
     8  	"reflect"
     9  	"testing"
    10  )
    11  
    12  func TestTypeFunc(t *testing.T) {
    13  	var ok bool
    14  
    15  	fn := TypeFunc()
    16  
    17  	_, ok = fn("unknown")
    18  	if ok {
    19  		t.Errorf("Expected ok==false")
    20  	}
    21  
    22  	actual, ok := fn("UserProfile")
    23  	if !ok {
    24  		t.Errorf("Expected ok==true")
    25  	}
    26  
    27  	expected := reflect.TypeOf(UserProfile{})
    28  	if !reflect.DeepEqual(expected, actual) {
    29  		t.Errorf("Expected: %#v, actual: %#v", expected, actual)
    30  	}
    31  }