diff --git a/bitrate/BitrateCalculator_test.go b/bitrate/BitrateCalculator_test.go index 506e423e..e65e6eff 100644 --- a/bitrate/BitrateCalculator_test.go +++ b/bitrate/BitrateCalculator_test.go @@ -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) + } }