/** Tests covering the shift operators.
+ disabled for pic16
sign: signed, unsigned
type: char, int, long
#include <testfwk.h>
void
-testShiftClasses(void)
+test1ShiftClasses(void)
{
{attr} {storage} {sign} {type} i, result;
}
void
-testShiftRight(void)
+test2ShiftRight(void)
{
{attr} {storage} {type} i, result;
ASSERT(result == -15);
}
-static void
-testShiftByteMultiples(void)
+void
+test3ShiftByteMultiples(void)
{
{attr} {storage} {type} i;
ASSERT((({type}) i<<24) == (({type}) {vals} << 24));
}
-static void
-testShiftOne(void)
+void
+test4ShiftOne(void)
{
{attr} {storage} {sign} {type} i;
{sign} {type} result;
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));
+}