From 9b01b71a19b46b2996699c0e3ac6aba0af019dfe Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 27 Jun 2014 07:36:18 -0700 Subject: [PATCH] config returns a value, so we can assert corrrect JSON syntax --- src/config.pkg | 4 ++-- src/config.pkg.c | 10 ++++++---- tests/ships.lua | 9 +++++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/config.pkg b/src/config.pkg index 26f67c481..5c9e1ff33 100644 --- a/src/config.pkg +++ b/src/config.pkg @@ -3,8 +3,8 @@ $#include "bind_config.h" module eressea { module config { void config_reset @ reset(void); - void config_read @ read(const char *filename); - void config_parse @ parse(const char *json); + int config_read @ read(const char *filename); + int config_parse @ parse(const char *json); } } diff --git a/src/config.pkg.c b/src/config.pkg.c index d1f3aa0c6..e9ebccd10 100644 --- a/src/config.pkg.c +++ b/src/config.pkg.c @@ -64,10 +64,11 @@ static int tolua_config_eressea_config_read00(lua_State* tolua_S) { const char* filename = ((const char*) tolua_tostring(tolua_S,1,0)); { - config_read(filename); + int tolua_ret = (int) config_read(filename); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } - return 0; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'read'.",&tolua_err); @@ -90,10 +91,11 @@ static int tolua_config_eressea_config_parse00(lua_State* tolua_S) { const char* json = ((const char*) tolua_tostring(tolua_S,1,0)); { - config_parse(json); + int tolua_ret = (int) config_parse(json); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } - return 0; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'parse'.",&tolua_err); diff --git a/tests/ships.lua b/tests/ships.lua index 6bc92983f..4dae533b2 100644 --- a/tests/ships.lua +++ b/tests/ships.lua @@ -3,7 +3,7 @@ require "lunit" module("tests.ships", package.seeall, lunit.testcase) function setup() - eressea.free_game() + eressea.game.reset() eressea.settings.set("nmr.removenewbie", "0") eressea.settings.set("nmr.timeout", "0") eressea.settings.set("rules.ships.storms", "0") @@ -39,11 +39,16 @@ function setup() "de" : { "move" : "NACH" } + }, + "strings" : { + "de" : { + "harbour" : "Hafen" + } } }]] eressea.config.reset() - eressea.config.parse(conf) + assert(eressea.config.parse(conf)==0) end function test_sail_oceans()