Test file is complete and appears to chose that the library works.

This commit is contained in:
Unknown 2017-12-06 13:37:52 +10:30
parent 742f92b56b
commit 94f8ffb361
1 changed files with 9 additions and 5 deletions

View File

@ -30,7 +30,6 @@ package bitrate
import (
"testing"
"time"
"fmt"
)
// Some consts used over duration of testing
@ -60,13 +59,18 @@ func Test1(t *testing.T) {
// Now let's check that the output delay feature works
func Test2(t *testing.T){
bitrateCalc = BitrateCalculator{}
var currentBitrate int64
for i := 0; i < 2; i++ {
bitrateCalc.Start(bitrate2)
bitrateCalc.Start(bitrateDelay2)
time.Sleep(testTime*time.Millisecond)
currentBitrate := int64(bitrateCalc.Stop(amountOfData))
actualBitrate := int64(amountOfData / ((testTime * time.Millisecond)/1e9))
currentBitrate = int64(bitrateCalc.Stop(amountOfData))
if i == 0 && currentBitrate != 0 {
t.Errorf("Bitrate is wrong! Calculated: %v Actual %v", currentBitrate, actualBitrate)
t.Errorf("The bitrate calc did not delay outputting!")
}
time.Sleep(6000*time.Millisecond)
}
actualBitrate := int64(amountOfData / ((testTime * time.Millisecond)/1e9))
if currentBitrate != actualBitrate {
t.Errorf("Bitrate is wrong! Calculated: %v Actual %v", currentBitrate, actualBitrate)
}
}