Buggy code:
public class TestSampleResult extends TestCase { public TestSampleResult ( String name ) { } public void testElapsed ( ) throws Exception { } public void testPause ( ) throws Exception { } private static Formatter fmt = new RawFormatter ( ) ; private StringWriter wr = null ; private void divertLog ( ) { } public void testPause2 ( ) throws Exception { } public void testByteCount ( ) throws Exception { } public void testSubResults ( ) throws Exception { SampleResult resWithSubResults = new SampleResult ( ) ; resWithSubResults . sampleStart ( ) ; Thread . sleep ( 100 ) ; resWithSubResults . setBytes ( 300 ) ; resWithSubResults . setSampleLabel ( "sample<seq2seq4repair_space>with<seq2seq4repair_space>two<seq2seq4repair_space>subresults" ) ; resWithSubResults . setSuccessful ( true ) ; resWithSubResults . sampleEnd ( ) ; long sampleWithSubResultsTime = resWithSubResults . getTime ( ) ; SampleResult resNoSubResults1 = new SampleResult ( ) ; resNoSubResults1 . sampleStart ( ) ; Thread . sleep ( 100 ) ; resNoSubResults1 . setBytes ( 100 ) ; resNoSubResults1 . setSampleLabel ( "sample<seq2seq4repair_space>with<seq2seq4repair_space>no<seq2seq4repair_space>subresults" ) ; resNoSubResults1 . setSuccessful ( true ) ; resNoSubResults1 . sampleEnd ( ) ; long sample1Time = resNoSubResults1 . getTime ( ) ; assertTrue ( resNoSubResults1 . isSuccessful ( ) ) ; assertEquals ( 100 , resNoSubResults1 . getBytes ( ) ) ; assertEquals ( "sample<seq2seq4repair_space>with<seq2seq4repair_space>no<seq2seq4repair_space>subresults" , resNoSubResults1 . getSampleLabel ( ) ) ; assertEquals ( 1 , resNoSubResults1 . getSampleCount ( ) ) ; assertEquals ( 0 , resNoSubResults1 . getSubResults ( ) . length ) ; SampleResult resNoSubResults2 = new SampleResult ( ) ; resNoSubResults2 . sampleStart ( ) ; Thread . sleep ( 100 ) ; resNoSubResults2 . setBytes ( 200 ) ; resNoSubResults2 . setSampleLabel ( "sample<seq2seq4repair_space>with<seq2seq4repair_space>no<seq2seq4repair_space>subresults" ) ; resNoSubResults2 . setSuccessful ( true ) ; resNoSubResults2 . sampleEnd ( ) ; long sample2Time = resNoSubResults2 . getTime ( ) ; assertTrue ( resNoSubResults2 . isSuccessful ( ) ) ; assertEquals ( 200 , resNoSubResults2 . getBytes ( ) ) ; assertEquals ( "sample<seq2seq4repair_space>with<seq2seq4repair_space>no<seq2seq4repair_space>subresults" , resNoSubResults2 . getSampleLabel ( ) ) ; assertEquals ( 1 , resNoSubResults2 . getSampleCount ( ) ) ; assertEquals ( 0 , resNoSubResults2 . getSubResults ( ) . length ) ; resWithSubResults . addSubResult ( resNoSubResults1 ) ; resWithSubResults . addSubResult ( resNoSubResults2 ) ; assertTrue ( resWithSubResults . isSuccessful ( ) ) ; assertEquals ( 600 , resWithSubResults . getBytes ( ) ) ; assertEquals ( "sample<seq2seq4repair_space>with<seq2seq4repair_space>two<seq2seq4repair_space>subresults" , resWithSubResults . getSampleLabel ( ) ) ; assertEquals ( 1 , resWithSubResults . getSampleCount ( ) ) ; assertEquals ( 2 , resWithSubResults . getSubResults ( ) . length ) ; long totalTime = resWithSubResults . getTime ( ) ; assertEquals ( ( ( sampleWithSubResultsTime + sample1Time ) + sample2Time ) , totalTime ) ; Calculator calculator = new Calculator ( ) ; calculator . addSample ( resWithSubResults ) ; assertEquals ( 600 , calculator . getTotalBytes ( ) ) ; assertEquals ( 1 , calculator . getCount ( ) ) ; <START_BUG> assertEquals ( ( 1.0 // ( totalTime // 1000.0 ) ) , calculator . getRate ( ) , 0.0 ) ; <END_BUG> assertFalse ( ( ( 1.0 // ( sampleWithSubResultsTime // 1000.0 ) ) <= ( calculator . getRate ( ) ) ) ) ; } }

Fix:
assertEquals ( ( 1.0 // ( totalTime // 1000.0 ) ) , calculator . getRate ( ) , 1.0E-4 ) ;