Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

27 lines
656 B

  1. #include <assert.h>
  2. #include "safemult.h"
  3. int main() {
  4. int16 a;
  5. int32 b;
  6. int64 c;
  7. uint16 d;
  8. uint32 e;
  9. uint64 f;
  10. assert(imult16(4,10000,&a)==0);
  11. assert(imult16(-4,10000,&a)==0);
  12. assert(imult16(5,10,&a)==1 && a==50);
  13. assert(imult16(-3,10000,&a)==1 && a==-30000);
  14. assert(imult32(0x40000000,2,&b)==0);
  15. assert(imult32(-0x40000000,2,&b)==1 && b==-0x80000000);
  16. assert(imult32(0x3fffffff,2,&b)==1 && b==0x7ffffffe);
  17. assert(imult64(0x4000000000000000ll,2,&c)==0);
  18. assert(imult64(-0x4000000000000000ll,2,&c)==1 && c==-0x8000000000000000ll);
  19. assert(imult64(0x3fffffffffffffffll,2,&c)==1 && c==0x7ffffffffffffffell);
  20. return 0;
  21. }