! fixedpt.inf - test harness for fixedpt.h (fixed-point math support for Inform)
!   Version 1.0 (19-Sep-2001)
!
! by Matt Albrecht - [email protected]
!
! (If you need to edit this file, note that indentations are 4 spaces
! and tabs are not used.)
!
! This has been donated to the Public Domain.  Use, abuse, and don't blame me.
!

Message "Compiling Fixed-Point Math unit tests";



Include "infunit";



! Not optimized version
Include "fixedpt";




[Main;
   StartTest( testPrint );
   StartTest( testConvertFloor );

   report();
];




[ testPrint
       i;

   i = $ffff;
   print "$ffff: signed = ", (fixedpt_signed)i, "^";
   print "     unsigned = ", (fixedpt_unsigned)i, "^";

   i = $0;
   print "$0000: signed = ", (fixedpt_signed)i, "^";
   print "     unsigned = ", (fixedpt_unsigned)i, "^";

   i = $ff00;
   print "$ff00: signed = ", (fixedpt_signed)i, "^";
   print "     unsigned = ", (fixedpt_unsigned)i, "^";

   i = $8000;
   print "$8000: signed = ", (fixedpt_signed)i, "^";
   print "     unsigned = ", (fixedpt_unsigned)i, "^";

   i = $7fff;
   print "$7fff: signed = ", (fixedpt_signed)i, "^";
   print "     unsigned = ", (fixedpt_unsigned)i, "^";

   i = $0080;
   print "$0080: signed = ", (fixedpt_signed)i, "^";
   print "     unsigned = ", (fixedpt_unsigned)i, "^";

   i = $01ff;
   print "$01ff: signed = ", (fixedpt_signed)i, "^";
   print "     unsigned = ", (fixedpt_unsigned)i, "^";
];


[ testConvertFloor
   ;

   assertEquals(
       0,
       fixedpt_unsigned_floor_word( 0 ),
       "floor(0) not right" );

   assertEquals(
       0,
       fixedpt_unsigned_floor_word( $00ff ),
       "floor($00ff) not right" );

   assertEquals(
       1,
       fixedpt_unsigned_floor_word( $0100 ),
       "floor($0100) not right" );

   assertEquals(
       1,
       fixedpt_unsigned_floor_word( $01ff ),
       "floor($01ff) not right" );

];