diff --git a/parser/parser_test.go b/parser/parser_test.go index 94be834e..9e063a29 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -1,7 +1,34 @@ +/* +NAME + parser_test.go + +DESCRIPTION + See Readme.md + +AUTHOR + Saxon Nelson-Milton + +LICENSE + parser_test.go is Copyright (C) 2017 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 + along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. +*/ + package parser import ( - "fmt" + "log" "os" "strconv" "testing" @@ -13,21 +40,22 @@ const ( ) func TestH264Parser(t *testing.T) { - fmt.Println("Opening input file!") + log.SetOutput(os.Stderr) + log.Println("Opening input file!") inputFile, err := os.Open(h264InputFileName) if err != nil { t.Errorf("Should not have got error opening file!") return } - fmt.Println("Getting file stats!") + log.Println("Getting file stats!") stats, err := inputFile.Stat() if err != nil { t.Errorf("Could not get input file stats!") return } - fmt.Println("Creating space for file data and reading!") + log.Println("Creating space for file data and reading!") data := make([]byte, stats.Size()) _, err = inputFile.Read(data) if err != nil { @@ -36,7 +64,7 @@ func TestH264Parser(t *testing.T) { } // Create 'parser' and start it up - fmt.Println("Creating parser!") + log.Println("Creating parser!") parser := NewH264Parser() parser.SetOutputChan(make(chan []byte, 10000)) parser.Start() @@ -67,34 +95,34 @@ func TestH264Parser(t *testing.T) { /* func TestMJPEGParser(t *testing.T) { - fmt.Println("Opening input file!") + log.Println("Opening input file!") // Open the input file inputFile, err := os.Open(testInputFileName) if err != nil { t.Errorf("Should not have got error opening file!") } - fmt.Println("Getting file stats!") + log.Println("Getting file stats!") stats, err := inputFile.Stat() if err != nil { t.Errorf("Could not get input file stats!") return } - fmt.Println("Creating space for file data!") + log.Println("Creating space for file data!") data := make([]byte, stats.Size()) _, err = inputFile.Read(data) if err != nil { t.Errorf("Should not have got read error!") return } - fmt.Println("Creating parser!") + log.Println("Creating parser!") parser := NewMJPEGParser(len(data) + 1) parser.SetOutputChan(make(chan []byte, 10000)) parser.Start() - fmt.Printf("len(data): %v\n", len(data)) + log.Printf("len(data): %v\n", len(data)) for i := range data { parser.GetInputChan() <- data[i] } - fmt.Println("Writing jpegs to files!") + log.Println("Writing jpegs to files!") for i := 0; len(parser.GetOutputChan()) > 0; i++ { // Open a new output file outputFile, err := os.Create("testOutput/image" + strconv.Itoa(i) + ".jpeg")