gopkg.in/dedis/onet.v2@v2.0.0-20181115163211-c8f3724038a7/simul/build_test.go (about)

     1  package simul
     2  
     3  import (
     4  	"strconv"
     5  	"testing"
     6  
     7  	"gopkg.in/dedis/onet.v2/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  		CheckHosts(rc)
    27  		hosts, _ := rc.GetInt("hosts")
    28  		if hosts != s.hosts {
    29  			t.Fatal(s, "gave hosts:", hosts)
    30  		}
    31  		rc.Put("bf", "0")
    32  		CheckHosts(rc)
    33  		bf, _ := rc.GetInt("bf")
    34  		if bf != s.BF {
    35  			t.Fatal(s, "gave BF:", bf)
    36  		}
    37  		rc.Put("depth", "0")
    38  		CheckHosts(rc)
    39  		depth, _ := rc.GetInt("depth")
    40  		if depth != s.depth {
    41  			t.Fatal(s, "gave depth:", bf)
    42  		}
    43  	}
    44  }