2 C11 generic associations
13 void testGeneric(void)
15 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
16 ASSERT (_Generic(i
, default : 0, int : 1, long : 2) == 1);
17 ASSERT (_Generic(l
, default : 0, int : 1, long int : 2) == 2);
18 ASSERT (_Generic(l
, default : 0, int : 1, char : 2) == 0);
19 ASSERT (_Generic('c', default : 0, int : 1, char : 2) == 1);
20 ASSERT (_Generic(7, default : 0, int : 1, char : 2) == 1);
21 ASSERT (_Generic(e
, default : 0, int : 1, char : 2) == 1);
22 ASSERT (_Generic(c
, default : 0, int : 1, char : 2) == 2);
23 ASSERT (_Generic("c"[0], char : 1, default : 0) == _Generic(c
, char : 1, default : 0)); // There once was a bug where the sign of plain char different from the sign of char in string literals.
29 _Pragma("std_c2y") // generic selection with a type name is a C2y feature
32 void testGenericWithType(void)
36 ASSERT (_Generic(typeof(i
), int : 0, const int : 1, default : 2) == 1);