comparison base/test/TestOurRealTime.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 b7b84ae5f0a7
children 622d193a00dc
comparison
equal deleted inserted replaced
1343:c380e56c95f5 1344:980afe3f1a76
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(1, -ONE_BILLION-ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); 65 QCOMPARE(RealTime(1, -ONE_BILLION-ONE_BILLION/2), RealTime(0, -ONE_BILLION/2));
66 QCOMPARE(RealTime(-1, ONE_BILLION+ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); 66 QCOMPARE(RealTime(-1, ONE_BILLION+ONE_BILLION/2), RealTime(0, 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(-2, ONE_BILLION*2), RealTime(0, 0)); 71 QCOMPARE(RealTime(-2, ONE_BILLION*2), RealTime(0, 0));
72 QCOMPARE(RealTime(-2, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); 72 QCOMPARE(RealTime(-2, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2));
73 73
74 QCOMPARE(RealTime(0, 1).sec, 0); 74 QCOMPARE(RealTime(0, 1).sec, 0);
75 QCOMPARE(RealTime(0, 1).nsec, 1); 75 QCOMPARE(RealTime(0, 1).nsec, 1);
76 QCOMPARE(RealTime(0, -1).sec, 0); 76 QCOMPARE(RealTime(0, -1).sec, 0);
77 QCOMPARE(RealTime(0, -1).nsec, -1); 77 QCOMPARE(RealTime(0, -1).nsec, -1);
78 QCOMPARE(RealTime(1, -1).sec, 0); 78 QCOMPARE(RealTime(1, -1).sec, 0);
79 QCOMPARE(RealTime(1, -1).nsec, ONE_BILLION-1); 79 QCOMPARE(RealTime(1, -1).nsec, ONE_BILLION-1);
80 QCOMPARE(RealTime(-1, 1).sec, 0); 80 QCOMPARE(RealTime(-1, 1).sec, 0);
81 QCOMPARE(RealTime(-1, 1).nsec, -ONE_BILLION+1); 81 QCOMPARE(RealTime(-1, 1).nsec, -ONE_BILLION+1);
82 QCOMPARE(RealTime(-1, -1).sec, -1); 82 QCOMPARE(RealTime(-1, -1).sec, -1);
83 QCOMPARE(RealTime(-1, -1).nsec, -1); 83 QCOMPARE(RealTime(-1, -1).nsec, -1);
84 84
85 QCOMPARE(RealTime(2, -ONE_BILLION*2).sec, 0); 85 QCOMPARE(RealTime(2, -ONE_BILLION*2).sec, 0);
86 QCOMPARE(RealTime(2, -ONE_BILLION*2).nsec, 0); 86 QCOMPARE(RealTime(2, -ONE_BILLION*2).nsec, 0);
87 QCOMPARE(RealTime(2, -ONE_BILLION/2).sec, 1); 87 QCOMPARE(RealTime(2, -ONE_BILLION/2).sec, 1);
88 QCOMPARE(RealTime(2, -ONE_BILLION/2).nsec, ONE_BILLION/2); 88 QCOMPARE(RealTime(2, -ONE_BILLION/2).nsec, ONE_BILLION/2);
89 89
90 QCOMPARE(RealTime(-2, ONE_BILLION*2).sec, 0); 90 QCOMPARE(RealTime(-2, ONE_BILLION*2).sec, 0);
91 QCOMPARE(RealTime(-2, ONE_BILLION*2).nsec, 0); 91 QCOMPARE(RealTime(-2, ONE_BILLION*2).nsec, 0);
92 QCOMPARE(RealTime(-2, ONE_BILLION/2).sec, -1); 92 QCOMPARE(RealTime(-2, ONE_BILLION/2).sec, -1);
93 QCOMPARE(RealTime(-2, ONE_BILLION/2).nsec, -ONE_BILLION/2); 93 QCOMPARE(RealTime(-2, ONE_BILLION/2).nsec, -ONE_BILLION/2);
94 } 94 }
95 95
96 void fromSeconds() 96 void fromSeconds()
97 { 97 {
98 QCOMPARE(RealTime::fromSeconds(0), RealTime(0, 0)); 98 QCOMPARE(RealTime::fromSeconds(0), RealTime(0, 0));
99 99
100 QCOMPARE(RealTime::fromSeconds(0.5).sec, 0); 100 QCOMPARE(RealTime::fromSeconds(0.5).sec, 0);
101 QCOMPARE(RealTime::fromSeconds(0.5).nsec, ONE_BILLION/2); 101 QCOMPARE(RealTime::fromSeconds(0.5).nsec, ONE_BILLION/2);
102 QCOMPARE(RealTime::fromSeconds(0.5).usec(), ONE_MILLION/2); 102 QCOMPARE(RealTime::fromSeconds(0.5).usec(), ONE_MILLION/2);
103 QCOMPARE(RealTime::fromSeconds(0.5).msec(), 500); 103 QCOMPARE(RealTime::fromSeconds(0.5).msec(), 500);
104 104
105 QCOMPARE(RealTime::fromSeconds(0.5), RealTime(0, ONE_BILLION/2)); 105 QCOMPARE(RealTime::fromSeconds(0.5), RealTime(0, ONE_BILLION/2));
106 QCOMPARE(RealTime::fromSeconds(1), RealTime(1, 0)); 106 QCOMPARE(RealTime::fromSeconds(1), RealTime(1, 0));
107 QCOMPARE(RealTime::fromSeconds(1.5), RealTime(1, ONE_BILLION/2)); 107 QCOMPARE(RealTime::fromSeconds(1.5), RealTime(1, ONE_BILLION/2));
108 108
109 QCOMPARE(RealTime::fromSeconds(-0.5).sec, 0); 109 QCOMPARE(RealTime::fromSeconds(-0.5).sec, 0);
110 QCOMPARE(RealTime::fromSeconds(-0.5).nsec, -ONE_BILLION/2); 110 QCOMPARE(RealTime::fromSeconds(-0.5).nsec, -ONE_BILLION/2);
111 QCOMPARE(RealTime::fromSeconds(-0.5).usec(), -ONE_MILLION/2); 111 QCOMPARE(RealTime::fromSeconds(-0.5).usec(), -ONE_MILLION/2);
112 QCOMPARE(RealTime::fromSeconds(-0.5).msec(), -500); 112 QCOMPARE(RealTime::fromSeconds(-0.5).msec(), -500);
113 113
114 QCOMPARE(RealTime::fromSeconds(-1.5).sec, -1); 114 QCOMPARE(RealTime::fromSeconds(-1.5).sec, -1);
115 QCOMPARE(RealTime::fromSeconds(-1.5).nsec, -ONE_BILLION/2); 115 QCOMPARE(RealTime::fromSeconds(-1.5).nsec, -ONE_BILLION/2);
116 QCOMPARE(RealTime::fromSeconds(-1.5).usec(), -ONE_MILLION/2); 116 QCOMPARE(RealTime::fromSeconds(-1.5).usec(), -ONE_MILLION/2);
117 QCOMPARE(RealTime::fromSeconds(-1.5).msec(), -500); 117 QCOMPARE(RealTime::fromSeconds(-1.5).msec(), -500);
118 118
119 QCOMPARE(RealTime::fromSeconds(-0.5), RealTime(0, -ONE_BILLION/2)); 119 QCOMPARE(RealTime::fromSeconds(-0.5), RealTime(0, -ONE_BILLION/2));
120 QCOMPARE(RealTime::fromSeconds(-1), RealTime(-1, 0)); 120 QCOMPARE(RealTime::fromSeconds(-1), RealTime(-1, 0));
121 QCOMPARE(RealTime::fromSeconds(-1.5), RealTime(-1, -ONE_BILLION/2)); 121 QCOMPARE(RealTime::fromSeconds(-1.5), RealTime(-1, -ONE_BILLION/2));
122 } 122 }
123 123
124 void fromMilliseconds() 124 void fromMilliseconds()
125 { 125 {
126 QCOMPARE(RealTime::fromMilliseconds(0), RealTime(0, 0)); 126 QCOMPARE(RealTime::fromMilliseconds(0), RealTime(0, 0));
127 QCOMPARE(RealTime::fromMilliseconds(500), RealTime(0, ONE_BILLION/2)); 127 QCOMPARE(RealTime::fromMilliseconds(500), RealTime(0, ONE_BILLION/2));
128 QCOMPARE(RealTime::fromMilliseconds(1000), RealTime(1, 0)); 128 QCOMPARE(RealTime::fromMilliseconds(1000), RealTime(1, 0));
129 QCOMPARE(RealTime::fromMilliseconds(1500), RealTime(1, ONE_BILLION/2)); 129 QCOMPARE(RealTime::fromMilliseconds(1500), RealTime(1, ONE_BILLION/2));
130 130
131 QCOMPARE(RealTime::fromMilliseconds(-0), RealTime(0, 0)); 131 QCOMPARE(RealTime::fromMilliseconds(-0), RealTime(0, 0));
132 QCOMPARE(RealTime::fromMilliseconds(-500), RealTime(0, -ONE_BILLION/2)); 132 QCOMPARE(RealTime::fromMilliseconds(-500), RealTime(0, -ONE_BILLION/2));
133 QCOMPARE(RealTime::fromMilliseconds(-1000), RealTime(-1, 0)); 133 QCOMPARE(RealTime::fromMilliseconds(-1000), RealTime(-1, 0));
134 QCOMPARE(RealTime::fromMilliseconds(-1500), RealTime(-1, -ONE_BILLION/2)); 134 QCOMPARE(RealTime::fromMilliseconds(-1500), RealTime(-1, -ONE_BILLION/2));
135 } 135 }
136 136
137 void fromTimeval() 137 void fromTimeval()
138 { 138 {
139 struct timeval tv; 139 struct timeval tv;
140 140
141 tv.tv_sec = 0; tv.tv_usec = 0; 141 tv.tv_sec = 0; tv.tv_usec = 0;
142 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, 0)); 142 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, 0));
143 tv.tv_sec = 0; tv.tv_usec = ONE_MILLION/2; 143 tv.tv_sec = 0; tv.tv_usec = ONE_MILLION/2;
144 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, ONE_BILLION/2)); 144 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, ONE_BILLION/2));
145 tv.tv_sec = 1; tv.tv_usec = 0; 145 tv.tv_sec = 1; tv.tv_usec = 0;
146 QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, 0)); 146 QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, 0));
147 tv.tv_sec = 1; tv.tv_usec = ONE_MILLION/2; 147 tv.tv_sec = 1; tv.tv_usec = ONE_MILLION/2;
148 QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, ONE_BILLION/2)); 148 QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, ONE_BILLION/2));
149 149
150 tv.tv_sec = 0; tv.tv_usec = -ONE_MILLION/2; 150 tv.tv_sec = 0; tv.tv_usec = -ONE_MILLION/2;
151 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, -ONE_BILLION/2)); 151 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, -ONE_BILLION/2));
152 tv.tv_sec = -1; tv.tv_usec = 0; 152 tv.tv_sec = -1; tv.tv_usec = 0;
153 QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, 0)); 153 QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, 0));
154 tv.tv_sec = -1; tv.tv_usec = -ONE_MILLION/2; 154 tv.tv_sec = -1; tv.tv_usec = -ONE_MILLION/2;
155 QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, -ONE_BILLION/2)); 155 QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, -ONE_BILLION/2));
156 } 156 }
157 157
158 void fromXsdDuration() 158 void fromXsdDuration()
159 { 159 {
160 QCOMPARE(RealTime::fromXsdDuration("PT0"), RealTime::zeroTime); 160 QCOMPARE(RealTime::fromXsdDuration("PT0"), RealTime::zeroTime);
161 QCOMPARE(RealTime::fromXsdDuration("PT0S"), RealTime::zeroTime); 161 QCOMPARE(RealTime::fromXsdDuration("PT0S"), RealTime::zeroTime);
162 QCOMPARE(RealTime::fromXsdDuration("PT10S"), RealTime(10, 0)); 162 QCOMPARE(RealTime::fromXsdDuration("PT10S"), RealTime(10, 0));
163 QCOMPARE(RealTime::fromXsdDuration("PT10.5S"), RealTime(10, ONE_BILLION/2)); 163 QCOMPARE(RealTime::fromXsdDuration("PT10.5S"), RealTime(10, ONE_BILLION/2));
164 QCOMPARE(RealTime::fromXsdDuration("PT1.5S").sec, 1); 164 QCOMPARE(RealTime::fromXsdDuration("PT1.5S").sec, 1);
165 QCOMPARE(RealTime::fromXsdDuration("PT1.5S").msec(), 500); 165 QCOMPARE(RealTime::fromXsdDuration("PT1.5S").msec(), 500);
166 QCOMPARE(RealTime::fromXsdDuration("-PT1.5S").sec, -1); 166 QCOMPARE(RealTime::fromXsdDuration("-PT1.5S").sec, -1);
167 QCOMPARE(RealTime::fromXsdDuration("-PT1.5S").msec(), -500); 167 QCOMPARE(RealTime::fromXsdDuration("-PT1.5S").msec(), -500);
168 QCOMPARE(RealTime::fromXsdDuration("PT1M30.5S"), RealTime(90, ONE_BILLION/2)); 168 QCOMPARE(RealTime::fromXsdDuration("PT1M30.5S"), RealTime(90, ONE_BILLION/2));
169 QCOMPARE(RealTime::fromXsdDuration("PT1H2M30.5S"), RealTime(3750, ONE_BILLION/2)); 169 QCOMPARE(RealTime::fromXsdDuration("PT1H2M30.5S"), RealTime(3750, ONE_BILLION/2));
170 } 170 }
171 171
172 void toDouble() 172 void toDouble()
173 { 173 {
174 QCOMPARE(RealTime(0, 0).toDouble(), 0.0); 174 QCOMPARE(RealTime(0, 0).toDouble(), 0.0);
175 QCOMPARE(RealTime(0, ONE_BILLION/2).toDouble(), 0.5); 175 QCOMPARE(RealTime(0, ONE_BILLION/2).toDouble(), 0.5);
176 QCOMPARE(RealTime(1, 0).toDouble(), 1.0); 176 QCOMPARE(RealTime(1, 0).toDouble(), 1.0);
177 QCOMPARE(RealTime(1, ONE_BILLION/2).toDouble(), 1.5); 177 QCOMPARE(RealTime(1, ONE_BILLION/2).toDouble(), 1.5);
178 178
179 QCOMPARE(RealTime(0, -ONE_BILLION/2).toDouble(), -0.5); 179 QCOMPARE(RealTime(0, -ONE_BILLION/2).toDouble(), -0.5);
180 QCOMPARE(RealTime(-1, 0).toDouble(), -1.0); 180 QCOMPARE(RealTime(-1, 0).toDouble(), -1.0);
181 QCOMPARE(RealTime(-1, -ONE_BILLION/2).toDouble(), -1.5); 181 QCOMPARE(RealTime(-1, -ONE_BILLION/2).toDouble(), -1.5);
182 } 182 }
183 183
184 void assign() 184 void assign()
185 { 185 {
186 RealTime r; 186 RealTime r;
187 r = RealTime(0, 0); 187 r = RealTime(0, 0);
188 QCOMPARE(r, RealTime::zeroTime); 188 QCOMPARE(r, RealTime::zeroTime);
189 r = RealTime(0, ONE_BILLION/2); 189 r = RealTime(0, ONE_BILLION/2);
190 QCOMPARE(r.sec, 0); 190 QCOMPARE(r.sec, 0);
191 QCOMPARE(r.nsec, ONE_BILLION/2); 191 QCOMPARE(r.nsec, ONE_BILLION/2);
192 r = RealTime(-1, -ONE_BILLION/2); 192 r = RealTime(-1, -ONE_BILLION/2);
193 QCOMPARE(r.sec, -1); 193 QCOMPARE(r.sec, -1);
194 QCOMPARE(r.nsec, -ONE_BILLION/2); 194 QCOMPARE(r.nsec, -ONE_BILLION/2);
195 } 195 }
196 196
197 void plus() 197 void plus()
198 { 198 {
199 QCOMPARE(RealTime(0, 0) + RealTime(0, 0), RealTime(0, 0)); 199 QCOMPARE(RealTime(0, 0) + RealTime(0, 0), RealTime(0, 0));
200 200
201 QCOMPARE(RealTime(0, 0) + RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); 201 QCOMPARE(RealTime(0, 0) + RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2));
202 QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(0, ONE_BILLION/2), RealTime(1, 0)); 202 QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(0, ONE_BILLION/2), RealTime(1, 0));
203 QCOMPARE(RealTime(1, 0) + RealTime(0, ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); 203 QCOMPARE(RealTime(1, 0) + RealTime(0, ONE_BILLION/2), RealTime(1, ONE_BILLION/2));
204 204
205 QCOMPARE(RealTime(0, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); 205 QCOMPARE(RealTime(0, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2));
206 QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(-1, 0)); 206 QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(-1, 0));
207 QCOMPARE(RealTime(-1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); 207 QCOMPARE(RealTime(-1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2));
208 208
209 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); 209 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2));
210 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, 0)); 210 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, 0));
211 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); 211 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2));
212 212
213 QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(-1, 0), RealTime(0, -ONE_BILLION/2)); 213 QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(-1, 0), RealTime(0, -ONE_BILLION/2));
214 QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(1, 0), RealTime(0, ONE_BILLION/2)); 214 QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(1, 0), RealTime(0, ONE_BILLION/2));
215 } 215 }
216 216
217 void minus() 217 void minus()
218 { 218 {
219 QCOMPARE(RealTime(0, 0) - RealTime(0, 0), RealTime(0, 0)); 219 QCOMPARE(RealTime(0, 0) - RealTime(0, 0), RealTime(0, 0));
220 220
221 QCOMPARE(RealTime(0, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); 221 QCOMPARE(RealTime(0, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, -ONE_BILLION/2));
222 QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(0, ONE_BILLION/2), RealTime(0, 0)); 222 QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(0, ONE_BILLION/2), RealTime(0, 0));
223 QCOMPARE(RealTime(1, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); 223 QCOMPARE(RealTime(1, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2));
224 224
225 QCOMPARE(RealTime(0, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); 225 QCOMPARE(RealTime(0, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2));
226 QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(0, 0)); 226 QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(0, 0));
227 QCOMPARE(RealTime(-1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); 227 QCOMPARE(RealTime(-1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2));
228 228
229 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); 229 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2));
230 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, 0)); 230 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, 0));
231 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, ONE_BILLION/2)); 231 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, ONE_BILLION/2));
232 232
233 QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(-1, 0), RealTime(1, ONE_BILLION/2)); 233 QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(-1, 0), RealTime(1, ONE_BILLION/2));
234 QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(1, 0), RealTime(-1, -ONE_BILLION/2)); 234 QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(1, 0), RealTime(-1, -ONE_BILLION/2));
235 } 235 }
236 236
237 void negate() 237 void negate()
238 { 238 {
239 QCOMPARE(-RealTime(0, 0), RealTime(0, 0)); 239 QCOMPARE(-RealTime(0, 0), RealTime(0, 0));
240 QCOMPARE(-RealTime(1, 0), RealTime(-1, 0)); 240 QCOMPARE(-RealTime(1, 0), RealTime(-1, 0));
241 QCOMPARE(-RealTime(1, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); 241 QCOMPARE(-RealTime(1, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2));
242 QCOMPARE(-RealTime(-1, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); 242 QCOMPARE(-RealTime(-1, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2));
243 } 243 }
244 244
245 void compare() 245 void compare()
246 { 246 {
247 int sec, nsec; 247 int sec, nsec;
248 for (sec = -2; sec <= 2; sec += 2) { 248 for (sec = -2; sec <= 2; sec += 2) {
249 for (nsec = -1; nsec <= 1; nsec += 1) { 249 for (nsec = -1; nsec <= 1; nsec += 1) {
250 QCOMPARE(RealTime(sec, nsec) < RealTime(sec, nsec), false); 250 QCOMPARE(RealTime(sec, nsec) < RealTime(sec, nsec), false);
251 QCOMPARE(RealTime(sec, nsec) > RealTime(sec, nsec), false); 251 QCOMPARE(RealTime(sec, nsec) > RealTime(sec, nsec), false);
252 QCOMPARE(RealTime(sec, nsec) == RealTime(sec, nsec), true); 252 QCOMPARE(RealTime(sec, nsec) == RealTime(sec, nsec), true);
253 QCOMPARE(RealTime(sec, nsec) != RealTime(sec, nsec), false); 253 QCOMPARE(RealTime(sec, nsec) != RealTime(sec, nsec), false);
254 QCOMPARE(RealTime(sec, nsec) <= RealTime(sec, nsec), true); 254 QCOMPARE(RealTime(sec, nsec) <= RealTime(sec, nsec), true);
255 QCOMPARE(RealTime(sec, nsec) >= RealTime(sec, nsec), true); 255 QCOMPARE(RealTime(sec, nsec) >= RealTime(sec, nsec), true);
256 } 256 }
257 } 257 }
258 RealTime prev(-3, 0); 258 RealTime prev(-3, 0);
259 for (sec = -2; sec <= 2; sec += 2) { 259 for (sec = -2; sec <= 2; sec += 2) {
260 for (nsec = -1; nsec <= 1; nsec += 1) { 260 for (nsec = -1; nsec <= 1; nsec += 1) {
261 261
262 RealTime curr(sec, nsec); 262 RealTime curr(sec, nsec);
263 263
264 QCOMPARE(prev < curr, true); 264 QCOMPARE(prev < curr, true);
265 QCOMPARE(prev > curr, false); 265 QCOMPARE(prev > curr, false);
266 QCOMPARE(prev == curr, false); 266 QCOMPARE(prev == curr, false);
267 QCOMPARE(prev != curr, true); 267 QCOMPARE(prev != curr, true);
268 QCOMPARE(prev <= curr, true); 268 QCOMPARE(prev <= curr, true);
269 QCOMPARE(prev >= curr, false); 269 QCOMPARE(prev >= curr, false);
270 270
271 QCOMPARE(curr < prev, false); 271 QCOMPARE(curr < prev, false);
272 QCOMPARE(curr > prev, true); 272 QCOMPARE(curr > prev, true);
273 QCOMPARE(curr == prev, false); 273 QCOMPARE(curr == prev, false);
274 QCOMPARE(curr != prev, true); 274 QCOMPARE(curr != prev, true);
275 QCOMPARE(curr <= prev, false); 275 QCOMPARE(curr <= prev, false);
276 QCOMPARE(curr >= prev, true); 276 QCOMPARE(curr >= prev, true);
277 277
278 prev = curr; 278 prev = curr;
279 } 279 }
280 } 280 }
281 } 281 }
282 282
283 void frame() 283 void frame()
284 { 284 {
285 int frames[] = { 285 int frames[] = {