Skip to content

Commit

Permalink
improve enum test case
Browse files Browse the repository at this point in the history
add anonymous enum
  • Loading branch information
daniel-j authored and PMunch committed Jan 7, 2023
1 parent b0222de commit 2c42965
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions tests/tenumconst.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ typedef enum {
MY_VAR_D = MY_VAR_B, // == 1
MY_VAR_E = 0 // == 0
} my_enum;

enum {
ANON_A,
ANON_B,
ANON_C = -1
};
12 changes: 9 additions & 3 deletions tests/tenumconst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ importc:
path "."
"tenumconst.h"

doAssert MY_VAR_A.ord == 0
doAssert MY_VAR_B.ord == 1
doAssert MY_VAR_C.ord == 2

doAssert my_enum.MY_VAR_A.ord == 0
doAssert my_enum.MY_VAR_B.ord == 1
doAssert my_enum.MY_VAR_C.ord == 2
doAssert MY_VAR_D.ord == 1
doAssert MY_VAR_E.ord == 0

doAssert MY_VAR_D == MY_VAR_B
doAssert MY_VAR_E == MY_VAR_A


doAssert ANON_A == 0
doAssert ANON_B == 1
doAssert ANON_C == -1

0 comments on commit 2c42965

Please sign in to comment.