Exemple #1
0
// Helps me in generating test data for the range tests.
// Make sure you verify the data afterward. This saves me some typing.
func TestGenerateResultRangeTests(t *testing.T) {
	t.Skip("not needed.")

	tmpl, err := template.New("test").Parse(`
{{ range $_, $item := . }}
{"{{ $item.In }}", ResultRanges{
{{ range $_, $x := $item.Out }}{
  Gender:  {{ if $x.Gender }}stringp("{{ $x.Gender }}"){{ else }}nil{{ end }},
  AgeLow:  {{ if $x.AgeLow }}float64p({{ $x.AgeLow }}){{ else }}nil{{ end }},
  AgeHigh: {{ if $x.AgeHigh }}float64p({{ $x.AgeHigh }}){{ else }}nil{{ end }},
  Low:     {{ if $x.Low }}float64p({{ $x.Low }}){{ else }}nil{{ end }},
  High:    {{ if $x.High }}float64p({{ $x.High }}){{ else }}nil{{ end }},
  Text:    {{ if $x.Text }}stringp("{{ $x.Text }}"){{ else }}nil{{ end }},
},{{ end }}
}},{{ end }}`)
	if err != nil {
		panic(err)
	}

	for i, rt := range rangeTests {
		resultRanges := ccd.ResultRanges{}
		resultRanges.Parse(rt.In)
		rangeTests[i].Out = resultRanges
	}

	err = tmpl.Execute(os.Stdout, rangeTests)
	if err != nil {
		panic(err)
	}
}
Exemple #2
0
func TestResultRange(t *testing.T) {
	for _, rt := range rangeTests {
		resultRanges := ccd.ResultRanges{}
		resultRanges.Parse(rt.In)

		// Just set the OriginalText since it will always be the input.
		for i, _ := range rt.Out {
			rt.Out[i].OriginalText = rt.In
		}

		if !reflect.DeepEqual(rt.Out, resultRanges) {
			t.Fatal(spew.Printf("\ninput:    %v\nexpected: %v\ngot:      %v\n", rt.In, rt.Out, resultRanges))
		}

		_ = spew.Dump
		_ = goon.Dump
		_ = fmt.Println
	}

	//goon.Dump(rangeTests)
}