1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include <random>
#include "catch_amalgamated.hpp"
#include "AppHdr.h"
#include "randbook.h"
#include "spl-book.h"
#include "spl-util.h"
TEST_CASE( "When setting book spell list", "[single-file]" ) {
item_def book;
SECTION("spells will be padded with SPELL_NO_SPELL") {
init_spell_descs();
vector<spell_type> spells = {SPELL_MAGIC_DART, SPELL_CAUSE_FEAR};
_set_book_spell_list(book, spells);
const auto& book_spells = book.props[SPELL_LIST_KEY].get_vector();
REQUIRE(book_spells.size() == RANDBOOK_SIZE);
for (auto i = 2; i < RANDBOOK_SIZE; i++ )
REQUIRE(book_spells[i].get_int() == SPELL_NO_SPELL);
}
SECTION("the spell list will be truncated to RANDBOOK_SIZE entries") {
init_spell_descs();
vector<spell_type> spells = {
SPELL_FREEZE,
SPELL_SOUL_SPLINTER,
SPELL_APPORTATION,
SPELL_SUMMON_SMALL_MAMMAL,
SPELL_MAGIC_DART,
SPELL_SHOCK,
SPELL_SANDBLAST,
SPELL_FOXFIRE,
SPELL_STING,
};
_set_book_spell_list(book, spells);
const auto& book_spells = book.props[SPELL_LIST_KEY].get_vector();
REQUIRE(book_spells.size() == RANDBOOK_SIZE);
}
}
|