Esempio n. 1
0
func TestParsingEmptyConfigurationFile(t *testing.T) {
	opt, err := gopush.ReadOptions(strings.NewReader(""))
	if err != nil {
		t.Errorf("unexpected error while parsing configuration: %v", err)
	}

	defaultConfig := gopush.Options{
		AllowedInstructions:         make(map[string]struct{}),
		AllowedTypes:                make(map[string]struct{}),
		EvalPushLimit:               1000,
		MaxPointsInProgram:          100,
		MaxPointsInRandomExpression: 25,
		MaxRandomFloat:              1.0,
		MaxRandomInteger:            10,
		MinRandomFloat:              -1.0,
		MinRandomInteger:            -10,
		NewERCNameProbabilty:        0.001,
		RandomSeed:                  0,
		TopLevelPopCode:             false,
		TopLevelPushCode:            true,
		Tracing:                     false,
	}

	if !reflect.DeepEqual(opt, defaultConfig) {
		t.Error("expected \"\" to parse to defaultConfig")
	}
}
Esempio n. 2
0
func TestParseErrors(t *testing.T) {
	for _, pe := range optionParseErrorTests {
		_, err := gopush.ReadOptions(strings.NewReader(pe.toParse))
		if err.Error() != pe.expectedError {
			t.Errorf("unexpected error while parsing configuration: %q, expected %q", err, pe.expectedError)
		}
	}
}