From d29faf25c41ea64ed5f1b398b3e000ea63abc720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 9 Jan 2016 20:22:58 +0100 Subject: [PATCH] Remove tests Tests were quite old, used very simple framework which did not allow much fidelity and were probably never executed. --- CMakeLists.txt | 2 +- test/management/finance_test.c | 60 --------------------------- test/management/finance_test.h | 30 -------------- test/ride/ride_ratings_test.c | 38 ----------------- test/ride/ride_ratings_test.h | 9 ---- test/tests.c | 76 ---------------------------------- test/tests.h | 43 ------------------- 7 files changed, 1 insertion(+), 257 deletions(-) delete mode 100644 test/management/finance_test.c delete mode 100644 test/management/finance_test.h delete mode 100644 test/ride/ride_ratings_test.c delete mode 100644 test/ride/ride_ratings_test.h delete mode 100644 test/tests.c delete mode 100644 test/tests.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f1d51d61e..2d28d66784 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/test/management/finance_test.c b/test/management/finance_test.c deleted file mode 100644 index 0772dfb0ff..0000000000 --- a/test/management/finance_test.c +++ /dev/null @@ -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 . -*****************************************************************************/ - -#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); -} - - diff --git a/test/management/finance_test.h b/test/management/finance_test.h deleted file mode 100644 index 482d31d390..0000000000 --- a/test/management/finance_test.h +++ /dev/null @@ -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 . -*****************************************************************************/ - -#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 diff --git a/test/ride/ride_ratings_test.c b/test/ride/ride_ratings_test.c deleted file mode 100644 index 9282d6be07..0000000000 --- a/test/ride/ride_ratings_test.c +++ /dev/null @@ -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); -} diff --git a/test/ride/ride_ratings_test.h b/test/ride/ride_ratings_test.h deleted file mode 100644 index ed19312ce8..0000000000 --- a/test/ride/ride_ratings_test.h +++ /dev/null @@ -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 diff --git a/test/tests.c b/test/tests.c deleted file mode 100644 index 6963f14517..0000000000 --- a/test/tests.c +++ /dev/null @@ -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 . -*****************************************************************************/ - -#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; -} diff --git a/test/tests.h b/test/tests.h deleted file mode 100644 index 06619ec167..0000000000 --- a/test/tests.h +++ /dev/null @@ -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 . -*****************************************************************************/ - -#ifndef _TESTS_H_ -#define _TESTS_H_ - -#include -#include -#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