Skip to content

Commit

Permalink
Hook up enum test
Browse files Browse the repository at this point in the history
  • Loading branch information
waltervn committed Mar 3, 2015
1 parent e7e92a6 commit 46a5f19
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ if(BUILD_TESTING)
build_test("tclass.cpp")
build_test("ttoluapp.cpp")
build_test("tnamespace.cpp")
build_test("tenum.c")
endif()
30 changes: 30 additions & 0 deletions src/tests/tenum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "lualib.h"
#include "lauxlib.h"

#include "tenum.h"

Status checkenum (Order o)
{
if (o == FIRST)
return TRUE;
else
return FALSE;
}

int main (void)
{
int errcode = 0;
int tolua_tenum_open (lua_State*);
lua_State* L = luaL_newstate();

luaL_openlibs(L);
tolua_tenum_open(L);

if (luaL_dofile(L,"tenum.lua") != 0) {
fprintf(stderr, "%s", lua_tostring(L,-1));
errcode = 1;
}

lua_close(L);
return errcode;
}
17 changes: 17 additions & 0 deletions src/tests/tenum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef tenum_h
#define tenum_h


typedef enum {
FIRST,
SECOND
} Order;

typedef enum {
FALSE,
TRUE
} Status;

Status checkenum (Order o);

#endif
7 changes: 7 additions & 0 deletions src/tests/tenum.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local a = FIRST
local b = SECOND

assert(checkenum(a)==TRUE)
assert(checkenum(b)==FALSE)

print("Enum test OK")
13 changes: 13 additions & 0 deletions src/tests/tenum.pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$#include "tenum.h"

enum Order {
FIRST,
SECOND
};

typedef enum {
FALSE,
TRUE
} Status;

Status checkenum (Order o);

0 comments on commit 46a5f19

Please sign in to comment.