/* DESCRIPTION Testing function for turbidity probe. AUTHORS Russell Stanley LICENSE Copyright (C) 2021-2022 the Australian Ocean Lab (AusOcean) It is free software: you can redistribute it and/or modify them under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License in gpl.txt. If not, see http://www.gnu.org/licenses. */ package main import ( "io" "io/ioutil" "testing" "time" "bitbucket.org/ausocean/utils/logging" "gopkg.in/natefinch/lumberjack.v2" ) // TestProbe reads a given video file and writes the sharpness and contrast scores to a turbidity probe. func TestProbe(t *testing.T) { // Create lumberjack logger. fileLog := &lumberjack.Logger{ Filename: logPath, MaxSize: logMaxSize, MaxBackups: logMaxBackup, MaxAge: logMaxAge, } log := logging.New(logVerbosity, io.MultiWriter(fileLog), logSuppress) updatedMatrix := []float64{-0.2731048063, -0.0020501869, 661.0275911942, 0.0014327789, -0.2699443748, 339.3921028016, 0.0000838317, 0.0000476486, 1.0} ts, err := NewTurbidityProbe(log, time.Microsecond) if err != nil { t.Fatalf("failed to create turbidity probe") } err = ts.Update(updatedMatrix) if err != nil { t.Fatalf("could not update probe: %v", err) } video, err := ioutil.ReadFile("logo.h264") if err != nil { t.Fatalf("failed to read file: %v", err) } _, err = ts.Write(video) if err != nil { t.Fatalf("failed to write sharpness and contrast: %v", err) } t.Logf("contrast: %v, sharpness: %v\n", ts.contrast, ts.sharpness) }