github.com/Yeicor/sdf-viewer-go/sdf-viewer-go@v0.0.0-20220827152733-64b36e48c502/test.go (about)

     1  package sdf_viewer_go
     2  
     3  import (
     4  	"strconv"
     5  	"testing"
     6  )
     7  
     8  func TestImpl(_ *testing.T, s SDF) {
     9  	// Configure the root SDF
    10  	SetRootSDF(s)
    11  
    12  	// Test that operations on root and ALL descendant nodes don't panic
    13  	for childID := range availableSDFs {
    14  		testSubSDF(childID, 1)
    15  	}
    16  
    17  	// TODO: More and better tests
    18  }
    19  
    20  func BenchmarkImpl(t *testing.B, s SDF) {
    21  	// Configure the root SDF
    22  	SetRootSDF(s)
    23  
    24  	// Test that operations on root and ALL descendant nodes don't panic
    25  	for childID := range availableSDFs {
    26  		t.Run("Child#"+strconv.Itoa(int(childID)), func(b *testing.B) {
    27  			testSubSDF(childID, b.N)
    28  		})
    29  	}
    30  
    31  	// TODO: More and better tests
    32  }
    33  
    34  func testSubSDF(childID uint32, times int) {
    35  	for i := 0; i < times; i++ {
    36  		bounding_box(childID)
    37  		sample(childID, [3]float32{0, 0, 0}, false)
    38  		children(childID)
    39  		//for _, child := range getSDFOrPanic(childID).Children() {
    40  		//	// NOTE: Printing with %v is not supported by tinygo: https://github.com/tinygo-org/tinygo/issues/2983
    41  		//	fmt.Printf("Children[%d]: %s\n", childID, child.Name())
    42  		//}
    43  		parameters(childID)
    44  		changed(childID)
    45  	}
    46  }