mirror of https://bitbucket.org/ausocean/av.git
revid/config: add transform matrix test case
This commit is contained in:
parent
3047704ca0
commit
175cfc4925
|
@ -40,7 +40,7 @@ type turbidityProbe struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTurbidityProbe returns an empty turbidity probe for CircleCI testing only.
|
// NewTurbidityProbe returns an empty turbidity probe for CircleCI testing only.
|
||||||
func NewTurbidityProbe(log logger.Logger, delay time.Duration) (*turbidityProbe, error) {
|
func NewTurbidityProbe(log logger.Logger, delay time.Duration, transformMatrix []float64) (*turbidityProbe, error) {
|
||||||
tp := new(turbidityProbe)
|
tp := new(turbidityProbe)
|
||||||
return tp, nil
|
return tp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,7 @@ func TestUpdate(t *testing.T) {
|
||||||
"VBRQuality": "excellent",
|
"VBRQuality": "excellent",
|
||||||
"VerticalFlip": "true",
|
"VerticalFlip": "true",
|
||||||
"Width": "300",
|
"Width": "300",
|
||||||
|
"TransformMatrix": "0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,0.9",
|
||||||
}
|
}
|
||||||
|
|
||||||
dl := &dumbLogger{}
|
dl := &dumbLogger{}
|
||||||
|
@ -172,6 +173,7 @@ func TestUpdate(t *testing.T) {
|
||||||
VBRQuality: QualityExcellent,
|
VBRQuality: QualityExcellent,
|
||||||
VerticalFlip: true,
|
VerticalFlip: true,
|
||||||
Width: 300,
|
Width: 300,
|
||||||
|
TransformMatrix: []float64{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9},
|
||||||
}
|
}
|
||||||
|
|
||||||
got := Config{Logger: dl}
|
got := Config{Logger: dl}
|
||||||
|
|
|
@ -149,13 +149,19 @@ var Variables = []struct {
|
||||||
Name: KeyTransformMatrix,
|
Name: KeyTransformMatrix,
|
||||||
Type: typeString,
|
Type: typeString,
|
||||||
Update: func(c *Config, v string) {
|
Update: func(c *Config, v string) {
|
||||||
v = strings.Replace(v, " ", "", 0)
|
c.Logger.Log(logger.Debug, "updating transform matrix", "string", v)
|
||||||
|
v = strings.Replace(v, " ", "", -1)
|
||||||
|
vals := make([]float64, 0)
|
||||||
|
if v == "" {
|
||||||
|
c.TransformMatrix = vals
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
elements := strings.Split(v, ",")
|
elements := strings.Split(v, ",")
|
||||||
vals := make([]float64, len(elements))
|
for _, e := range elements {
|
||||||
for _, i := range elements {
|
vFloat, err := strconv.ParseFloat(e, 64)
|
||||||
vFloat, err := strconv.ParseFloat(i, 64)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Logger.Log(logger.Warning, "invalid TransformMatrix param", "value", i)
|
c.Logger.Log(logger.Warning, "invalid TransformMatrix param", "value", e)
|
||||||
}
|
}
|
||||||
vals = append(vals, vFloat)
|
vals = append(vals, vFloat)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue