blob: 12dfbbb8fec9da03819b728708c0a14219fcdf60 (
plain)
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
43
44
45
|
/* OpAssign tests
*/
#include <testfwk.h>
#ifdef __SDCC
#include <sdcc-lib.h>
#else
#define _STATMEM
#endif
typedef struct
{
char a;
char n;
} item_type;
item_type t;
_STATMEM item_type* get_next_item(void)
{
/* have a side effect */
t.n++;
/* keep things easy, not implementing a list.
Using a true list would break things
even more pointedly:
a) reading beyond end of the list and
b) intermixing list members */
return &t;
}
void
testOpAssign(void)
{
t.a = 0;
t.n = 0;
/* get_next_item() should be called only once */
get_next_item()->a |= 42;
ASSERT (t.a == 42);
ASSERT (t.n == 1);
}
|