go.dedis.ch/onet/v4@v4.0.0-pre1/simul/build_test.go (about)

     1  package simul
     2  
     3  import (
     4  	"strconv"
     5  	"testing"
     6  
     7  	"go.dedis.ch/onet/v4/simul/platform"
     8  )
     9  
    10  func TestDepth(t *testing.T) {
    11  	testStruct := []struct{ BF, depth, hosts int }{
    12  		{1, 1, 2},
    13  		{2, 1, 3},
    14  		{3, 1, 4},
    15  		{3, 2, 13},
    16  		{4, 1, 5},
    17  		{4, 2, 21},
    18  		{5, 1, 6},
    19  		{5, 2, 31},
    20  		{5, 3, 156},
    21  	}
    22  	for _, s := range testStruct {
    23  		rc := platform.NewRunConfig()
    24  		rc.Put("bf", strconv.Itoa(s.BF))
    25  		rc.Put("depth", strconv.Itoa(s.depth))
    26  
    27  		rc.Put("hosts", "0")
    28  		CheckHosts(rc)
    29  		hosts, _ := rc.GetInt("hosts")
    30  		if hosts != s.hosts {
    31  			t.Fatal(s, "gave hosts:", hosts)
    32  		}
    33  
    34  		rc.Put("bf", "0")
    35  		CheckHosts(rc)
    36  		bf, _ := rc.GetInt("bf")
    37  		if bf != s.BF {
    38  			t.Fatal(s, "gave BF:", bf)
    39  		}
    40  
    41  		rc.Put("depth", "0")
    42  		CheckHosts(rc)
    43  		depth, _ := rc.GetInt("depth")
    44  		if depth != s.depth {
    45  			t.Fatal(s, "gave depth:", bf)
    46  		}
    47  	}
    48  }