Mercurial > hg > svcore
diff base/test/TestRealTime.h @ 1028:abe13fe10ed6
RealTime frame-conversion test
author | Chris Cannam |
---|---|
date | Wed, 14 Jan 2015 14:58:38 +0000 |
parents | 30afdc7c7b89 |
children | a1cd5abcb38b |
line wrap: on
line diff
--- a/base/test/TestRealTime.h Mon Dec 08 15:37:12 2014 +0000 +++ b/base/test/TestRealTime.h Wed Jan 14 14:58:38 2015 +0000 @@ -269,8 +269,33 @@ } } - - + void frame() + { + int frames[] = { + 0, 1, 2047, 2048, 6656, 32767, 32768, 44100, 44101, 999999999 + }; + int n = sizeof(frames)/sizeof(frames[0]); + + int rates[] = { + 1, 2, 8000, 22050, 44100, 44101, 192000 + }; + int m = sizeof(rates)/sizeof(rates[0]); + + for (int i = 0; i < n; ++i) { + int frame = frames[i]; + for (int j = 0; j < m; ++j) { + int rate = rates[j]; + + RealTime rt = RealTime::frame2RealTime(frame, rate); + int conv = RealTime::realTime2Frame(rt, rate); + QCOMPARE(frame, conv); + + rt = RealTime::frame2RealTime(-frame, rate); + conv = RealTime::realTime2Frame(rt, rate); + QCOMPARE(-frame, conv); + } + } + } }; #endif