diff --git a/projects/language/language.vcxproj b/projects/language/language.vcxproj
index 74671ec40e..b37e1107f4 100644
--- a/projects/language/language.vcxproj
+++ b/projects/language/language.vcxproj
@@ -5,6 +5,10 @@
Debug
Win32
+
+ Release with Tests
+ Win32
+
Release
Win32
@@ -28,6 +32,13 @@
true
MultiByte
+
+ Utility
+ false
+ v120
+ true
+ MultiByte
+
@@ -37,6 +48,9 @@
+
+
+
$(SolutionDir)..\build\$(Configuration)\
@@ -46,6 +60,10 @@
$(SolutionDir)..\build\$(Configuration)\
$(SolutionDir)..\obj\$(ProjectName)\$(Configuration)\
+
+ $(SolutionDir)..\build\Release\
+ $(SolutionDir)..\obj\$(ProjectName)\Release\
+
Level3
@@ -73,6 +91,23 @@
xcopy /Y "$(SolutionDir)\..\Data\Language\*.*" "$(TargetDir)\Data\Language\"
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+
+
+ xcopy /Y "$(SolutionDir)\..\Data\Language\*.*" "$(TargetDir)\Data\Language\"
+
+
diff --git a/projects/libs/libs.vcxproj b/projects/libs/libs.vcxproj
index 4ede5f73ef..c1ae556f71 100644
--- a/projects/libs/libs.vcxproj
+++ b/projects/libs/libs.vcxproj
@@ -5,6 +5,10 @@
Debug
Win32
+
+ Release with Tests
+ Win32
+
Release
Win32
@@ -28,6 +32,13 @@
true
MultiByte
+
+ StaticLibrary
+ false
+ v120
+ true
+ MultiByte
+
@@ -37,6 +48,9 @@
+
+
+
$(SolutionDir)..\build\$(Configuration)\
@@ -49,6 +63,12 @@
..\..\lib\libcurl\include;..\..\lib\jansson;..\..\lib\cutest\CuTest.h;$(IncludePath)
..\..\lib\libcurl\lib;$(LibraryPath)
+
+ $(SolutionDir)..\build\Release\
+ $(SolutionDir)..\obj\$(ProjectName)\Release\
+ ..\..\lib\libcurl\include;..\..\lib\jansson;..\..\lib\cutest\CuTest.h;$(IncludePath)
+ ..\..\lib\libcurl\lib;$(LibraryPath)
+
Level3
@@ -87,10 +107,36 @@
Powershell -NonInteractive -ExecutionPolicy "ByPass" -File "$(ProjectDir)../../pre-build.ps1"
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ true
+ _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;NS_ENABLE_THREADS;NS_ENABLE_SSL;DISABLE_MD5;%(PreprocessorDefinitions)
+ MultiThreaded
+ 1Byte
+
+
+
+
+ true
+ true
+ true
+
+
+ libcurl.lib;Ws2_32.lib;%(AdditionalDependencies)
+
+
+ Powershell -NonInteractive -ExecutionPolicy "ByPass" -File "$(ProjectDir)../../pre-build.ps1"
+
+
TurnOffAllWarnings
TurnOffAllWarnings
+ TurnOffAllWarnings
@@ -107,6 +153,7 @@
TurnOffAllWarnings
TurnOffAllWarnings
+ TurnOffAllWarnings
diff --git a/projects/libs/libs.vcxproj.filters b/projects/libs/libs.vcxproj.filters
index 3f0add7eba..feaf95a9ee 100644
--- a/projects/libs/libs.vcxproj.filters
+++ b/projects/libs/libs.vcxproj.filters
@@ -119,8 +119,6 @@
jansson
-
- cutest
-
+
\ No newline at end of file
diff --git a/projects/openrct2.sln b/projects/openrct2.sln
index e423a34ab2..67248e41b4 100644
--- a/projects/openrct2.sln
+++ b/projects/openrct2.sln
@@ -15,19 +15,26 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
+ Release with Tests|Win32 = Release with Tests|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.ActiveCfg = Debug|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.Build.0 = Debug|Win32
+ {D24D94F6-2A74-480C-B512-629C306CE92F}.Release with Tests|Win32.ActiveCfg = Release with Tests|Win32
+ {D24D94F6-2A74-480C-B512-629C306CE92F}.Release with Tests|Win32.Build.0 = Release with Tests|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.ActiveCfg = Release|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32
{0468FC1E-5881-4DB9-9DDE-1892290B31D9}.Debug|Win32.ActiveCfg = Debug|Win32
{0468FC1E-5881-4DB9-9DDE-1892290B31D9}.Debug|Win32.Build.0 = Debug|Win32
+ {0468FC1E-5881-4DB9-9DDE-1892290B31D9}.Release with Tests|Win32.ActiveCfg = Release with Tests|Win32
+ {0468FC1E-5881-4DB9-9DDE-1892290B31D9}.Release with Tests|Win32.Build.0 = Release with Tests|Win32
{0468FC1E-5881-4DB9-9DDE-1892290B31D9}.Release|Win32.ActiveCfg = Release|Win32
{0468FC1E-5881-4DB9-9DDE-1892290B31D9}.Release|Win32.Build.0 = Release|Win32
{074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Debug|Win32.ActiveCfg = Debug|Win32
{074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Debug|Win32.Build.0 = Debug|Win32
+ {074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Release with Tests|Win32.ActiveCfg = Release with Tests|Win32
+ {074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Release with Tests|Win32.Build.0 = Release with Tests|Win32
{074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Release|Win32.ActiveCfg = Release|Win32
{074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj
index d4730df9bb..33c9fdb64e 100644
--- a/projects/openrct2.vcxproj
+++ b/projects/openrct2.vcxproj
@@ -10,6 +10,10 @@
Debug
Win32
+
+ Release with Tests
+ Win32
+
Release
Win32
@@ -40,6 +44,8 @@
+
+
@@ -83,8 +89,9 @@
-
-
+
+
+
@@ -150,6 +157,8 @@
+
+
@@ -180,6 +189,8 @@
+
+
@@ -218,8 +229,9 @@
-
-
+
+
+
@@ -265,6 +277,13 @@
true
MultiByte
+
+ DynamicLibrary
+ false
+ v120
+ true
+ MultiByte
+
@@ -274,6 +293,9 @@
+
+
+
$(SolutionDir)..\lodepng;$(SolutionDir)..\sdl\include;$(SolutionDir)..\libspeex;$(IncludePath)
@@ -289,6 +311,13 @@
+
+ $(SolutionDir)..\lib;$(SolutionDir)..\lib\libspeex;$(SolutionDir)..\lib\sdl\include;$(SolutionDir)..\lib\libcurl\include;$(SolutionDir)..\lib\jansson;$(SolutionDir)..\lib\cutest;$(IncludePath)
+ $(SolutionDir)..\lib\sdl\lib\x86;$(SolutionDir)..\lib\libcurl\lib;$(LibraryPath)
+ $(SolutionDir)..\build\Release\
+ $(SolutionDir)..\obj\$(ProjectName)\Release\
+
+
Level3
@@ -330,6 +359,45 @@
"$(TargetDir)\openrct2.exe" sprite build "$(SolutionDir)\..\Data\g2.dat" "$(SolutionDir)\..\Resources\g2\"
+xcopy /Y "$(SolutionDir)\..\Data\*.*" "$(TargetDir)\Data\"
+ Build g2.dat and copy the Data directory.
+
+
+
+
+
+
+
+
+
+
+
+
+ Level3
+ Disabled
+ true
+ true
+
+
+ MultiThreaded
+ 1Byte
+ 4013
+
+
+ false
+ _CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;ENABLE_TESTS;%(PreprocessorDefinitions)
+ $(IntDir)fake\%(RelativeDir)
+ true
+
+
+ true
+ true
+ true
+ winmm.lib;sdl2.lib;Dsound.lib;%(AdditionalDependencies)
+ /ignore:4099 %(AdditionalOptions)
+
+
+ "$(TargetDir)\openrct2.exe" sprite build "$(SolutionDir)\..\Data\g2.dat" "$(SolutionDir)\..\Resources\g2\"
xcopy /Y "$(SolutionDir)\..\Data\*.*" "$(TargetDir)\Data\"
Build g2.dat and copy the Data directory.
diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters
index eb177f6008..7cad6663ee 100644
--- a/projects/openrct2.vcxproj.filters
+++ b/projects/openrct2.vcxproj.filters
@@ -50,6 +50,9 @@
{73238872-312d-437f-8497-7cb66466d835}
+
+ {c6b9c169-ff2a-41df-9b1c-47d15763c3e2}
+
@@ -462,12 +465,15 @@
Source\Windows
-
+
Test
-
+
Test\Management
+
+ Test\Ride
+
@@ -683,11 +689,14 @@
Source\Interface
-
+
Test
-
+
Test\Management
+
+ Test\Ride
+
\ No newline at end of file
diff --git a/projects/openrct2.vcxproj.user b/projects/openrct2.vcxproj.user
index 2b27afde74..ca410df7e6 100644
--- a/projects/openrct2.vcxproj.user
+++ b/projects/openrct2.vcxproj.user
@@ -7,6 +7,12 @@
+
+ $(TargetDir)
+ WindowsLocalDebugger
+ $(TargetDir)\openrct2.exe
+ test
+
false
diff --git a/src/cmdline.c b/src/cmdline.c
index 4cfb774780..371283956c 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -27,6 +27,15 @@
#include "platform/platform.h"
#include "util/util.h"
+#ifdef ENABLE_TESTS
+ #include "../test/tests.h"
+#else
+ static int cmdline_for_test_error(const char **argv, int argc)
+ {
+ printf("OpenRCT2 has not been built with the test suite.\n");
+ }
+#endif
+
typedef struct tm tm_t;
typedef struct argparse_option argparse_option_t;
typedef struct argparse argparse_t;
@@ -123,13 +132,6 @@ static int cmdline_for_edit(const char **argv, int argc)
return 0;
}
-static int cmdline_for_test(const char **argv, int argc)
-{
- gOpenRCT2StartupAction = STARTUP_ACTION_TEST;
- gOpenRCT2Headless = true;
- return 0;
-}
-
static int cmdline_for_none(const char **argv, int argc)
{
assert(argc >= 1);
@@ -149,7 +151,12 @@ struct { const char *firstArg; cmdline_action action; } cmdline_table[] = {
{ "edit", cmdline_for_edit },
{ "sprite", cmdline_for_sprite },
{ "screenshot", cmdline_for_screenshot },
- { "test", cmdline_for_test }
+
+#ifdef ENABLE_TESTS
+ { "test", cmdline_for_test },
+#else
+ { "test", cmdline_for_test_error },
+#endif
};
static int cmdline_call_action(const char **argv, int argc)
diff --git a/src/openrct2.c b/src/openrct2.c
index 8d25745a24..39f7d5deda 100644
--- a/src/openrct2.c
+++ b/src/openrct2.c
@@ -30,7 +30,6 @@
#include "platform/platform.h"
#include "util/sawyercoding.h"
#include "world/mapgen.h"
-#include "test/tests.h"
int gOpenRCT2StartupAction = STARTUP_ACTION_TITLE;
char gOpenRCT2StartupActionPath[512] = { 0 };
@@ -186,11 +185,6 @@ void openrct2_launch()
editor_load_landscape(gOpenRCT2StartupActionPath);
}
break;
- case STARTUP_ACTION_TEST:
- gExitCode = run_all_tests();
- openrct2_dispose();
- exit(gExitCode);
- return;
}
openrct2_loop();
}
diff --git a/src/openrct2.h b/src/openrct2.h
index 1b6e137d30..d2452d5389 100644
--- a/src/openrct2.h
+++ b/src/openrct2.h
@@ -27,8 +27,7 @@ enum {
STARTUP_ACTION_INTRO,
STARTUP_ACTION_TITLE,
STARTUP_ACTION_OPEN,
- STARTUP_ACTION_EDIT,
- STARTUP_ACTION_TEST
+ STARTUP_ACTION_EDIT
};
extern int gOpenRCT2StartupAction;
diff --git a/test.bat b/test.bat
new file mode 100644
index 0000000000..59c0adf8e0
--- /dev/null
+++ b/test.bat
@@ -0,0 +1,2 @@
+msbuild .\projects\openrct2.sln "/p:Configuration=Release with Tests" /p:Platform=Win32
+.\build\Release\openrct2.exe test
\ No newline at end of file
diff --git a/src/test/management/finance_test.c b/test/management/finance_test.c
similarity index 93%
rename from src/test/management/finance_test.c
rename to test/management/finance_test.c
index bc14d637ac..0772dfb0ff 100644
--- a/src/test/management/finance_test.c
+++ b/test/management/finance_test.c
@@ -18,11 +18,11 @@
* along with this program. If not, see .
*****************************************************************************/
-#include "../../addresses.h"
-#include "../../openrct2.h"
-#include "../../scenario.h"
+#include "../../src/addresses.h"
+#include "../../src/management/finance.h"
+#include "../../src/openrct2.h"
+#include "../../src/scenario.h"
-#include "../../management/finance.h"
#include "finance_test.h"
void test_finance_setup(CuTest* tc) {
diff --git a/src/test/management/finance_test.h b/test/management/finance_test.h
similarity index 100%
rename from src/test/management/finance_test.h
rename to test/management/finance_test.h
diff --git a/test/ride/ride_ratings_test.c b/test/ride/ride_ratings_test.c
new file mode 100644
index 0000000000..929396f6ca
--- /dev/null
+++ b/test/ride/ride_ratings_test.c
@@ -0,0 +1,38 @@
+#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);
+}
\ No newline at end of file
diff --git a/test/ride/ride_ratings_test.h b/test/ride/ride_ratings_test.h
new file mode 100644
index 0000000000..43526ef500
--- /dev/null
+++ b/test/ride/ride_ratings_test.h
@@ -0,0 +1,9 @@
+#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
\ No newline at end of file
diff --git a/src/test/tests.c b/test/tests.c
similarity index 73%
rename from src/test/tests.c
rename to test/tests.c
index 5b7764a2bb..487306343d 100644
--- a/src/test/tests.c
+++ b/test/tests.c
@@ -18,7 +18,25 @@
* 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)
{
@@ -29,6 +47,10 @@ CuSuite* new_suite(void)
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);
@@ -50,5 +72,5 @@ int run_all_tests(void)
CuSuiteDetails(suite, output);
printf("Test results:\n%s\n", output->buffer);
- return suite->failCount > 0;
+ return suite->failCount;
}
diff --git a/src/test/tests.h b/test/tests.h
similarity index 91%
rename from src/test/tests.h
rename to test/tests.h
index b661defbba..10f94b39ed 100644
--- a/src/test/tests.h
+++ b/test/tests.h
@@ -22,16 +22,16 @@
#define _TESTS_H_
#include
-
#include
+#include "../src/common.h"
-#include "../scenario.h"
-
+int cmdline_for_test(const char **argv, int argc);
int run_all_tests();
-/*
- * Test utilities
- */
+// Test utilities
+
+#include "../src/scenario.h"
+
static void test_load_scenario(CuTest* tc, const char* file_name) {
const rct_scenario_basic* scenario = get_scenario_by_filename(file_name);
if (scenario == NULL) {