X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=support%2Fregression%2Ftests%2Fshifts.c;h=0eb607f91a808f4cf007377efca0e50fc71baf35;hb=9e3df070c8022aa20b3761a9d213a185eb27ed99;hp=c709c5a2b76961a22b472f30f0d9552a34e13b13;hpb=58cd074c23701c28549f8ae3004e43a9b6d473a5;p=fw%2Fsdcc diff --git a/support/regression/tests/shifts.c b/support/regression/tests/shifts.c index c709c5a2..0eb607f9 100644 --- a/support/regression/tests/shifts.c +++ b/support/regression/tests/shifts.c @@ -1,4 +1,5 @@ /** Tests covering the shift operators. + disabled for pic16 sign: signed, unsigned type: char, int, long @@ -12,7 +13,7 @@ #include void -testShiftClasses(void) +test1ShiftClasses(void) { {attr} {storage} {sign} {type} i, result; @@ -30,7 +31,7 @@ testShiftClasses(void) } void -testShiftRight(void) +test2ShiftRight(void) { {attr} {storage} {type} i, result; @@ -48,8 +49,8 @@ testShiftRight(void) ASSERT(result == -15); } -static void -testShiftByteMultiples(void) +void +test3ShiftByteMultiples(void) { {attr} {storage} {type} i; @@ -59,13 +60,13 @@ testShiftByteMultiples(void) ASSERT(i>>24 == ({type})({vals} >> 24)); i = ({type}){vals}; - ASSERT(({type})(i<<8) == ({type})({vals} << 8));; - ASSERT(({type})(i<<16) == ({type})({vals} << 16)); - ASSERT(({type})(i<<24) == ({type})({vals} << 24)); + ASSERT( ({type})(i<<8) == ({type})({vals} << 8));; + ASSERT((({type}) i<<16) == (({type}) {vals} << 16)); + ASSERT((({type}) i<<24) == (({type}) {vals} << 24)); } -static void -testShiftOne(void) +void +test4ShiftOne(void) { {attr} {storage} {sign} {type} i; {sign} {type} result; @@ -86,3 +87,24 @@ testShiftOne(void) result <<= 1; ASSERT(result == ({type})(({type}){vals} << 1)); } + +static {type} ShiftLeftByParam ({type} count) +{ + {attr} {storage} {type} i; + i = ({type}){vals}; + return (i << count); +} + +static {type} ShiftRightByParam ({type} count) +{ + {attr} {storage} {type} i; + i = ({type}){vals}; + return (i >> count); +} + +void +testShiftByParam(void) +{ + ASSERT(ShiftLeftByParam(2) == ({type})({vals} << 2)); + ASSERT(ShiftRightByParam(2) == ({type})({vals} >> 2)); +}