github.com/gorgonia/agogo@v0.1.1/mcts/unsafe_test.go (about)

     1  package mcts
     2  
     3  import "testing"
     4  
     5  func TestUnsafe(t *testing.T) {
     6  	tree := &MCTS{}
     7  	ptr := ptrFromTree(tree)
     8  	if ptr == 0 {
     9  		t.Fatal("Impossible to get 0x0 from a valid tree")
    10  	}
    11  	tree2 := treeFromUintptr(ptr)
    12  	if tree2 != tree {
    13  		t.Fatal("Expected the same pointer for trees")
    14  	}
    15  
    16  	ptr = ptrFromTree(nil)
    17  	if ptr != 0x0 {
    18  		t.Fatal("Must get 0x0 from a nil tree")
    19  	}
    20  
    21  	tree2 = treeFromUintptr(0x0)
    22  	if tree2 != nil {
    23  		t.Fatal("tree2 has to be nil")
    24  	}
    25  }