File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,16 @@ int squared(int a)
44{
55 return a * a ;
66}
7+
8+ /* test case for issue #21094 */
9+ typedef enum upng_error {
10+ UPNG_EOK = 0 , /* success (no error) */
11+ UPNG_ENOMEM = 1 , /* memory allocation failed */
12+ UPNG_ENOTFOUND = 2 , /* resource not found (file missing) */
13+ UPNG_ENOTPNG = 3 , /* image data does not have a PNG header */
14+ UPNG_EMALFORMED = 4 , /* image data is not a valid PNG image */
15+ UPNG_EUNSUPPORTED = 5 , /* critical PNG chunk type is not supported */
16+ UPNG_EUNINTERLACED = 6 , /* image interlacing is not supported */
17+ UPNG_EUNFORMAT = 7 , /* image color format is not supported */
18+ UPNG_EPARAM = 8 /* invalid parameter to method call */
19+ } upng_error ;
Original file line number Diff line number Diff line change 22import imports.cstuff3;
33
44static assert (squared(4 ) == 16 );
5+
6+ /* test case for issue #21094 */
7+ string enum_to_str (E)(E v) if (is (E == enum ))
8+ {
9+ final switch (v) with (E)
10+ {
11+ static foreach (m; __traits (allMembers , E))
12+ {
13+ case mixin (m):
14+ return m;
15+ }
16+ }
17+ }
18+
19+ void testEnumSwitch ()
20+ {
21+ auto str = enum_to_str(UPNG_EOK );
22+ assert (str == " UPNG_EOK" );
23+ }
You can’t perform that action at this time.
0 commit comments