summaryrefslogtreecommitdiff
path: root/support/regression/tests/pow2shifts.c
blob: a1884da8681282a39a47e8a6d0568a8321d85f52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Test power of 2 based shifts.
   sign: signed, unsigned
 */
#include <testfwk.h>

void
testIntShift(void)
{
  volatile {sign} int left;

  left = 4;
  ASSERT(left * 1024 == 4096);
  ASSERT(left * 2048 == 8192);
  ASSERT(left * 256 == 1024);
  ASSERT(left * 64 == 256);

  left = 4096;
  ASSERT(left / 1024 == 4);
  ASSERT(left / 2048 == 2);
  ASSERT(left / 256 == 16);
  ASSERT(left / 4 == 1024);
}