/** Tests covering the shift operators.
- type: char, int
+ sign: signed, unsigned
+ type: char, int, long
storage: static,
attr: volatile
*/
#include <testfwk.h>
-static void
+void
testShiftClasses(void)
{
- {attr} {storage} {type} i, result;
+ {attr} {storage} {sign} {type} i, result;
- i = 50;
- ASSERT(i>>3 == 6);
- ASSERT(i<<2 == 200);
+ i = 30;
+ ASSERT(i>>3 == 3);
+ ASSERT(i<<2 == 120);
result = i;
result >>= 2;
- ASSERT(result == 12);
+ ASSERT(result == 7);
result = i;
result <<= 2;
- ASSERT(result == 200);
+ ASSERT(result == 120);
+}
+
+void
+testShiftRight(void)
+{
+ {attr} {storage} {type} i, result;
+
+ i = -120;
+ ASSERT(i>>2 == -30);
+
+ result = i;
+ result >>= 3;
+ ASSERT(result == -15);
}
/** PENDING: Disabled. */
testShiftByteMultiples(void)
{
#if 0
+ /* PENDING */
{attr} {storage} {type} i;
i = ({type}){vals};
ASSERT(i>>24 == (({type}){vals} >> 24));
i = ({type}){vals};
- ASSERT(i<<8 == (({type}){vals} << 8));
+ ASSERT(i<<8 == (({type}){vals} << 8));;
ASSERT(i<<16 == (({type}){vals} << 16));
ASSERT(i<<24 == (({type}){vals} << 24));
#endif
static void
testShiftOne(void)
{
- {attr} {storage} {type} i;
- {type} result;
+ {attr} {storage} {sign} {type} i;
+ {sign} {type} result;
i = ({type}){vals};