diff --git a/parser/parser_test.go b/parser/parser_test.go index 2a2ddc7b..d1e5f2cb 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -64,24 +64,18 @@ func TestH264Parser(t *testing.T) { parser.SetOutputChan(make(chan []byte, outChanSize)) parser.Start() - count := 0 - for i := range data { - // If we have a whole frame, write it to a file for inspection otherwise do - // nothing + for i, n := 0, 0; n <= nOfFrames; i++ { select { case parser.InputChan() <- data[i]: case frame := <-parser.OutputChan(): - outputFile, err := os.Create("testOutput/" + strconv.Itoa(count) + ".h264_frame") + outputFile, err := os.Create("testOutput/" + strconv.Itoa(n) + ".h264_frame") if err != nil { t.Errorf("Should not have got error creating output file!") return } outputFile.Write(frame) outputFile.Close() - count++ - if count > nOfFrames { - return - } + n++ default: } }