Mercurial > hg > svcore
comparison base/test/TestVampRealTime.h @ 1344:980afe3f1a76 3.0-integration
Untabify, comment test that doesn't apply on Windows
author | Chris Cannam |
---|---|
date | Fri, 06 Jan 2017 11:21:09 +0000 |
parents | abfc498c52bc |
children | 2001fe23e449 |
comparison
equal
deleted
inserted
replaced
1343:c380e56c95f5 | 1344:980afe3f1a76 |
---|---|
35 QCOMPARE(QString(s.c_str()), QString(e)); | 35 QCOMPARE(QString(s.c_str()), QString(e)); |
36 } | 36 } |
37 | 37 |
38 typedef Vamp::RealTime RealTime; | 38 typedef Vamp::RealTime RealTime; |
39 typedef long frame_type; | 39 typedef long frame_type; |
40 | 40 |
41 private slots: | 41 private slots: |
42 | 42 |
43 void zero() | 43 void zero() |
44 { | 44 { |
45 QCOMPARE(RealTime(0, 0), RealTime::zeroTime); | 45 QCOMPARE(RealTime(0, 0), RealTime::zeroTime); |
46 QCOMPARE(RealTime(0, 0).sec, 0); | 46 QCOMPARE(RealTime(0, 0).sec, 0); |
47 QCOMPARE(RealTime(0, 0).nsec, 0); | 47 QCOMPARE(RealTime(0, 0).nsec, 0); |
48 QCOMPARE(RealTime(0, 0).msec(), 0); | 48 QCOMPARE(RealTime(0, 0).msec(), 0); |
49 QCOMPARE(RealTime(0, 0).usec(), 0); | 49 QCOMPARE(RealTime(0, 0).usec(), 0); |
50 } | 50 } |
51 | 51 |
52 void ctor() | 52 void ctor() |
53 { | 53 { |
54 QCOMPARE(RealTime(0, 0), RealTime(0, 0)); | 54 QCOMPARE(RealTime(0, 0), RealTime(0, 0)); |
55 | 55 |
56 // wraparounds | 56 // wraparounds |
57 QCOMPARE(RealTime(0, ONE_BILLION/2), RealTime(1, -ONE_BILLION/2)); | 57 QCOMPARE(RealTime(0, ONE_BILLION/2), RealTime(1, -ONE_BILLION/2)); |
58 QCOMPARE(RealTime(0, -ONE_BILLION/2), RealTime(-1, ONE_BILLION/2)); | 58 QCOMPARE(RealTime(0, -ONE_BILLION/2), RealTime(-1, ONE_BILLION/2)); |
59 | 59 |
60 QCOMPARE(RealTime(1, ONE_BILLION), RealTime(2, 0)); | 60 QCOMPARE(RealTime(1, ONE_BILLION), RealTime(2, 0)); |
61 QCOMPARE(RealTime(1, -ONE_BILLION), RealTime(0, 0)); | 61 QCOMPARE(RealTime(1, -ONE_BILLION), RealTime(0, 0)); |
62 QCOMPARE(RealTime(-1, ONE_BILLION), RealTime(0, 0)); | 62 QCOMPARE(RealTime(-1, ONE_BILLION), RealTime(0, 0)); |
63 QCOMPARE(RealTime(-1, -ONE_BILLION), RealTime(-2, 0)); | 63 QCOMPARE(RealTime(-1, -ONE_BILLION), RealTime(-2, 0)); |
64 | 64 |
65 QCOMPARE(RealTime(2, -ONE_BILLION*2), RealTime(0, 0)); | 65 QCOMPARE(RealTime(2, -ONE_BILLION*2), RealTime(0, 0)); |
66 QCOMPARE(RealTime(2, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); | 66 QCOMPARE(RealTime(2, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); |
67 | 67 |
68 QCOMPARE(RealTime(-2, ONE_BILLION*2), RealTime(0, 0)); | 68 QCOMPARE(RealTime(-2, ONE_BILLION*2), RealTime(0, 0)); |
69 QCOMPARE(RealTime(-2, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); | 69 QCOMPARE(RealTime(-2, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); |
70 | 70 |
71 QCOMPARE(RealTime(0, 1).sec, 0); | 71 QCOMPARE(RealTime(0, 1).sec, 0); |
72 QCOMPARE(RealTime(0, 1).nsec, 1); | 72 QCOMPARE(RealTime(0, 1).nsec, 1); |
73 QCOMPARE(RealTime(0, -1).sec, 0); | 73 QCOMPARE(RealTime(0, -1).sec, 0); |
74 QCOMPARE(RealTime(0, -1).nsec, -1); | 74 QCOMPARE(RealTime(0, -1).nsec, -1); |
75 QCOMPARE(RealTime(1, -1).sec, 0); | 75 QCOMPARE(RealTime(1, -1).sec, 0); |
76 QCOMPARE(RealTime(1, -1).nsec, ONE_BILLION-1); | 76 QCOMPARE(RealTime(1, -1).nsec, ONE_BILLION-1); |
77 QCOMPARE(RealTime(-1, 1).sec, 0); | 77 QCOMPARE(RealTime(-1, 1).sec, 0); |
78 QCOMPARE(RealTime(-1, 1).nsec, -ONE_BILLION+1); | 78 QCOMPARE(RealTime(-1, 1).nsec, -ONE_BILLION+1); |
79 QCOMPARE(RealTime(-1, -1).sec, -1); | 79 QCOMPARE(RealTime(-1, -1).sec, -1); |
80 QCOMPARE(RealTime(-1, -1).nsec, -1); | 80 QCOMPARE(RealTime(-1, -1).nsec, -1); |
81 | 81 |
82 QCOMPARE(RealTime(2, -ONE_BILLION*2).sec, 0); | 82 QCOMPARE(RealTime(2, -ONE_BILLION*2).sec, 0); |
83 QCOMPARE(RealTime(2, -ONE_BILLION*2).nsec, 0); | 83 QCOMPARE(RealTime(2, -ONE_BILLION*2).nsec, 0); |
84 QCOMPARE(RealTime(2, -ONE_BILLION/2).sec, 1); | 84 QCOMPARE(RealTime(2, -ONE_BILLION/2).sec, 1); |
85 QCOMPARE(RealTime(2, -ONE_BILLION/2).nsec, ONE_BILLION/2); | 85 QCOMPARE(RealTime(2, -ONE_BILLION/2).nsec, ONE_BILLION/2); |
86 | 86 |
87 QCOMPARE(RealTime(-2, ONE_BILLION*2).sec, 0); | 87 QCOMPARE(RealTime(-2, ONE_BILLION*2).sec, 0); |
88 QCOMPARE(RealTime(-2, ONE_BILLION*2).nsec, 0); | 88 QCOMPARE(RealTime(-2, ONE_BILLION*2).nsec, 0); |
89 QCOMPARE(RealTime(-2, ONE_BILLION/2).sec, -1); | 89 QCOMPARE(RealTime(-2, ONE_BILLION/2).sec, -1); |
90 QCOMPARE(RealTime(-2, ONE_BILLION/2).nsec, -ONE_BILLION/2); | 90 QCOMPARE(RealTime(-2, ONE_BILLION/2).nsec, -ONE_BILLION/2); |
91 } | 91 } |
92 | 92 |
93 void fromSeconds() | 93 void fromSeconds() |
94 { | 94 { |
95 QCOMPARE(RealTime::fromSeconds(0), RealTime(0, 0)); | 95 QCOMPARE(RealTime::fromSeconds(0), RealTime(0, 0)); |
96 | 96 |
97 QCOMPARE(RealTime::fromSeconds(0.5).sec, 0); | 97 QCOMPARE(RealTime::fromSeconds(0.5).sec, 0); |
98 QCOMPARE(RealTime::fromSeconds(0.5).nsec, ONE_BILLION/2); | 98 QCOMPARE(RealTime::fromSeconds(0.5).nsec, ONE_BILLION/2); |
99 QCOMPARE(RealTime::fromSeconds(0.5).usec(), ONE_MILLION/2); | 99 QCOMPARE(RealTime::fromSeconds(0.5).usec(), ONE_MILLION/2); |
100 QCOMPARE(RealTime::fromSeconds(0.5).msec(), 500); | 100 QCOMPARE(RealTime::fromSeconds(0.5).msec(), 500); |
101 | 101 |
102 QCOMPARE(RealTime::fromSeconds(0.5), RealTime(0, ONE_BILLION/2)); | 102 QCOMPARE(RealTime::fromSeconds(0.5), RealTime(0, ONE_BILLION/2)); |
103 QCOMPARE(RealTime::fromSeconds(1), RealTime(1, 0)); | 103 QCOMPARE(RealTime::fromSeconds(1), RealTime(1, 0)); |
104 QCOMPARE(RealTime::fromSeconds(1.5), RealTime(1, ONE_BILLION/2)); | 104 QCOMPARE(RealTime::fromSeconds(1.5), RealTime(1, ONE_BILLION/2)); |
105 | 105 |
106 QCOMPARE(RealTime::fromSeconds(-0.5).sec, 0); | 106 QCOMPARE(RealTime::fromSeconds(-0.5).sec, 0); |
107 QCOMPARE(RealTime::fromSeconds(-0.5).nsec, -ONE_BILLION/2); | 107 QCOMPARE(RealTime::fromSeconds(-0.5).nsec, -ONE_BILLION/2); |
108 QCOMPARE(RealTime::fromSeconds(-0.5).usec(), -ONE_MILLION/2); | 108 QCOMPARE(RealTime::fromSeconds(-0.5).usec(), -ONE_MILLION/2); |
109 QCOMPARE(RealTime::fromSeconds(-0.5).msec(), -500); | 109 QCOMPARE(RealTime::fromSeconds(-0.5).msec(), -500); |
110 | 110 |
111 QCOMPARE(RealTime::fromSeconds(-1.5).sec, -1); | 111 QCOMPARE(RealTime::fromSeconds(-1.5).sec, -1); |
112 QCOMPARE(RealTime::fromSeconds(-1.5).nsec, -ONE_BILLION/2); | 112 QCOMPARE(RealTime::fromSeconds(-1.5).nsec, -ONE_BILLION/2); |
113 QCOMPARE(RealTime::fromSeconds(-1.5).usec(), -ONE_MILLION/2); | 113 QCOMPARE(RealTime::fromSeconds(-1.5).usec(), -ONE_MILLION/2); |
114 QCOMPARE(RealTime::fromSeconds(-1.5).msec(), -500); | 114 QCOMPARE(RealTime::fromSeconds(-1.5).msec(), -500); |
115 | 115 |
116 QCOMPARE(RealTime::fromSeconds(-0.5), RealTime(0, -ONE_BILLION/2)); | 116 QCOMPARE(RealTime::fromSeconds(-0.5), RealTime(0, -ONE_BILLION/2)); |
117 QCOMPARE(RealTime::fromSeconds(-1), RealTime(-1, 0)); | 117 QCOMPARE(RealTime::fromSeconds(-1), RealTime(-1, 0)); |
118 QCOMPARE(RealTime::fromSeconds(-1.5), RealTime(-1, -ONE_BILLION/2)); | 118 QCOMPARE(RealTime::fromSeconds(-1.5), RealTime(-1, -ONE_BILLION/2)); |
119 } | 119 } |
120 | 120 |
121 void fromMilliseconds() | 121 void fromMilliseconds() |
122 { | 122 { |
123 QCOMPARE(RealTime::fromMilliseconds(0), RealTime(0, 0)); | 123 QCOMPARE(RealTime::fromMilliseconds(0), RealTime(0, 0)); |
124 QCOMPARE(RealTime::fromMilliseconds(500), RealTime(0, ONE_BILLION/2)); | 124 QCOMPARE(RealTime::fromMilliseconds(500), RealTime(0, ONE_BILLION/2)); |
125 QCOMPARE(RealTime::fromMilliseconds(1000), RealTime(1, 0)); | 125 QCOMPARE(RealTime::fromMilliseconds(1000), RealTime(1, 0)); |
126 QCOMPARE(RealTime::fromMilliseconds(1500), RealTime(1, ONE_BILLION/2)); | 126 QCOMPARE(RealTime::fromMilliseconds(1500), RealTime(1, ONE_BILLION/2)); |
127 | 127 |
128 QCOMPARE(RealTime::fromMilliseconds(-0), RealTime(0, 0)); | 128 QCOMPARE(RealTime::fromMilliseconds(-0), RealTime(0, 0)); |
129 QCOMPARE(RealTime::fromMilliseconds(-500), RealTime(0, -ONE_BILLION/2)); | 129 QCOMPARE(RealTime::fromMilliseconds(-500), RealTime(0, -ONE_BILLION/2)); |
130 QCOMPARE(RealTime::fromMilliseconds(-1000), RealTime(-1, 0)); | 130 QCOMPARE(RealTime::fromMilliseconds(-1000), RealTime(-1, 0)); |
131 QCOMPARE(RealTime::fromMilliseconds(-1500), RealTime(-1, -ONE_BILLION/2)); | 131 QCOMPARE(RealTime::fromMilliseconds(-1500), RealTime(-1, -ONE_BILLION/2)); |
132 } | 132 } |
133 | 133 |
134 #ifndef _WIN32 | |
134 void fromTimeval() | 135 void fromTimeval() |
135 { | 136 { |
136 struct timeval tv; | 137 struct timeval tv; |
137 | 138 |
138 tv.tv_sec = 0; tv.tv_usec = 0; | 139 tv.tv_sec = 0; tv.tv_usec = 0; |
139 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, 0)); | 140 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, 0)); |
140 tv.tv_sec = 0; tv.tv_usec = ONE_MILLION/2; | 141 tv.tv_sec = 0; tv.tv_usec = ONE_MILLION/2; |
141 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, ONE_BILLION/2)); | 142 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, ONE_BILLION/2)); |
142 tv.tv_sec = 1; tv.tv_usec = 0; | 143 tv.tv_sec = 1; tv.tv_usec = 0; |
143 QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, 0)); | 144 QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, 0)); |
144 tv.tv_sec = 1; tv.tv_usec = ONE_MILLION/2; | 145 tv.tv_sec = 1; tv.tv_usec = ONE_MILLION/2; |
145 QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, ONE_BILLION/2)); | 146 QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, ONE_BILLION/2)); |
146 | 147 |
147 tv.tv_sec = 0; tv.tv_usec = -ONE_MILLION/2; | 148 tv.tv_sec = 0; tv.tv_usec = -ONE_MILLION/2; |
148 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, -ONE_BILLION/2)); | 149 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, -ONE_BILLION/2)); |
149 tv.tv_sec = -1; tv.tv_usec = 0; | 150 tv.tv_sec = -1; tv.tv_usec = 0; |
150 QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, 0)); | 151 QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, 0)); |
151 tv.tv_sec = -1; tv.tv_usec = -ONE_MILLION/2; | 152 tv.tv_sec = -1; tv.tv_usec = -ONE_MILLION/2; |
152 QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, -ONE_BILLION/2)); | 153 QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, -ONE_BILLION/2)); |
153 } | 154 } |
155 #endif | |
154 | 156 |
155 void assign() | 157 void assign() |
156 { | 158 { |
157 RealTime r; | 159 RealTime r; |
158 r = RealTime(0, 0); | 160 r = RealTime(0, 0); |
159 QCOMPARE(r, RealTime::zeroTime); | 161 QCOMPARE(r, RealTime::zeroTime); |
160 r = RealTime(0, ONE_BILLION/2); | 162 r = RealTime(0, ONE_BILLION/2); |
161 QCOMPARE(r.sec, 0); | 163 QCOMPARE(r.sec, 0); |
162 QCOMPARE(r.nsec, ONE_BILLION/2); | 164 QCOMPARE(r.nsec, ONE_BILLION/2); |
163 r = RealTime(-1, -ONE_BILLION/2); | 165 r = RealTime(-1, -ONE_BILLION/2); |
164 QCOMPARE(r.sec, -1); | 166 QCOMPARE(r.sec, -1); |
165 QCOMPARE(r.nsec, -ONE_BILLION/2); | 167 QCOMPARE(r.nsec, -ONE_BILLION/2); |
166 } | 168 } |
167 | 169 |
168 void plus() | 170 void plus() |
169 { | 171 { |
170 QCOMPARE(RealTime(0, 0) + RealTime(0, 0), RealTime(0, 0)); | 172 QCOMPARE(RealTime(0, 0) + RealTime(0, 0), RealTime(0, 0)); |
171 | 173 |
172 QCOMPARE(RealTime(0, 0) + RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); | 174 QCOMPARE(RealTime(0, 0) + RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); |
173 QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(0, ONE_BILLION/2), RealTime(1, 0)); | 175 QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(0, ONE_BILLION/2), RealTime(1, 0)); |
174 QCOMPARE(RealTime(1, 0) + RealTime(0, ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); | 176 QCOMPARE(RealTime(1, 0) + RealTime(0, ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); |
175 | 177 |
176 QCOMPARE(RealTime(0, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); | 178 QCOMPARE(RealTime(0, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); |
177 QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(-1, 0)); | 179 QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(-1, 0)); |
178 QCOMPARE(RealTime(-1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); | 180 QCOMPARE(RealTime(-1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); |
179 | 181 |
180 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); | 182 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); |
181 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, 0)); | 183 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, 0)); |
182 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); | 184 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); |
183 | 185 |
184 QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(-1, 0), RealTime(0, -ONE_BILLION/2)); | 186 QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(-1, 0), RealTime(0, -ONE_BILLION/2)); |
185 QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(1, 0), RealTime(0, ONE_BILLION/2)); | 187 QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(1, 0), RealTime(0, ONE_BILLION/2)); |
186 } | 188 } |
187 | 189 |
188 void minus() | 190 void minus() |
189 { | 191 { |
190 QCOMPARE(RealTime(0, 0) - RealTime(0, 0), RealTime(0, 0)); | 192 QCOMPARE(RealTime(0, 0) - RealTime(0, 0), RealTime(0, 0)); |
191 | 193 |
192 QCOMPARE(RealTime(0, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); | 194 QCOMPARE(RealTime(0, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); |
193 QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(0, ONE_BILLION/2), RealTime(0, 0)); | 195 QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(0, ONE_BILLION/2), RealTime(0, 0)); |
194 QCOMPARE(RealTime(1, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); | 196 QCOMPARE(RealTime(1, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); |
195 | 197 |
196 QCOMPARE(RealTime(0, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); | 198 QCOMPARE(RealTime(0, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); |
197 QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(0, 0)); | 199 QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(0, 0)); |
198 QCOMPARE(RealTime(-1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); | 200 QCOMPARE(RealTime(-1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); |
199 | 201 |
200 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); | 202 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); |
201 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, 0)); | 203 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, 0)); |
202 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, ONE_BILLION/2)); | 204 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, ONE_BILLION/2)); |
203 | 205 |
204 QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(-1, 0), RealTime(1, ONE_BILLION/2)); | 206 QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(-1, 0), RealTime(1, ONE_BILLION/2)); |
205 QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(1, 0), RealTime(-1, -ONE_BILLION/2)); | 207 QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(1, 0), RealTime(-1, -ONE_BILLION/2)); |
206 } | 208 } |
207 | 209 |
208 void negate() | 210 void negate() |
209 { | 211 { |
210 QCOMPARE(-RealTime(0, 0), RealTime(0, 0)); | 212 QCOMPARE(-RealTime(0, 0), RealTime(0, 0)); |
211 QCOMPARE(-RealTime(1, 0), RealTime(-1, 0)); | 213 QCOMPARE(-RealTime(1, 0), RealTime(-1, 0)); |
212 QCOMPARE(-RealTime(1, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); | 214 QCOMPARE(-RealTime(1, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); |
213 QCOMPARE(-RealTime(-1, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); | 215 QCOMPARE(-RealTime(-1, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); |
214 } | 216 } |
215 | 217 |
216 void compare() | 218 void compare() |
217 { | 219 { |
218 int sec, nsec; | 220 int sec, nsec; |
219 for (sec = -2; sec <= 2; sec += 2) { | 221 for (sec = -2; sec <= 2; sec += 2) { |
220 for (nsec = -1; nsec <= 1; nsec += 1) { | 222 for (nsec = -1; nsec <= 1; nsec += 1) { |
221 QCOMPARE(RealTime(sec, nsec) < RealTime(sec, nsec), false); | 223 QCOMPARE(RealTime(sec, nsec) < RealTime(sec, nsec), false); |
222 QCOMPARE(RealTime(sec, nsec) > RealTime(sec, nsec), false); | 224 QCOMPARE(RealTime(sec, nsec) > RealTime(sec, nsec), false); |
223 QCOMPARE(RealTime(sec, nsec) == RealTime(sec, nsec), true); | 225 QCOMPARE(RealTime(sec, nsec) == RealTime(sec, nsec), true); |
224 QCOMPARE(RealTime(sec, nsec) != RealTime(sec, nsec), false); | 226 QCOMPARE(RealTime(sec, nsec) != RealTime(sec, nsec), false); |
225 QCOMPARE(RealTime(sec, nsec) <= RealTime(sec, nsec), true); | 227 QCOMPARE(RealTime(sec, nsec) <= RealTime(sec, nsec), true); |
226 QCOMPARE(RealTime(sec, nsec) >= RealTime(sec, nsec), true); | 228 QCOMPARE(RealTime(sec, nsec) >= RealTime(sec, nsec), true); |
227 } | 229 } |
228 } | 230 } |
229 RealTime prev(-3, 0); | 231 RealTime prev(-3, 0); |
230 for (sec = -2; sec <= 2; sec += 2) { | 232 for (sec = -2; sec <= 2; sec += 2) { |
231 for (nsec = -1; nsec <= 1; nsec += 1) { | 233 for (nsec = -1; nsec <= 1; nsec += 1) { |
232 | 234 |
233 RealTime curr(sec, nsec); | 235 RealTime curr(sec, nsec); |
234 | 236 |
235 QCOMPARE(prev < curr, true); | 237 QCOMPARE(prev < curr, true); |
236 QCOMPARE(prev > curr, false); | 238 QCOMPARE(prev > curr, false); |
237 QCOMPARE(prev == curr, false); | 239 QCOMPARE(prev == curr, false); |
238 QCOMPARE(prev != curr, true); | 240 QCOMPARE(prev != curr, true); |
239 QCOMPARE(prev <= curr, true); | 241 QCOMPARE(prev <= curr, true); |
240 QCOMPARE(prev >= curr, false); | 242 QCOMPARE(prev >= curr, false); |
241 | 243 |
242 QCOMPARE(curr < prev, false); | 244 QCOMPARE(curr < prev, false); |
243 QCOMPARE(curr > prev, true); | 245 QCOMPARE(curr > prev, true); |
244 QCOMPARE(curr == prev, false); | 246 QCOMPARE(curr == prev, false); |
245 QCOMPARE(curr != prev, true); | 247 QCOMPARE(curr != prev, true); |
246 QCOMPARE(curr <= prev, false); | 248 QCOMPARE(curr <= prev, false); |
247 QCOMPARE(curr >= prev, true); | 249 QCOMPARE(curr >= prev, true); |
248 | 250 |
249 prev = curr; | 251 prev = curr; |
250 } | 252 } |
251 } | 253 } |
252 } | 254 } |
253 | 255 |
254 void frame() | 256 void frame() |
255 { | 257 { |
256 int frames[] = { | 258 int frames[] = { |