Group tests by module
That is to reduce total number of executables.
This commit is contained in:
parent
b4432595b4
commit
9cacd1ddd0
5 changed files with 61 additions and 49 deletions
|
@ -15,11 +15,16 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE streamreader
|
||||
/** @file
|
||||
* Tests for libcommon classes.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE common
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include "../engine/common/streamreader.h"
|
||||
#include "../engine/common/timer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -27,7 +32,9 @@ using namespace reone;
|
|||
|
||||
namespace endian = boost::endian;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_get_little_endian) {
|
||||
// StreamReader
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StreamReader_GetLE) {
|
||||
auto stream = make_shared<istringstream>(string("\x01" "\xe8\x03" "\xa0\x86\x01\x00" "\x00\xe4\x0b\x54\x02\x00\x00\x00" "\x60\x79\xfe\xff" "\x00\x00\x80\x3f" "abc\0defgh", 32));
|
||||
StreamReader reader(stream);
|
||||
BOOST_TEST((reader.getByte() == 0x01));
|
||||
|
@ -40,7 +47,7 @@ BOOST_AUTO_TEST_CASE(test_get_little_endian) {
|
|||
BOOST_TEST((reader.getString(3) == "def"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_get_big_endian) {
|
||||
BOOST_AUTO_TEST_CASE(StreamReader_GetBE) {
|
||||
auto stream = make_shared<istringstream>(string("\x03\xe8" "\x00\x01\x86\xa0" "\x00\x00\x00\x02\x54\x0b\xe4\x00" "\xff\xfe\x79\x60" "\x3f\x80\x00\x00", 22));
|
||||
StreamReader reader(stream, endian::order::big);
|
||||
BOOST_TEST((reader.getUint16() == 1000u));
|
||||
|
@ -49,3 +56,21 @@ BOOST_AUTO_TEST_CASE(test_get_big_endian) {
|
|||
BOOST_TEST((reader.getInt32() == -100000));
|
||||
BOOST_TEST((reader.getFloat() == 1.0f));
|
||||
}
|
||||
|
||||
// END StreamReader
|
||||
|
||||
// Timer
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Timer_TimesOut) {
|
||||
Timer timer(1.0f);
|
||||
|
||||
timer.advance(0.5f);
|
||||
|
||||
BOOST_TEST(!timer.isTimedOut());
|
||||
|
||||
timer.advance(0.6f);
|
||||
|
||||
BOOST_TEST(timer.isTimedOut());
|
||||
}
|
||||
|
||||
// END Timer
|
|
@ -15,7 +15,11 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE pathfinder
|
||||
/** @file
|
||||
* Tests for libgame classes.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE game
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
|
@ -27,7 +31,9 @@ using namespace std;
|
|||
using namespace reone::game;
|
||||
using namespace reone::resource;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_find_path) {
|
||||
// Pathfinder
|
||||
|
||||
BOOST_AUTO_TEST_CASE(PathFinder_FindPath) {
|
||||
vector<Path::Point> points = {
|
||||
{ 1.0f, 1.0f, { 1, 2 } },
|
||||
{ 1.0f, 2.0f, { 0, 2 } },
|
||||
|
@ -55,7 +61,7 @@ BOOST_AUTO_TEST_CASE(test_find_path) {
|
|||
BOOST_TEST(found);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(find_path_when_no_points_then_from_to_returned) {
|
||||
BOOST_AUTO_TEST_CASE(PathFinder_FindPath_NoPoints) {
|
||||
Pathfinder pathfinder;
|
||||
pathfinder.load({}, {});
|
||||
|
||||
|
@ -70,3 +76,5 @@ BOOST_AUTO_TEST_CASE(find_path_when_no_points_then_from_to_returned) {
|
|||
|
||||
BOOST_TEST(found);
|
||||
}
|
||||
|
||||
// END Pathfinder
|
|
@ -15,7 +15,11 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE gffwriter
|
||||
/** @file
|
||||
* Tests for libresource classes.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE resource
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
|
@ -26,9 +30,12 @@ using namespace std;
|
|||
|
||||
using namespace reone::resource;
|
||||
|
||||
namespace endian = boost::endian;
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_save_load) {
|
||||
// GffStruct
|
||||
|
||||
BOOST_AUTO_TEST_CASE(GffStruct_SaveLoad) {
|
||||
auto struct1 = make_shared<GffStruct>(0);
|
||||
GffStruct::Field struct1Field(GffStruct::FieldType::Byte, "MyByte"); struct1Field.uintValue = 1;
|
||||
struct1->add(move(struct1Field));
|
||||
|
@ -69,3 +76,5 @@ BOOST_AUTO_TEST_CASE(test_save_load) {
|
|||
BOOST_TEST((readRoot->fields()[1].children[0]->fields()[0].uintValue == 2));
|
||||
BOOST_TEST((readRoot->fields()[1].children[1]->fields()[0].uintValue == 3));
|
||||
}
|
||||
|
||||
// END GffStruct
|
|
@ -15,7 +15,11 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE scriptexecution
|
||||
/** @file
|
||||
* Tests for libscript classes.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE script
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
|
@ -25,7 +29,9 @@ using namespace std;
|
|||
|
||||
using namespace reone::script;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_destruct) {
|
||||
// ScriptExecution
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ScriptExecution_Destruct) {
|
||||
Instruction instr;
|
||||
auto program = make_shared<ScriptProgram>("");
|
||||
|
||||
|
@ -69,7 +75,7 @@ BOOST_AUTO_TEST_CASE(test_destruct) {
|
|||
BOOST_TEST((execution.getStackVariable(0).intValue == 1));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_cptopbp) {
|
||||
BOOST_AUTO_TEST_CASE(ScriptExecution_CopyTopBp) {
|
||||
Instruction instr;
|
||||
auto program = make_shared<ScriptProgram>("");
|
||||
|
||||
|
@ -113,3 +119,5 @@ BOOST_AUTO_TEST_CASE(test_cptopbp) {
|
|||
BOOST_TEST((execution.getStackVariable(4).intValue == 1));
|
||||
BOOST_TEST((execution.getStackVariable(5).intValue == 2));
|
||||
}
|
||||
|
||||
// END ScriptExecution
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021 The reone project contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE timer
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include "../engine/common/timer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace reone;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_timer_times_out) {
|
||||
Timer timer(1.0f);
|
||||
|
||||
timer.advance(0.5f);
|
||||
|
||||
BOOST_TEST(!timer.isTimedOut());
|
||||
|
||||
timer.advance(0.6f);
|
||||
|
||||
BOOST_TEST(timer.isTimedOut());
|
||||
}
|
Loading…
Reference in a new issue