Using n instead of count, and also simplified code

This commit is contained in:
saxon 2018-07-04 22:13:18 +09:30
parent b3a57557e2
commit b59e756d53
1 changed files with 3 additions and 9 deletions

View File

@ -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:
}
}