From 2bf3c840aee51bce17302d4140440325ffa4cb36 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 5 Jun 2012 07:36:05 -0700 Subject: [PATCH] beware: new directory layout, new server --- scripts/tests/attrib.lua | 53 +++++++++++++++++++ scripts/tests/bson.lua | 2 +- scripts/tests/common.lua | 2 +- scripts/tests/spells.lua | 108 ++++----------------------------------- src/CMakeLists.txt | 6 +++ 5 files changed, 72 insertions(+), 99 deletions(-) create mode 100644 scripts/tests/attrib.lua diff --git a/scripts/tests/attrib.lua b/scripts/tests/attrib.lua new file mode 100644 index 000000000..b86efa734 --- /dev/null +++ b/scripts/tests/attrib.lua @@ -0,0 +1,53 @@ +require "lunit" + +module("tests.eressea.attrib", package.seeall, lunit.testcase) + +function has_attrib(u, value) + for a in u.attribs do + if (a.data==value) then return true end + end + return false +end + +function test_attrib_global() + a = attrib.create('global', {}) + write_game('attrib.dat') + free_game() + read_game('attrib.dat') +end + +function test_attrib() + local r = region.create(0,0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + data = { arr = { 'a', 'b', 'c' }, name = 'familiar', events = { die = 'familiar_died' }, data = { mage = u2 } } + a = { 'a' } + b = { 'a' } + uno = u.id + u2no = u2.id + a = attrib.create(u, 12) + a = attrib.create(u, "enno") + a = attrib.create(u, u2) + a = attrib.create(u, data) + write_game("attrib.dat") + free_game() + read_game("attrib.dat") + u = get_unit(uno) + u2 = get_unit(u2no) + assert_false(has_attrib(u, 42)) + assert_true(has_attrib(u, "enno")) + assert_true(has_attrib(u, 12)) + + for a in u.attribs do + x = a.data + if (type(x)=="table") then + assert_equal('a', x.arr[1]) + assert_equal('familiar', x.name) + assert_equal('familiar_died', x.events.die) + assert_equal(u2, x.data.mage) + break + end + end +end + diff --git a/scripts/tests/bson.lua b/scripts/tests/bson.lua index 0ee6e6e2e..f199ee7d0 100644 --- a/scripts/tests/bson.lua +++ b/scripts/tests/bson.lua @@ -1,6 +1,6 @@ require "lunit" -module("tests.bson", package.seeall, lunit.testcase) +module("tests.eressea.bson", package.seeall, lunit.testcase) function setup() free_game() diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 635b06f34..59b9b68e9 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -35,7 +35,7 @@ local function two_factions() return f1, f2 end -module("tests.common", package.seeall, lunit.testcase) +module("tests.eressea.common", package.seeall, lunit.testcase) function setup() free_game() diff --git a/scripts/tests/spells.lua b/scripts/tests/spells.lua index d8b446ace..f27b18df7 100644 --- a/scripts/tests/spells.lua +++ b/scripts/tests/spells.lua @@ -1,20 +1,23 @@ require "lunit" -module("tests.spells", package.seeall, lunit.testcase) +module("tests.eressea.spells", package.seeall, lunit.testcase) + +local r, f, u function setup() free_game() - settings.set("magic.fumble.enable", "0") settings.set("magic.regeneration.enable", "0") + settings.set("magic.fumble.enable", "0") settings.set("rules.economy.food", "4") + + r = region.create(0, 0, "plain") + f = faction.create("spell_payment@eressea.de", "elf", "de") + u = unit.create(f, r, 1) + u.magic = "gray" + u:set_skill("magic", 12) end function test_spell_payment() - local r = region.create(0,0, "plain") - local f = faction.create("spell_payment@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:set_skill("magic", 12) - u.magic = "gwyrrd" -- calls create_mage u:add_spell("create_roi") local permaura = u:get_pooled("permaura") @@ -23,7 +26,7 @@ function test_spell_payment() u:clear_orders() u:add_order("ZAUBERE 'Erschaffe einen Ring der Unsichtbarkeit' ") process_orders() - + write_reports() assert_equal(1, u:get_item("roi")) assert_equal(0, u:get_item("money")) assert_equal(0, u.aura) @@ -31,12 +34,6 @@ function test_spell_payment() end function test_spell_not_found_no_payment() - local r = region.create(0,0, "plain") - local f = faction.create("spell_fails_no_payment@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 12) - local permaura = u:get_pooled("permaura") u:add_item("money", 3000) u.aura = 50 @@ -51,132 +48,49 @@ function test_spell_not_found_no_payment() assert_equal(permaura, u:get_pooled("permaura")) end -function test_create_firesword() - local r = region.create(0,0, "plain") - local f = faction.create("create_firesword@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 12) - u:add_spell("create_firesword") - - u:cast_spell('create_firesword', 1) - assert_equal(1, u:get_item("firesword")) -end - function test_create_roi() - local r = region.create(0,0, "plain") - local f = faction.create("create_roi@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 10) - u:add_spell('create_roi') u:cast_spell('create_roi') assert_equal(1, u:get_item("roi")) end function test_create_roqf() - local r = region.create(0,0, "plain") - local f = faction.create("create_roqf@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 10) - u:add_spell('create_roqf') u:cast_spell('create_roqf') assert_equal(1, u:get_item("roqf")) end function test_create_aots() - local r = region.create(0,0, "plain") - local f = faction.create("create_aots@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 10) - u:add_spell('create_aots') u:cast_spell('create_aots') assert_equal(1, u:get_item("aots")) end function test_create_ror() - local r = region.create(0,0, "plain") - local f = faction.create("create_ror@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 10) - u:add_spell('create_ror') u:cast_spell('create_ror') assert_equal(1, u:get_item("ror")) end -function test_create_magicherbbag() - local r = region.create(0,0, "plain") - local f = faction.create("create_magicherbbag@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 10) - - u:add_spell('create_magicherbbag') - u:cast_spell('create_magicherbbag') - assert_equal(1, u:get_item("magicherbbag")) -end - function test_create_trollbelt() - local r = region.create(0,0, "plain") - local f = faction.create("create_trollbelt@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 10) - u:add_spell('create_trollbelt') u:cast_spell('create_trollbelt') assert_equal(1, u:get_item("trollbelt")) end function test_create_dreameye() - local r = region.create(0,0, "plain") - local f = faction.create("create_dreameye@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 10) - u:add_spell('create_dreameye') u:cast_spell('create_dreameye') assert_equal(1, u:get_item("dreameye")) end function test_create_antimagic() - local r = region.create(0,0, "plain") - local f = faction.create("create_antimagic@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 10) - u:add_spell('create_antimagic') u:cast_spell('create_antimagic') assert_equal(1, u:get_item("antimagic")) end -function test_create_runesword() - local r = region.create(0,0, "plain") - local f = faction.create("create_runesword@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u.magic = "gwyrrd" -- calls create_mage - u:set_skill("magic", 10) - - u:add_spell('create_runesword') - u:cast_spell('create_runesword') - assert_equal(1, u:get_item("runesword")) -end - function test_create_rop() - local r = region.create(0,0, "plain") - local f = faction.create("create_rop@eressea.de", "human", "de") - local u = unit.create(f, r, 1) - u:set_skill("magic", 10) - u:add_spell('create_rop') u:cast_spell('create_rop') assert_equal(1, u:get_item("rop")) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e187bdc54..72af6a1ee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,12 @@ cmake_minimum_required(VERSION 2.6) project (eressea C) +IF(CMAKE_COMPILER_IS_GNUCC) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") +ELSE(CMAKE_COMPILER_IS_GNUCC) + MESSAGE(STATUS "Unknown compiler ${CMAKE_C_COMPILER_ID}") +ENDIF(CMAKE_COMPILER_IS_GNUCC) + set (ERESSEA_LIBRARY ${PROJECT_NAME} CACHE INTERNAL "Eressea Core Library") set (ERESSEA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "Eressea Core headers")