示例#1
0
func TestParse(t *testing.T) {
	cases := []struct {
		line    string
		success bool
	}{
		{"Beta(1, 1)", true},
		{"beta(0.5, 1.5)", true},
		{" Beta \t (1, 1)", true},
		{"Gamma(1, 1)", false},
		{"Beta(1, 1, 1)", false},
		{"beta(-1, 1)", false},
		{"beta(0, 1)", false},
		{"beta(1, -1)", false},
		{"beta(1, 0)", false},
		{"beta(1, 0)", false},
		{"uniform()", true},
		{"uniform( )", true},
	}

	for _, c := range cases {
		if _, err := Parse(c.line); c.success {
			assert.Success(err, t)
		} else {
			assert.Failure(err, t)
		}
	}
}
示例#2
0
func TestExtractTaskNumber(t *testing.T) {
	scenarios := []struct {
		name    string
		total   uint
		result  uint
		success bool
	}{
		{"t0_0", 50, 0, true},
		{"t0_42", 50, 42, true},
		{"t0_42", 43, 42, true},
		{"t0_42", 42, 0, false},
		{"t1_42", 50, 0, false},
		{"t0_-2", 50, 0, false},
	}

	for _, s := range scenarios {
		result, err := extractTaskID(s.name, s.total)

		if s.success {
			assert.Success(err, t)
		} else {
			assert.Failure(err, t)
		}

		assert.Equal(result, s.result, t)
	}
}
示例#3
0
func TestCovPCAFailure(t *testing.T) {
	_, _, err := CovPCA([]float64{-1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}, 3, 0.0)

	assert.Failure(err, t)
}