2015-04-16 02:55:27 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include<Eina.h>
|
|
|
|
#include "Elua.h"
|
|
|
|
#include "elua_suite.h"
|
|
|
|
|
2015-04-16 07:11:43 -07:00
|
|
|
/* Untestable APIs:
|
|
|
|
*
|
|
|
|
* void elua_state_include_path_add(Elua_State *, const char *);
|
|
|
|
*/
|
|
|
|
|
2015-04-16 05:45:08 -07:00
|
|
|
START_TEST(elua_api)
|
2015-04-16 02:55:27 -07:00
|
|
|
{
|
2015-04-16 06:02:21 -07:00
|
|
|
Elua_State *st;
|
|
|
|
lua_State *lst;
|
|
|
|
|
2015-04-16 05:45:08 -07:00
|
|
|
fail_if(!elua_init());
|
|
|
|
|
2015-04-16 06:02:21 -07:00
|
|
|
st = elua_state_new("test");
|
2015-04-16 05:45:08 -07:00
|
|
|
fail_if(!st);
|
|
|
|
|
2015-04-16 07:08:02 -07:00
|
|
|
/* test env vars */
|
|
|
|
setenv("ELUA_CORE_DIR", "foo", 1);
|
|
|
|
setenv("ELUA_MODULES_DIR", "bar", 1);
|
|
|
|
setenv("ELUA_APPS_DIR", "baz", 1);
|
|
|
|
elua_state_dirs_fill(st, EINA_FALSE);
|
|
|
|
fail_if(strcmp(elua_state_core_dir_get(st), "foo"));
|
|
|
|
fail_if(strcmp(elua_state_mod_dir_get(st), "bar"));
|
|
|
|
fail_if(strcmp(elua_state_apps_dir_get(st), "baz"));
|
|
|
|
|
|
|
|
/* now fill it properly */
|
2015-04-16 06:58:42 -07:00
|
|
|
elua_state_dirs_set(st, ELUA_CORE_DIR, ELUA_MODULES_DIR, ELUA_APPS_DIR);
|
|
|
|
fail_if(strcmp(elua_state_core_dir_get(st), ELUA_CORE_DIR));
|
|
|
|
fail_if(strcmp(elua_state_mod_dir_get(st), ELUA_MODULES_DIR));
|
|
|
|
fail_if(strcmp(elua_state_apps_dir_get(st), ELUA_APPS_DIR));
|
|
|
|
|
2015-04-16 06:02:21 -07:00
|
|
|
lst = elua_state_lua_state_get(st);
|
|
|
|
fail_if(!lst);
|
|
|
|
|
|
|
|
fail_if(elua_state_from_lua_state_get(lst) != st);
|
|
|
|
|
2015-04-16 06:08:28 -07:00
|
|
|
fail_if(strcmp(elua_state_prog_name_get(st), "test"));
|
|
|
|
|
2015-04-16 07:11:43 -07:00
|
|
|
fail_if(!elua_state_modules_setup(st));
|
|
|
|
fail_if(!elua_state_i18n_setup(st));
|
|
|
|
fail_if(!elua_state_io_setup(st));
|
|
|
|
|
2015-04-16 05:45:08 -07:00
|
|
|
elua_state_free(st);
|
|
|
|
|
|
|
|
elua_shutdown();
|
2015-04-16 02:55:27 -07:00
|
|
|
}
|
2015-04-16 05:45:08 -07:00
|
|
|
END_TEST
|
2015-04-16 02:55:27 -07:00
|
|
|
|
|
|
|
void elua_lib_test(TCase *tc)
|
|
|
|
{
|
2015-04-16 05:45:08 -07:00
|
|
|
tcase_add_test(tc, elua_api);
|
2015-04-16 02:55:27 -07:00
|
|
|
}
|
|
|
|
|