1 /** Tests covering the shift operators.
10 pending - 1792, 851968, 1560281088, -3, -1792, -851968, -1560000000
15 test1ShiftClasses(void)
17 {attr
} {storage
} {sign
} {type
} i
, result
;
29 ASSERT(result
== 120);
32 /* This tests for implementation-defined behaviour (right-shifting negative values).
33 For sdcc the implementation defined behaviour is that right shift for arithmetic
34 types is arithmetic. */
38 #ifndef __SDCC_pdk14 // Lack of memory
39 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
40 {attr
} {storage
} signed {type
} i
, result
;
53 ASSERT(result
== -15);
59 test3ShiftByteMultiples(void)
61 {attr
} {storage
} {type
} i
;
64 ASSERT(i
>>8 == ({type
})({vals
} >> 8));
65 ASSERT(i
>>16 == ({type
})({vals
} >> 16));
66 ASSERT(i
>>24 == ({type
})({vals
} >> 24));
69 ASSERT( ({type
})(i
<<8) == ({type
})({vals
} << 8));;
70 ASSERT((({type
}) i
<<16) == (({type
}) {vals
} << 16));
71 ASSERT((({type
}) i
<<24) == (({type
}) {vals
} << 24));
77 #ifndef __SDCC_pdk14 // Lack of memory
78 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
79 {attr
} {storage
} {sign
} {type
} i
;
85 ASSERT(result
== ({type
})(({type
}){vals
} >> 1));
89 ASSERT(result
== ({type
})(({type
}){vals
} >> 1));
92 ASSERT(result
== ({type
})(({type
}){vals
} << 1));
96 ASSERT(result
== ({type
})(({type
}){vals
} << 1));
101 #ifndef __SDCC_pdk14 // Lack of memory
102 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
103 static {type
} ShiftLeftByParam ({type
} count
)
105 {attr
} {storage
} {type
} i
;
110 static {type
} ShiftRightByParam ({type
} count
)
112 {attr
} {storage
} {type
} i
;
120 testShiftByParam(void)
122 #ifndef __SDCC_pdk14 // Lack of memory
123 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
124 ASSERT(ShiftLeftByParam(2) == ({type
})({vals
} << 2));
125 ASSERT(ShiftRightByParam(2) == ({type
})({vals
} >> 2));