github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/opbench/config_test.go (about) 1 // Copyright 2019 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package opbench 12 13 import ( 14 "reflect" 15 "testing" 16 ) 17 18 func TestConfigIterator(t *testing.T) { 19 check := func(cs []Options, expected []string) { 20 ci := NewConfigIterator(&Spec{ 21 Inputs: cs, 22 }) 23 24 var res []string 25 c, ok := ci.Next() 26 for ok { 27 res = append(res, c.String()) 28 c, ok = ci.Next() 29 } 30 31 if !reflect.DeepEqual(res, expected) { 32 t.Fatalf("expected %#v, got %#v", expected, res) 33 } 34 } 35 36 check([]Options{ 37 {"a", []float64{1, 2, 3}}, 38 {"b", []float64{4, 5}}, 39 }, []string{ 40 "a=1/b=4", 41 "a=2/b=4", 42 "a=3/b=4", 43 "a=1/b=5", 44 "a=2/b=5", 45 "a=3/b=5", 46 }) 47 48 check([]Options{}, []string{""}) 49 50 check([]Options{ 51 {"a", []float64{1}}, 52 {"b", []float64{10}}, 53 }, []string{"a=1/b=10"}) 54 }