1 //980324 bkoz 2 //test for bool and bitwise ands 3 4 #include <assert.h> 5 6 bar(bool x)7void bar ( bool x ) {}; bars(short x)8void bars ( short x ) {}; 9 10 #if 0 11 int andb(){ 12 bool y; 13 bar ( y ); 14 int blob = ( 27 & int (y) ); 15 return blob; //expect 1 or 0 16 } 17 #endif 18 andbtrue()19int andbtrue(){ 20 bool y = true; 21 bar ( y ); 22 int blob = ( 27 & int (y) ); 23 return blob; //expect 1 24 } 25 andbfalse()26int andbfalse(){ 27 bool y = false; 28 bar ( y ); 29 int blob = ( 27 & int (y) ); 30 return blob; //expect 0 31 } 32 andbfalse2()33int andbfalse2(){ 34 bool y = 0; 35 bar ( y ); 36 int blob = ( 27 & int (y) ); 37 return blob; //expect 0 38 } 39 ands()40int ands(){ 41 short y = 1; 42 bars ( y ); 43 int blob = ( 27 & int (y) ); 44 return blob; //expect 1 45 } 46 47 main()48int main() { 49 int tmp; 50 #if 0 51 tmp = andb(); 52 assert (tmp == 1 || tmp == 0); 53 #endif 54 tmp = andbtrue(); 55 assert (tmp == 1); 56 tmp = andbfalse(); 57 assert (tmp == 0); 58 tmp = andbfalse2(); 59 assert (tmp == 0); 60 tmp = ands(); 61 assert (tmp == 1); 62 return 0; 63 } 64