summaryrefslogtreecommitdiff
path: root/support/regression/tests/not.c
blob: f50b696d8de87964e6d52d8192b3398f84629e22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/** not.c test ! operator

  ANSI: return type is int

  attr: volatile,
*/
#include <testfwk.h>

void
testNot(void)
{
    signed char  {attr} sc;
  unsigned char  {attr} uc;
  unsigned int   {attr} ui;
  unsigned long  {attr} ul;

  sc = 0;
  uc = 0;
  ui = 0;
  ul = 0;
  /* remember: unsigned * signed -> unsigned */
  /*             signed * signed ->   signed */
  ASSERT(!(  signed char) 0 * -1 < 0);
  ASSERT(!(unsigned char) 0 * -1 < 0);
  ASSERT(!sc   * -1 < 0);
  ASSERT(!uc   * -1 < 0);
  ASSERT(! 0   * -1 < 0);
  ASSERT(! 0u  * -1 < 0);
  ASSERT(!ui   * -1 < 0);
  ASSERT(! 0l  * -1 < 0);
  ASSERT(! 0ul * -1 < 0);
  ASSERT(!ul   * -1 < 0);

  ASSERT(!(char) 0 <<  8 == 0x100);
  ASSERT(!sc       <<  8 == 0x100);
#if !defined(PORT_HOST)
  ASSERT(!0  << 16 == 0);
  ASSERT(!0l << 16 == 0);
  ASSERT(!ui << 16 == 0);
  ASSERT(!ul << 16 == 0);
#endif
}