Changeset 871 for trunk/test/half.cpp
 Timestamp:
 Aug 28, 2011, 11:07:12 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/half.cpp
r870 r871 36 36 CPPUNIT_TEST(test_half_to_float); 37 37 CPPUNIT_TEST(test_half_to_int); 38 CPPUNIT_TEST(test_float_op_half); 39 CPPUNIT_TEST(test_half_op_float); 38 40 CPPUNIT_TEST_SUITE_END(); 39 41 … … 206 208 CPPUNIT_ASSERT_EQUAL((int)(half)(65504.0f), 65504); 207 209 CPPUNIT_ASSERT_EQUAL((int)(half)(65504.0f), 65504); 210 } 211 212 void test_float_op_half() 213 { 214 half zero = 0; 215 half one = 1; 216 half two = 2; 217 218 float a = zero + one; 219 CPPUNIT_ASSERT_EQUAL(1.0f, a); 220 a += zero; 221 CPPUNIT_ASSERT_EQUAL(1.0f, a); 222 a = zero; 223 CPPUNIT_ASSERT_EQUAL(1.0f, a); 224 a *= one; 225 CPPUNIT_ASSERT_EQUAL(1.0f, a); 226 a /= one; 227 CPPUNIT_ASSERT_EQUAL(1.0f, a); 228 229 float b = one + zero; 230 CPPUNIT_ASSERT_EQUAL(1.0f, b); 231 b += one; 232 CPPUNIT_ASSERT_EQUAL(2.0f, b); 233 b *= two; 234 CPPUNIT_ASSERT_EQUAL(4.0f, b); 235 b = two; 236 CPPUNIT_ASSERT_EQUAL(2.0f, b); 237 b /= two; 238 CPPUNIT_ASSERT_EQUAL(1.0f, b); 239 240 float c = one  zero; 241 CPPUNIT_ASSERT_EQUAL(1.0f, c); 242 243 float d = two  one; 244 CPPUNIT_ASSERT_EQUAL(1.0f, d); 245 246 float e = two + (one); 247 CPPUNIT_ASSERT_EQUAL(1.0f, e); 248 249 float f = (two * two) / (one + one); 250 CPPUNIT_ASSERT_EQUAL(2.0f, f); 251 } 252 253 void test_half_op_float() 254 { 255 half zero = 0; 256 half one = 1; 257 half two = 2; 258 half four = 4; 259 260 half a = one + 0.0f; 261 CPPUNIT_ASSERT_EQUAL(one.bits(), a.bits()); 262 a += 0.0f; 263 CPPUNIT_ASSERT_EQUAL(one.bits(), a.bits()); 264 a = 0.0f; 265 CPPUNIT_ASSERT_EQUAL(one.bits(), a.bits()); 266 a *= 1.0f; 267 CPPUNIT_ASSERT_EQUAL(one.bits(), a.bits()); 268 a /= 1.0f; 269 CPPUNIT_ASSERT_EQUAL(one.bits(), a.bits()); 270 271 half b = one + 0.0f; 272 CPPUNIT_ASSERT_EQUAL(one.bits(), b.bits()); 273 b += 1.0f; 274 CPPUNIT_ASSERT_EQUAL(two.bits(), b.bits()); 275 b *= 2.0f; 276 CPPUNIT_ASSERT_EQUAL(four.bits(), b.bits()); 277 b = 2.0f; 278 CPPUNIT_ASSERT_EQUAL(two.bits(), b.bits()); 279 b /= 2.0f; 280 CPPUNIT_ASSERT_EQUAL(one.bits(), b.bits()); 281 282 half c = 1.0f  zero; 283 CPPUNIT_ASSERT_EQUAL(one.bits(), c.bits()); 284 285 half d = 2.0f  one; 286 CPPUNIT_ASSERT_EQUAL(one.bits(), d.bits()); 287 288 half e = 2.0f + (one); 289 CPPUNIT_ASSERT_EQUAL(one.bits(), e.bits()); 290 291 half f = (2.0f * two) / (1.0f + one); 292 CPPUNIT_ASSERT_EQUAL(two.bits(), f.bits()); 208 293 } 209 294
Note: See TracChangeset
for help on using the changeset viewer.