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 committed Jan 7, 2023
1 parent 6cb4d8e commit b8bcd0f
Show file tree
Hide file tree
Showing 2 changed files with 16 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
};
13 changes: 10 additions & 3 deletions tests/tenumconst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ 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
doAssert ANON_A.typeof is type[cint]

0 comments on commit b8bcd0f

Please sign in to comment.