mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Remove tests
Tests were quite old, used very simple framework which did not allow much fidelity and were probably never executed.
This commit is contained in:
committed by
IntelOrca
parent
c7128a95ed
commit
d29faf25c4
@@ -118,7 +118,7 @@ endif (USE_LODEPNG)
|
||||
# include lib
|
||||
include_directories("lib/")
|
||||
# add source files
|
||||
file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "lib/argparse/*.c" "lib/cutest/*.c" ${LODEPNG_SOURCES})
|
||||
file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "lib/argparse/*.c" ${LODEPNG_SOURCES})
|
||||
if (APPLE)
|
||||
file(GLOB_RECURSE ORCT2_MM_SOURCES "src/*.m")
|
||||
set_source_files_properties(${ORCT2_MM_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c -fmodules")
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2015 Marco Costa
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* This file is part of OpenRCT2.
|
||||
*
|
||||
* OpenRCT2 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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../../src/addresses.h"
|
||||
#include "../../src/management/finance.h"
|
||||
#include "../../src/openrct2.h"
|
||||
#include "../../src/scenario.h"
|
||||
|
||||
#include "finance_test.h"
|
||||
|
||||
void test_finance_setup(CuTest* tc) {
|
||||
test_load_scenario(tc, "Build your own Six Flags Park.SC6");
|
||||
}
|
||||
|
||||
void test_finance_loan_increase(CuTest* tc) {
|
||||
money32 initialCash = finance_get_current_cash();
|
||||
money32 initialLoan = finance_get_current_loan();
|
||||
|
||||
money32 newLoan = finance_get_maximum_loan();
|
||||
finance_set_loan(newLoan);
|
||||
|
||||
money32 actual = finance_get_current_loan();
|
||||
CuAssertIntEquals(tc, newLoan, actual);
|
||||
|
||||
money32 actualCash = finance_get_current_cash();
|
||||
CuAssertIntEquals(tc, initialCash + newLoan - initialLoan, actualCash);
|
||||
}
|
||||
|
||||
void test_finance_loan_pay_back(CuTest* tc) {
|
||||
money32 initialCash = finance_get_current_cash();
|
||||
money32 initialLoan = finance_get_current_loan();
|
||||
|
||||
money32 newLoan = MONEY(0, 00);
|
||||
finance_set_loan(newLoan);
|
||||
|
||||
money32 actual = finance_get_current_loan();
|
||||
CuAssertIntEquals(tc, newLoan, actual);
|
||||
|
||||
money32 actualCash = finance_get_current_cash();
|
||||
CuAssertIntEquals(tc, MONEY(0, 00), actualCash);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2015 Marco Costa
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* This file is part of OpenRCT2.
|
||||
*
|
||||
* OpenRCT2 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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _FINANCE_TEST_H_
|
||||
#define _FINANCE_TEST_H_
|
||||
|
||||
#include "../tests.h"
|
||||
|
||||
void test_finance_setup(CuTest* tc);
|
||||
void test_finance_loan_increase(CuTest* tc);
|
||||
void test_finance_loan_pay_back(CuTest* tc);
|
||||
|
||||
#endif
|
||||
@@ -1,38 +0,0 @@
|
||||
#include "../../src/ride/ride_ratings.h"
|
||||
#include "../../src/localisation/localisation.h"
|
||||
|
||||
#include "ride_ratings_test.h"
|
||||
|
||||
void test_ride_ratings_setup(CuTest* tc) {
|
||||
test_load_scenario(tc, "Six Flags Magic Mountain.SC6");
|
||||
}
|
||||
|
||||
void test_ride_ratings(CuTest* tc) {
|
||||
int i;
|
||||
rct_ride *ride;
|
||||
rating_tuple *rideRatings = malloc(256 * sizeof(rating_tuple));
|
||||
char rideName[256];
|
||||
char buffer[256];
|
||||
|
||||
// Store original ride ratings
|
||||
FOR_ALL_RIDES(i, ride)
|
||||
rideRatings[i] = ride->ratings;
|
||||
|
||||
// Update all the ride ratings
|
||||
// TODO use a better function that can just be called once for each ride
|
||||
for (int i = 0; i < MAX_RIDES * 10; i++)
|
||||
ride_ratings_update_all();
|
||||
|
||||
FOR_ALL_RIDES(i, ride) {
|
||||
format_string(rideName, ride->name, &ride->name_arguments);
|
||||
|
||||
sprintf(buffer, "[%s.excitement]", rideName);
|
||||
CuAssertIntEquals_Msg(tc, buffer, rideRatings[i].excitement, ride->excitement);
|
||||
sprintf(buffer, "[%s.intensity]", rideName);
|
||||
CuAssertIntEquals_Msg(tc, buffer, rideRatings[i].intensity, ride->intensity);
|
||||
sprintf(buffer, "[%s.nausea]", rideName);
|
||||
CuAssertIntEquals_Msg(tc, buffer, rideRatings[i].nausea, ride->nausea);
|
||||
}
|
||||
|
||||
free(rideRatings);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#ifndef _RIDE_RATINGS_TEST_H_
|
||||
#define _RIDE_RATINGS_TEST_H_
|
||||
|
||||
#include "../tests.h"
|
||||
|
||||
void test_ride_ratings_setup(CuTest* tc);
|
||||
void test_ride_ratings(CuTest* tc);
|
||||
|
||||
#endif
|
||||
76
test/tests.c
76
test/tests.c
@@ -1,76 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2015 Marco Costa
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* This file is part of OpenRCT2.
|
||||
*
|
||||
* OpenRCT2 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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../src/openrct2.h"
|
||||
#include "management/finance_test.h"
|
||||
#include "ride/ride_ratings_test.h"
|
||||
|
||||
int cmdline_for_test(const char **argv, int argc)
|
||||
{
|
||||
// NOTE Currently all tests are running in a OpenRCT2 setup frame. Tests for the initialisation and disposing should be
|
||||
// separate and independent.
|
||||
|
||||
int numFailedTests;
|
||||
|
||||
gOpenRCT2Headless = true;
|
||||
if (openrct2_initialise()) {
|
||||
numFailedTests = run_all_tests();
|
||||
|
||||
openrct2_dispose();
|
||||
}
|
||||
return numFailedTests > 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
CuSuite* new_suite(void)
|
||||
{
|
||||
CuSuite* suite = CuSuiteNew();
|
||||
|
||||
// Test Finance
|
||||
SUITE_ADD_TEST(suite, test_finance_setup);
|
||||
SUITE_ADD_TEST(suite, test_finance_loan_increase);
|
||||
SUITE_ADD_TEST(suite, test_finance_loan_pay_back);
|
||||
|
||||
// Test Ride
|
||||
SUITE_ADD_TEST(suite, test_ride_ratings_setup);
|
||||
SUITE_ADD_TEST(suite, test_ride_ratings);
|
||||
|
||||
// Future Tests:
|
||||
// Test X
|
||||
// SUITE_ADD_TEST(suite, test_X_setup);
|
||||
// SUITE_ADD_TEST(suite, test_X_Y);
|
||||
// SUITE_ADD_TEST(suite, test_X_Z);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
int run_all_tests(void)
|
||||
{
|
||||
CuString *output = CuStringNew();
|
||||
CuSuite* suite = CuSuiteNew();
|
||||
|
||||
CuSuiteAddSuite(suite, new_suite());
|
||||
|
||||
CuSuiteRun(suite);
|
||||
CuSuiteSummary(suite, output);
|
||||
CuSuiteDetails(suite, output);
|
||||
printf("Test results:\n%s\n", output->buffer);
|
||||
|
||||
return suite->failCount;
|
||||
}
|
||||
43
test/tests.h
43
test/tests.h
@@ -1,43 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2015 Marco Costa
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* This file is part of OpenRCT2.
|
||||
*
|
||||
* OpenRCT2 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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _TESTS_H_
|
||||
#define _TESTS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <CuTest.h>
|
||||
#include "../src/common.h"
|
||||
|
||||
int cmdline_for_test(const char **argv, int argc);
|
||||
int run_all_tests();
|
||||
|
||||
// Test utilities
|
||||
|
||||
#include "../src/scenario.h"
|
||||
|
||||
static void test_load_scenario(CuTest* tc, const char* file_name) {
|
||||
const scenario_index_entry* scenario = scenario_list_find_by_path(file_name);
|
||||
if (scenario == NULL) {
|
||||
CuFail(tc, "Could not load scenario");
|
||||
}
|
||||
scenario_load_and_play_from_path(scenario->name);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user