diff --git a/tau/compilers.h b/tau/compilers.h index 6f5987e..492c985 100644 --- a/tau/compilers.h +++ b/tau/compilers.h @@ -61,116 +61,61 @@ Copyright (c) 2021 Jason Dsouza <@jasmcaus> #endif // TAU_COMPILER_GCC #ifndef TAU_DISABLE_DEBUG_WARNINGS -#define TAU_DISABLE_DEBUG_WARNINGS \ - /* MSVC Warnings */ \ - TAU_MSVC_SUPPRESS_WARNING_PUSH \ - /* Conditional expression is constant */ \ - TAU_MSVC_SUPPRESS_WARNING(4127) \ - /* Assignment within conditional expression */ \ - TAU_MSVC_SUPPRESS_WARNING(4706) \ - /* Unreferenced inline function has been removed */ \ - TAU_MSVC_SUPPRESS_WARNING(4514) \ - /* Function not inlined*/ \ - TAU_MSVC_SUPPRESS_WARNING(4710) \ - /* function 'x' selected for automatic inline expansion */ \ - TAU_MSVC_SUPPRESS_WARNING(4711) \ - /* No function prototype given: converting '()' to '(void)' */ \ - TAU_MSVC_SUPPRESS_WARNING(4255) \ - /* '__cplusplus' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' */ \ - TAU_MSVC_SUPPRESS_WARNING(4668) \ - /* 'fprintf' : format string '' requires an argument of type 'unsigned __int64', but variadic */ \ - /* argument 1 has type 'size_t' */ \ - TAU_MSVC_SUPPRESS_WARNING(4777) \ - /* https://stackoverflow.com/questions/39479163 - what's the difference between 4018 and 4389 */ \ - /* signed/unsigned mismatch */ \ - TAU_MSVC_SUPPRESS_WARNING(4388) \ - /* expression' : signed/unsigned mismatch */ \ - TAU_MSVC_SUPPRESS_WARNING(4018) \ - /* Conversion from 'int' to 'unsigned long', signed/unsigned mismatch */ \ - TAU_MSVC_SUPPRESS_WARNING(4365) \ - /* format string expected in argument 'x' is not a string literal */ \ - TAU_MSVC_SUPPRESS_WARNING(4774) \ - /* 'var' : conversion from 'x' to 'y', possible loss of data */ \ - TAU_MSVC_SUPPRESS_WARNING(4267) \ - /* In multi-platform code, we cannot use the non-standard "safe" functions from */ \ - /* Microsoft's C lib like e.g. sprintf_s() instead of standard sprintf(). */ \ - TAU_MSVC_SUPPRESS_WARNING(4996) \ - /* warning C4090: '=': different 'const' qualifiers */ \ - TAU_MSVC_SUPPRESS_WARNING(4090) \ - /* io.h contains definitions for some structures with natural padding. This is uninteresting, */ \ - /* but for some reason, MSVC's behaviour is to warn about including this system header. That */ \ - /* *is* interesting */ \ - TAU_MSVC_SUPPRESS_WARNING(4820) \ - /* Miscellaneous */ \ - TAU_MSVC_SUPPRESS_WARNING(4061) \ - TAU_MSVC_SUPPRESS_WARNING(4100) \ - TAU_MSVC_SUPPRESS_WARNING(4201) \ - TAU_MSVC_SUPPRESS_WARNING(5045) \ - TAU_MSVC_SUPPRESS_WARNING(5105) \ - \ - /* Clang */ \ - TAU_CLANG_SUPPRESS_WARNING_PUSH \ - TAU_CLANG_SUPPRESS_WARNING("-Wdisabled-macro-expansion") \ - TAU_CLANG_SUPPRESS_WARNING("-Wlanguage-extension-token") \ - TAU_CLANG_SUPPRESS_WARNING("-Wc++98-compat") \ - TAU_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \ - TAU_CLANG_SUPPRESS_WARNING("-Wfloat-equal") \ - TAU_CLANG_SUPPRESS_WARNING("-Wmissing-variable-declarations") \ - TAU_CLANG_SUPPRESS_WARNING("-Wreserved-id-macro") \ - TAU_CLANG_SUPPRESS_WARNING("-Wunknown-pragmas") \ - TAU_CLANG_SUPPRESS_WARNING("-Wstrict-overflow") \ - TAU_CLANG_SUPPRESS_WARNING("-Wstrict-aliasing") \ - TAU_CLANG_SUPPRESS_WARNING("-Wsign-compare") \ - TAU_CLANG_SUPPRESS_WARNING("-Wsign-conversion") \ - TAU_CLANG_SUPPRESS_WARNING("-Wunused-macros") \ - TAU_CLANG_SUPPRESS_WARNING("-Wunused-function") \ - TAU_CLANG_SUPPRESS_WARNING("-Wunused-variable") \ - TAU_CLANG_SUPPRESS_WARNING("-Wunused-result") \ - TAU_CLANG_SUPPRESS_WARNING("-Wunused-parameter") \ - TAU_CLANG_SUPPRESS_WARNING("-Wunused-local-typedefs") \ - TAU_CLANG_SUPPRESS_WARNING("-Wswitch") \ - TAU_CLANG_SUPPRESS_WARNING("-Wswitch-enum") \ - TAU_CLANG_SUPPRESS_WARNING("-Wswitch-default") \ - TAU_CLANG_SUPPRESS_WARNING("-Wformat") \ - TAU_CLANG_SUPPRESS_WARNING("-Wformat-extra-args") \ - TAU_CLANG_SUPPRESS_WARNING("-Wignored-qualifiers") \ - TAU_CLANG_SUPPRESS_WARNING("-Wuninitialized") \ - TAU_CLANG_SUPPRESS_WARNING("-Wunused-const-variable") \ - TAU_CLANG_SUPPRESS_WARNING("-Wnewline-eof") \ - TAU_CLANG_SUPPRESS_WARNING("-Wdeprecated-declarations") \ - \ - /* GCC */ \ - TAU_GCC_SUPPRESS_WARNING_PUSH \ - TAU_GCC_SUPPRESS_WARNING("-Wunknown-pragmas") \ - TAU_GCC_SUPPRESS_WARNING("-Wpragmas") \ - TAU_GCC_SUPPRESS_WARNING("-Wmaybe-uninitialized") \ - TAU_GCC_SUPPRESS_WARNING("-Wmultistatement-macros") \ - TAU_GCC_SUPPRESS_WARNING("-Wdiscarded-qualifiers") \ - TAU_GCC_SUPPRESS_WARNING("-Wdisabled-macro-expansion") \ - TAU_GCC_SUPPRESS_WARNING("-Wlanguage-extension-token") \ - TAU_GCC_SUPPRESS_WARNING("-Wc++98-compat") \ - TAU_GCC_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \ - TAU_GCC_SUPPRESS_WARNING("-Wfloat-equal") \ - TAU_GCC_SUPPRESS_WARNING("-Wmissing-variable-declarations") \ - TAU_GCC_SUPPRESS_WARNING("-Wreserved-id-macro") \ - TAU_GCC_SUPPRESS_WARNING("-Wunknown-pragmas") \ - TAU_GCC_SUPPRESS_WARNING("-Wstrict-overflow") \ - TAU_GCC_SUPPRESS_WARNING("-Wstrict-aliasing") \ - TAU_GCC_SUPPRESS_WARNING("-Wsign-compare") \ - TAU_GCC_SUPPRESS_WARNING("-Wsign-conversion") \ - TAU_GCC_SUPPRESS_WARNING("-Wunused-macros") \ - TAU_GCC_SUPPRESS_WARNING("-Wunused-function") \ - TAU_GCC_SUPPRESS_WARNING("-Wunused-variable") \ - TAU_GCC_SUPPRESS_WARNING("-Wunused-result") \ - TAU_GCC_SUPPRESS_WARNING("-Wunused-parameter") \ - TAU_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs") \ - TAU_GCC_SUPPRESS_WARNING("-Wswitch") \ - TAU_GCC_SUPPRESS_WARNING("-Wswitch-enum") \ - TAU_GCC_SUPPRESS_WARNING("-Wswitch-default") \ - TAU_GCC_SUPPRESS_WARNING("-Wformat") \ - TAU_GCC_SUPPRESS_WARNING("-Wformat-extra-args") \ - TAU_GCC_SUPPRESS_WARNING("-Wsuggest-attribute=format") \ - TAU_GCC_SUPPRESS_WARNING("-Wdeprecated-declarations") +#define TAU_DISABLE_DEBUG_WARNINGS \ + /* MSVC Warnings */ \ + TAU_MSVC_SUPPRESS_WARNING_PUSH \ + /* Conditional expression is constant */ \ + TAU_MSVC_SUPPRESS_WARNING(4127) \ + /* Assignment within conditional expression */ \ + TAU_MSVC_SUPPRESS_WARNING(4706) \ + /* Unreferenced inline function has been removed */ \ + TAU_MSVC_SUPPRESS_WARNING(4514) \ + /* Function not inlined*/ \ + TAU_MSVC_SUPPRESS_WARNING(4710) \ + /* function 'x' selected for automatic inline expansion */ \ + TAU_MSVC_SUPPRESS_WARNING(4711) \ + /* No function prototype given: converting '()' to '(void)' */ \ + TAU_MSVC_SUPPRESS_WARNING(4255) \ + /* '__cplusplus' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' */ \ + TAU_MSVC_SUPPRESS_WARNING(4668) \ + /* 'fprintf' : format string '' requires an argument of type 'unsigned __int64', but variadic */ \ + /* argument 1 has type 'size_t' */ \ + TAU_MSVC_SUPPRESS_WARNING(4777) \ + /* https://stackoverflow.com/questions/39479163 - what's the difference between 4018 and 4389 */ \ + /* signed/unsigned mismatch */ \ + TAU_MSVC_SUPPRESS_WARNING(4388) \ + /* expression' : signed/unsigned mismatch */ \ + TAU_MSVC_SUPPRESS_WARNING(4018) \ + /* Conversion from 'int' to 'unsigned long', signed/unsigned mismatch */ \ + TAU_MSVC_SUPPRESS_WARNING(4365) \ + /* format string expected in argument 'x' is not a string literal */ \ + TAU_MSVC_SUPPRESS_WARNING(4774) \ + /* 'var' : conversion from 'x' to 'y', possible loss of data */ \ + TAU_MSVC_SUPPRESS_WARNING(4267) \ + /* In multi-platform code, we cannot use the non-standard "safe" functions from */ \ + /* Microsoft's C lib like e.g. sprintf_s() instead of standard sprintf(). */ \ + TAU_MSVC_SUPPRESS_WARNING(4996) \ + /* warning C4090: '=': different 'const' qualifiers */ \ + TAU_MSVC_SUPPRESS_WARNING(4090) \ + /* io.h contains definitions for some structures with natural padding. This is uninteresting, */ \ + /* but for some reason, MSVC's behaviour is to warn about including this system header. That */ \ + /* *is* interesting */ \ + TAU_MSVC_SUPPRESS_WARNING(4820) \ + /* Miscellaneous */ \ + TAU_MSVC_SUPPRESS_WARNING(4061) \ + TAU_MSVC_SUPPRESS_WARNING(4100) \ + TAU_MSVC_SUPPRESS_WARNING(4201) \ + TAU_MSVC_SUPPRESS_WARNING(5045) \ + TAU_MSVC_SUPPRESS_WARNING(5105) \ + \ + /* Clang */ \ + TAU_CLANG_SUPPRESS_WARNING_PUSH \ + TAU_CLANG_SUPPRESS_WARNING("-Wunused-function") \ + \ + /* GCC */ \ + TAU_GCC_SUPPRESS_WARNING_PUSH \ + TAU_GCC_SUPPRESS_WARNING("-Wunused-function") + #endif // TAU_DISABLE_DEBUG_WARNINGS #ifndef TAU_DISABLE_DEBUG_WARNINGS_POP diff --git a/tau/tau.h b/tau/tau.h index ebf73f5..3d35199 100644 --- a/tau/tau.h +++ b/tau/tau.h @@ -101,7 +101,7 @@ TAU_DISABLE_DEBUG_WARNINGS #ifndef TAU_NO_TESTING -typedef void (*tau_testsuite_t)(); +typedef void (*tau_testsuite_t)(void); typedef struct tauTestSuiteStruct { tau_testsuite_t func; char* name; @@ -157,17 +157,17 @@ extern volatile int shouldAbortTest; appropriately - fail the current test suite and carry on with the other checks (or move on to the next suite in the case of a REQUIRE) */ -static void failIfInsideTestSuite__(); -static void abortIfInsideTestSuite__(); +static void failIfInsideTestSuite__(void); +static void abortIfInsideTestSuite__(void); -static void failIfInsideTestSuite__() { +static void failIfInsideTestSuite__(void) { if(checkIsInsideTestSuite == 1) { hasCurrentTestFailed = 1; shouldFailTest = 1; } } -static void abortIfInsideTestSuite__() { +static void abortIfInsideTestSuite__(void) { if(checkIsInsideTestSuite == 1) { hasCurrentTestFailed = 1; shouldAbortTest = 1; @@ -176,7 +176,7 @@ static void abortIfInsideTestSuite__() { #endif // TAU_NO_TESTING -static void incrementWarnings() { +static void incrementWarnings(void) { #ifndef TAU_NO_TESTING tauStatsNumWarnings++; #endif // TAU_NO_TESTING @@ -244,7 +244,7 @@ TAU_EXTERN volatile int isCurrentTestIgnored; NOTE: This method has been edited to return the time (in nanoseconds). Depending on how large this value (e.g: 54890938849ns), we appropriately convert it to milliseconds/seconds before displaying it to stdout. */ -static inline double tauClock() { +static inline double tauClock(void) { #ifdef TAU_WIN_ LARGE_INTEGER counter; LARGE_INTEGER frequency; @@ -429,8 +429,10 @@ tauColouredPrintf(const int colour, const char* const fmt, ...) { printf(__VA_ARGS__) #endif // TAU_NO_TESTING - -static inline int tauIsDigit(const char c) { return c >= '0' && c <= '9'; } +static inline int tauIsNumberConstant(const char c) +{ + return ((c >= '0' && c <= '9') || c == '-' || c == '+' || c == '.'); +} // If the macro arguments can be decomposed further, we need to print the `In macro ..., so and so failed`. // This method signals whether this message should be printed. // @@ -439,36 +441,16 @@ static inline int tauIsDigit(const char c) { return c >= '0' && c <= '9'; } // See: https://stackoverflow.com/questions/20944784/why-is-conversion-from-string-constant-to-char-valid-in-c-but-invalid-in-c/20944858 static inline int tauShouldDecomposeMacro(const char* const actual, const char* const expected, const int isStringCmp) { // Signal that the macro can be further decomposed if either of the following symbols are present - int dots = 0; - int numActualDigits = 0; - int numExpectedDigits = 0; // If not inside a string comparison, we will return `1` only if we determine that `actual` is a variable // name/expression (i.e for a value, we search through each character verifying that each is a digit // - for floats, we allow a maximum of 1 '.' char) + // We can instead just check that the first character is either a digit, '+', '-' or '.' to filter out + // number constants since according to the standard identifiers cannot begin with digits. + // This accounts for number constants such as -44, 0xFA, 400000000UL, 0b0010(c++) and 1'000'123(c++). if(!isStringCmp) { - for(int i = 0; i < strlen(actual); i++) { - if(tauIsDigit(actual[i])) { - numActualDigits++; - } else if(actual[i] == '.') { - dots++; - if(dots > 1) { return 1; } - } else { - return 1; - } - } - // Do the same for `expected` - dots = 0; - for(int i=0; i < strlen(expected); i++) { - if(tauIsDigit(expected[i])) { - numExpectedDigits++; - } else if(expected[i] == '.') { - dots++; - if(dots > 1) { return 1; } - } else { - return 1; - } - } + if (!tauIsNumberConstant(*actual) || !tauIsNumberConstant(*expected)) + return 1; } // Inside a string comparison, we search for common expression tokens like the following: // '(', ')', '-' @@ -699,8 +681,8 @@ static void tauPrintColouredIfDifferent(const tau_u8 ch, const tau_u8 ref) { static void tauPrintHexBufCmp(const void* const buff, const void* const ref, const int size) { - const tau_u8* const test_buff = TAU_CAST(const tau_u8* const, buff); - const tau_u8* const ref_buff = TAU_CAST(const tau_u8* const, ref); + const tau_u8 *const test_buff = TAU_CAST(const tau_u8 *, buff); + const tau_u8 *const ref_buff = TAU_CAST(const tau_u8 *, ref); tauColouredPrintf(TAU_COLOUR_CYAN_,"<"); if(size != 0) @@ -999,7 +981,7 @@ static void tauPrintHexBufCmp(const void* const buff, const void* const ref, con static void __TAU_TEST_FIXTURE_TEARDOWN_##FIXTURE(struct FIXTURE* const); \ static void __TAU_TEST_FIXTURE_RUN_##FIXTURE##_##NAME(struct FIXTURE* const); \ \ - static void __TAU_TEST_FIXTURE_##FIXTURE##_##NAME() { \ + static void __TAU_TEST_FIXTURE_##FIXTURE##_##NAME(void) { \ struct FIXTURE fixture; \ memset(&fixture, 0, sizeof(fixture)); \ __TAU_TEST_FIXTURE_SETUP_##FIXTURE(&fixture); \ @@ -1062,7 +1044,7 @@ static void tauPrintHexBufCmp(const void* const buff, const void* const ref, con static void __TAU_TEST_FIXTURE_TEARDOWN_##FIXTURE(struct FIXTURE* const); \ static void __TAU_TEST_FIXTURE_RUN_##FIXTURE##_##NAME(struct FIXTURE* const); \ \ - static void __TAU_TEST_FIXTURE_##FIXTURE##_##NAME() { \ + static void __TAU_TEST_FIXTURE_##FIXTURE##_##NAME(void) { \ struct FIXTURE fixture; \ memset(&fixture, 0, sizeof(fixture)); \ __TAU_TEST_FIXTURE_SETUP_##FIXTURE(&fixture); \ @@ -1165,7 +1147,7 @@ static inline FILE* tau_fopen(const char* const filename, const char* const mode } -static void tau_help_() { +static void tau_help_(void) { printf("Usage: %s [options] [test...]\n", tau_argv0_); printf("\n"); printf("Run the specified unit tests; or if the option '--skip' is used, run all\n"); @@ -1264,7 +1246,7 @@ static tau_bool tauCmdLineRead(const int argc, const char* const * const argv) { return tau_true; } -static int tauCleanup() { +static int tauCleanup(void) { for (tau_ull i = 0; i < tauTestContext.numTestSuites; i++) free(TAU_PTRCAST(void* , tauTestContext.tests[i].name)); @@ -1278,7 +1260,7 @@ static int tauCleanup() { } // Triggers and runs all unit tests -static void tauRunTests() { +static void tauRunTests(void) { // Run tests for(tau_ull i = 0; i < tauTestContext.numTestSuites; i++) { checkIsInsideTestSuite = 1; @@ -1479,6 +1461,6 @@ inline int tau_main(const int argc, const char* const * const argv) { // volatile int shouldAbortTest = 0; #endif // TAU_NO_TESTING -TAU_DISABLE_DEBUG_WARNINGS_POP + TAU_DISABLE_DEBUG_WARNINGS_POP #endif // TAU_H_ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5223a45..a6a74ae 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # ------ Setting the C/CXX Standard ------ set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_C_STANDARD 11) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 14) set(CMAKE_C_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -18,4 +18,4 @@ endif() # TAU_BUILDINTERNALTESTS if(TAU_BUILDTHIRDPARTYTESTS) message("------- [INFO] Building ThirdParty Tests") add_subdirectory(ThirdParty) -endif() # TAU_BUILDTHIRDPARTYTESTS \ No newline at end of file +endif() # TAU_BUILDTHIRDPARTYTESTS diff --git a/test/InternalTests/main.c b/test/InternalTests/main.c index 6b19929..0ec064b 100644 --- a/test/InternalTests/main.c +++ b/test/InternalTests/main.c @@ -1,2 +1,2 @@ #include -TAU_MAIN() \ No newline at end of file +TAU_MAIN() diff --git a/test/InternalTests/test.c b/test/InternalTests/test.c index 949ce28..dcbdafe 100644 --- a/test/InternalTests/test.c +++ b/test/InternalTests/test.c @@ -12,7 +12,7 @@ TEST(c, REQUIRE_TF) { TEST(c, MemAlloc) { void* mem; - + mem = malloc(5); CHECK(mem != NULL, "Mem ideally should not be NULL"); @@ -20,23 +20,26 @@ TEST(c, MemAlloc) { CHECK(mem != NULL, "Mem ideally should not be NULL"); } -int retu() { +int retu(void) { return 10000000; } -TEST(c, ForLoop) { +TEST(c, ForLoop) +{ int count = 0; for(int i = 0; i<10000000; i++) { count++; } - REQUIRE_EQ(count, retu()); + REQUIRE_EQ(count, retu()); } -TEST(c, CHECK) { - CHECK(1 < 2, "1 < 2"); +TEST(c, CHECK) +{ + CHECK(1 < 2, "1 < 2"); } -TEST(c, REQUIRE_LT) { - REQUIRE_LT(1, 2); +TEST(c, REQUIRE_LT) +{ + REQUIRE_LT(1, 2); } TEST(c, REQUIRE_LE) { @@ -44,8 +47,9 @@ TEST(c, REQUIRE_LE) { REQUIRE_LE(1, 2); } -TEST(c, REQUIRE_GT) { - REQUIRE_GT(2, 1); +TEST(c, REQUIRE_GT) +{ + REQUIRE_GT(2, 1); } TEST(c, REQUIRE_GE) { @@ -53,32 +57,39 @@ TEST(c, REQUIRE_GE) { REQUIRE_GE(2, 1); } -TEST(c, REQUIRE_STREQ) { - REQUIRE_STREQ("foo", "foo"); +TEST(c, REQUIRE_STREQ) +{ + REQUIRE_STREQ("foo", "foo"); } -TEST(c, REQUIRE_STRNE) { - REQUIRE_STRNE("foo", "bar"); +TEST(c, REQUIRE_STRNE) +{ + REQUIRE_STRNE("foo", "bar"); } -TEST(c, REQUIRE_SUBSTREQ) { - REQUIRE_SUBSTREQ("fooder", "foobar", strlen("foo")); +TEST(c, REQUIRE_SUBSTREQ) +{ + REQUIRE_SUBSTREQ("fooder", "foobar", strlen("foo")); } -TEST(c, REQUIRE_SUBSTRNE) { - REQUIRE_SUBSTRNE("foo", "barfoo", strlen("foo")); +TEST(c, REQUIRE_SUBSTRNE) +{ + REQUIRE_SUBSTRNE("foo", "barfoo", strlen("foo")); } -TEST(c, CHECK_EQ1) { - CHECK_EQ(345, 345); +TEST(c, CHECK_EQ1) +{ + CHECK_EQ(345, 345); } -TEST(c, CHECK_NE) { - CHECK_NE(1, 2); +TEST(c, CHECK_NE) +{ + CHECK_NE(1, 2); } -TEST(c, CHECK_LT) { - CHECK_LT(1, 2); +TEST(c, CHECK_LT) +{ + CHECK_LT(1, 2); } TEST(c, CHECK_LE) { @@ -93,32 +104,39 @@ TEST(c, CHECK_GE) { CHECK_GE(2, 1); } -TEST(c, CHECK_STREQ) { - CHECK_STREQ("foo", "foo"); +TEST(c, CHECK_STREQ) +{ + CHECK_STREQ("foo", "foo"); } -TEST(c, CHECK_STRNE) { - CHECK_STRNE("foo", "bar"); +TEST(c, CHECK_STRNE) +{ + CHECK_STRNE("foo", "bar"); } -TEST(c, CHECK_SUBSTREQ) { - CHECK_SUBSTREQ("foo", "foobar", strlen("foo")); +TEST(c, CHECK_SUBSTREQ) +{ + CHECK_SUBSTREQ("foo", "foobar", strlen("foo")); } -TEST(c, CHECK_SUBSTRNE) { - CHECK_SUBSTRNE("foo", "barfoo", strlen("foo")); +TEST(c, CHECK_SUBSTRNE) +{ + CHECK_SUBSTRNE("foo", "barfoo", strlen("foo")); } -TEST(c11, REQUIRE_EQ) { - REQUIRE_EQ(1, 1); +TEST(c11, REQUIRE_EQ) +{ + REQUIRE_EQ(1, 1); } -TEST(c11, REQUIRE_NE) { - REQUIRE_NE(1, 2); +TEST(c11, REQUIRE_NE) +{ + REQUIRE_NE(1, 2); } -TEST(c11, REQUIRE_LT) { - REQUIRE_LT(1, 2); +TEST(c11, REQUIRE_LT) +{ + REQUIRE_LT(1, 2); } TEST(c11, REQUIRE_LE) { @@ -126,8 +144,9 @@ TEST(c11, REQUIRE_LE) { REQUIRE_LE(1, 2); } -TEST(c11, REQUIRE_GT) { - REQUIRE_GT(2, 1); +TEST(c11, REQUIRE_GT) +{ + REQUIRE_GT(2, 1); } TEST(c11, REQUIRE_GE) { @@ -135,24 +154,29 @@ TEST(c11, REQUIRE_GE) { REQUIRE_GE(2, 1); } -TEST(c11, REQUIRE_STREQ) { - REQUIRE_STREQ("foo", "foo"); +TEST(c11, REQUIRE_STREQ) +{ + REQUIRE_STREQ("foo", "foo"); } -TEST(c11, REQUIRE_SUBSTREQ) { - REQUIRE_STRNE("foo", "bar"); +TEST(c11, REQUIRE_SUBSTREQ) +{ + REQUIRE_STRNE("foo", "bar"); } -TEST(c11, CHECK_EQ2) { - CHECK_EQ(1, 1); +TEST(c11, CHECK_EQ2) +{ + CHECK_EQ(1, 1); } -TEST(c11, CHECK_NE) { - CHECK_NE(1, 2); +TEST(c11, CHECK_NE) +{ + CHECK_NE(1, 2); } -TEST(c11, CHECK_LT) { - CHECK_LT(1, 2); +TEST(c11, CHECK_LT) +{ + CHECK_LT(1, 2); } TEST(c11, CHECK_LE) { @@ -160,8 +184,9 @@ TEST(c11, CHECK_LE) { CHECK_LE(1, 2); } -TEST(c11, CHECK_GT) { - CHECK_GT(3, 1); +TEST(c11, CHECK_GT) +{ + CHECK_GT(3, 1); } TEST(c11, CHECK_GE) { @@ -169,12 +194,14 @@ TEST(c11, CHECK_GE) { CHECK_GE(2, 1); } -TEST(c11, CHECK_STREQ) { - CHECK_STREQ("foo", "foo"); +TEST(c11, CHECK_STREQ) +{ + CHECK_STREQ("foo", "foo"); } -TEST(c11, CHECK_SUBSTREQ) { - CHECK_STRNE("foo", "bar"); +TEST(c11, CHECK_SUBSTREQ) +{ + CHECK_STRNE("foo", "bar"); } TEST(c11, no_double_eval) { @@ -216,8 +243,9 @@ TEST_F_SETUP(MyTestF) { tau->foo = 42; } -TEST_F_TEARDOWN(MyTestF) { - REQUIRE_EQ(13, tau->foo); +TEST_F_TEARDOWN(MyTestF) +{ + REQUIRE_EQ(13, tau->foo); } TEST_F(MyTestF, c) { @@ -228,4 +256,89 @@ TEST_F(MyTestF, c) { TEST_F(MyTestF, c2) { REQUIRE_EQ(42, tau->foo); tau->foo = 13; -} \ No newline at end of file +} + +TEST(test_tauShouldDecomposeMacro_numbers, decimals) +{ + CHECK_EQ(123456789, 123456789); + CHECK_EQ(tauShouldDecomposeMacro("1", "123456789", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("123456789", "1", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, decimals_with_sign) +{ + CHECK_EQ(-123456789, -123456789); + CHECK_EQ(tauShouldDecomposeMacro("-123456789", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", "-123456789", 0), 0); + CHECK_EQ(+123456789, +123456789); + CHECK_EQ(tauShouldDecomposeMacro("+123456789", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", "+123456789", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, decimals_with_suffix) +{ + CHECK_EQ(987654321012345678UL, 987654321012345678UL); + CHECK_EQ(tauShouldDecomposeMacro("987654321012345678UL", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", "987654321012345678UL", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, hexadecimals) +{ + CHECK_EQ(0xFFFFFFFF, 0xFFFFFFFF); + CHECK_EQ(tauShouldDecomposeMacro("0xFFFFFFFF", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", "0xFFFFFFFF", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, octals) +{ + CHECK_EQ(007, 007); + CHECK_EQ(tauShouldDecomposeMacro("1", "007", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("007", "1", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, floats) +{ + CHECK_EQ(420.69, 420.69); + CHECK_EQ(tauShouldDecomposeMacro("420.69", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", "420.69", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, floats_only_fractional_part) +{ + CHECK_EQ(.69, .69); + CHECK_EQ(tauShouldDecomposeMacro(".69", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", ".69", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_c_identifiers, letters) +{ + const int myVar = 1; + CHECK_EQ(myVar, myVar); + CHECK_EQ(tauShouldDecomposeMacro("myVar", "a", 0), 1); + CHECK_EQ(tauShouldDecomposeMacro("a", "myVar", 0), 1); +} + +TEST(test_tauShouldDecomposeMacro_c_identifiers, letters_and_numbers) +{ + const int v1 = 1; + CHECK_EQ(v1, v1); + CHECK_EQ(tauShouldDecomposeMacro("v1", "a", 0), 1); + CHECK_EQ(tauShouldDecomposeMacro("a", "v1", 0), 1); +} + +TEST(test_tauShouldDecomposeMacro_c_identifiers, underscores_and_letters) +{ + const int __myVar__ = 1; + CHECK_EQ(__myVar__, __myVar__); + CHECK_EQ(tauShouldDecomposeMacro("__myVar__", "a", 0), 1); + CHECK_EQ(tauShouldDecomposeMacro("a", "__myVar__", 0), 1); +} + +TEST(test_tauShouldDecomposeMacro_c_identifiers, mixed) +{ +#define MYMACRO_2024dec10 1 + CHECK_EQ(MYMACRO_2024dec10, MYMACRO_2024dec10); +#undef MYMACRO_2024dec10 + CHECK_EQ(tauShouldDecomposeMacro("MYMACRO_2024dec10", "a", 0), 1); + CHECK_EQ(tauShouldDecomposeMacro("a", "MYMACRO_2024dec10", 0), 1); +} diff --git a/test/InternalTests/test.cpp b/test/InternalTests/test.cpp index f7ac4b6..3e4e5cd 100644 --- a/test/InternalTests/test.cpp +++ b/test/InternalTests/test.cpp @@ -5,16 +5,16 @@ TAU_ONLY_GLOBALS() #endif // _MSC_VER -TEST(cpp, REQUIRE_EQ) { - REQUIRE_EQ(1, 1); +TEST(cpp, REQUIRE_EQ) { + REQUIRE_EQ(1, 1); } -TEST(cpp, REQUIRE_NE) { - REQUIRE_NE(1, 2); +TEST(cpp, REQUIRE_NE) { + REQUIRE_NE(1, 2); } -TEST(cpp, REQUIRE_LT) { - REQUIRE_LT(1, 2); +TEST(cpp, REQUIRE_LT) { + REQUIRE_LT(1, 2); } TEST(cpp, REQUIRE_LE) { @@ -22,8 +22,8 @@ TEST(cpp, REQUIRE_LE) { REQUIRE_LE(1, 2); } -TEST(cpp, REQUIRE_GT) { - REQUIRE_GT(2, 1); +TEST(cpp, REQUIRE_GT) { + REQUIRE_GT(2, 1); } TEST(cpp, REQUIRE_GE) { @@ -31,33 +31,33 @@ TEST(cpp, REQUIRE_GE) { REQUIRE_GE(2, 1); } -TEST(cpp, REQUIRE_STREQ) { - REQUIRE_STREQ("foo", "foo"); +TEST(cpp, REQUIRE_STREQ) { + REQUIRE_STREQ("foo", "foo"); } -TEST(cpp, REQUIRE_STRNE) { - REQUIRE_STRNE("foo", "bar"); +TEST(cpp, REQUIRE_STRNE) { + REQUIRE_STRNE("foo", "bar"); } -TEST(cpp, REQUIRE_SUBSTREQ) { - REQUIRE_SUBSTREQ("foo", "foo", strlen("foo")); +TEST(cpp, REQUIRE_SUBSTREQ) { + REQUIRE_SUBSTREQ("foo", "foo", strlen("foo")); } -TEST(cpp, REQUIRE_SUBSTRNE) { - REQUIRE_SUBSTRNE("foo", "barfoo", strlen("foo")); +TEST(cpp, REQUIRE_SUBSTRNE) { + REQUIRE_SUBSTRNE("foo", "barfoo", strlen("foo")); } -TEST(cpp, CHECK_EQ) { - CHECK_EQ(1, 1); +TEST(cpp, CHECK_EQ) { + CHECK_EQ(1, 1); } -TEST(cpp, CHECK_NE) { - CHECK_NE(1, 2); +TEST(cpp, CHECK_NE) { + CHECK_NE(1, 2); } -TEST(cpp, CHECK_LT) { - CHECK_LT(1, 2); +TEST(cpp, CHECK_LT) { + CHECK_LT(1, 2); } TEST(cpp, CHECK_LE) { @@ -72,20 +72,20 @@ TEST(cpp, CHECK_GE) { CHECK_GE(2, 1); } -// TEST(cpp, CHECK_STREQ) { -// CHECK_STREQ("foo", "foo"); +// TEST(cpp, CHECK_STREQ) { +// CHECK_STREQ("foo", "foo"); // } -// TEST(cpp, CHECK_STRNE) { -// CHECK_STRNE("foo", "bar"); +// TEST(cpp, CHECK_STRNE) { +// CHECK_STRNE("foo", "bar"); // } -// TEST(cpp, CHECK_STRMNEQ) { -// CHECK_STRNNEQ("foo", "foobar", strlen("food")); +// TEST(cpp, CHECK_STRMNEQ) { +// CHECK_STRNNEQ("foo", "foobar", strlen("food")); // } -// TEST(cpp, CHECK_STRNNEQ) { -// CHECK_STRNNEQ("foo", "barfoo", strlen("foo")); +// TEST(cpp, CHECK_STRNNEQ) { +// CHECK_STRNNEQ("foo", "barfoo", strlen("foo")); // } TEST(cpp, no_double_eval) { @@ -179,20 +179,20 @@ TEST(cpp, Ptr) { static const int cppdata[4] = {42, 13, 6, -53}; -TEST(cpp, Array) { - CHECK_NE(cppdata, cppdata + 1); +TEST(cpp, Array) { + CHECK_NE(cppdata, cppdata + 1); } -TEST(cpp11, REQUIRE_EQ) { - REQUIRE_EQ(1, 1); +TEST(cpp11, REQUIRE_EQ) { + REQUIRE_EQ(1, 1); } -TEST(cpp11, REQUIRE_NE) { - REQUIRE_NE(1, 2); +TEST(cpp11, REQUIRE_NE) { + REQUIRE_NE(1, 2); } -TEST(cpp11, REQUIRE_LT) { - REQUIRE_LT(1, 2); +TEST(cpp11, REQUIRE_LT) { + REQUIRE_LT(1, 2); } TEST(cpp11, REQUIRE_LE) { @@ -207,32 +207,32 @@ TEST(cpp11, REQUIRE_GE) { REQUIRE_GE(2, 1); } -TEST(cpp11, REQUIRE_STREQ) { - REQUIRE_STREQ("foo", "foo"); +TEST(cpp11, REQUIRE_STREQ) { + REQUIRE_STREQ("foo", "foo"); } -TEST(cpp11, REQUIRE_STRNE) { - REQUIRE_STRNE("foo", "bar"); +TEST(cpp11, REQUIRE_STRNE) { + REQUIRE_STRNE("foo", "bar"); } -TEST(cpp11, REQUIRE_SUBSTREQ) { - REQUIRE_SUBSTREQ("foo", "foo", strlen("foo")); +TEST(cpp11, REQUIRE_SUBSTREQ) { + REQUIRE_SUBSTREQ("foo", "foo", strlen("foo")); } -TEST(cpp11, REQUIRE_SUBSTRNE) { - REQUIRE_SUBSTRNE("foo", "barfoo", strlen("foo")); +TEST(cpp11, REQUIRE_SUBSTRNE) { + REQUIRE_SUBSTRNE("foo", "barfoo", strlen("foo")); } -TEST(cpp11, CHECK_EQ) { - CHECK_EQ(1, 1); +TEST(cpp11, CHECK_EQ) { + CHECK_EQ(1, 1); } -TEST(cpp11, CHECK_NE) { - CHECK_NE(1, 2); +TEST(cpp11, CHECK_NE) { + CHECK_NE(1, 2); } -TEST(cpp11, CHECK_LT) { - CHECK_LT(1, 2); +TEST(cpp11, CHECK_LT) { + CHECK_LT(1, 2); } TEST(cpp11, CHECK_LE) { @@ -240,8 +240,8 @@ TEST(cpp11, CHECK_LE) { CHECK_LE(1, 2); } -TEST(cpp11, CHECK_GT) { - CHECK_GT(2, 1); +TEST(cpp11, CHECK_GT) { + CHECK_GT(2, 1); } TEST(cpp11, CHECK_GE) { @@ -249,20 +249,20 @@ TEST(cpp11, CHECK_GE) { CHECK_GE(2, 1); } -TEST(cpp11, CHECK_STREQ) { - CHECK_STREQ("foo", "foo"); +TEST(cpp11, CHECK_STREQ) { + CHECK_STREQ("foo", "foo"); } -TEST(cpp11, CHECK_STRNE) { - CHECK_STRNE("foo", "bar"); +TEST(cpp11, CHECK_STRNE) { + CHECK_STRNE("foo", "bar"); } -TEST(cpp11, CHECK_SUBSTREQ) { - CHECK_SUBSTREQ("foo", "foo", strlen("foo")); +TEST(cpp11, CHECK_SUBSTREQ) { + CHECK_SUBSTREQ("foo", "foo", strlen("foo")); } -TEST(cpp11, CHECK_SUBSTRNE) { - CHECK_SUBSTRNE("foo", "barfoo", strlen("foo")); +TEST(cpp11, CHECK_SUBSTRNE) { + CHECK_SUBSTRNE("foo", "barfoo", strlen("foo")); } TEST(cpp11, no_double_eval) { @@ -355,8 +355,8 @@ TEST(cpp11, Ptr) { static const int cpp11[4] = {42, 13, 6, -53}; -TEST(cpp11, Array) { - CHECK_NE(cpp11, cpp11 + 1); +TEST(cpp11, Array) { + CHECK_NE(cpp11, cpp11 + 1); } TEST(cpp, Section) { @@ -366,7 +366,7 @@ TEST(cpp, Section) { } struct Stack { - char* name; + const char* name; int age; int pop() { @@ -385,7 +385,7 @@ TEST_F_SETUP(Stack) { } TEST_F_TEARDOWN(Stack) { - + (void)tau; } TEST_F(Stack, TestStackDetails) { @@ -393,4 +393,89 @@ TEST_F(Stack, TestStackDetails) { CHECK_EQ(tau->age, 4); REQUIRE_STREQ(tau->name, "Hello"); REQUIRE_EQ(tau->pop(), 123); -} \ No newline at end of file +} + +TEST(test_tauShouldDecomposeMacro_numbers, decimals) +{ + CHECK_EQ(123456789, 123456789); + CHECK_EQ(tauShouldDecomposeMacro("1", "123456789", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("123456789", "1", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, decimals_with_sign) +{ + CHECK_EQ(-123456789, -123456789); + CHECK_EQ(tauShouldDecomposeMacro("-123456789", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", "-123456789", 0), 0); + CHECK_EQ(+123456789, +123456789); + CHECK_EQ(tauShouldDecomposeMacro("+123456789", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", "+123456789", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, decimals_with_suffix) +{ + CHECK_EQ(987654321012345678UL, 987654321012345678UL); + CHECK_EQ(tauShouldDecomposeMacro("987654321012345678UL", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", "987654321012345678UL", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, hexadecimals) +{ + CHECK_EQ(0xFFFFFFFF, 0xFFFFFFFF); + CHECK_EQ(tauShouldDecomposeMacro("0xFFFFFFFF", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", "0xFFFFFFFF", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, octals) +{ + CHECK_EQ(007, 007); + CHECK_EQ(tauShouldDecomposeMacro("1", "007", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("007", "1", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, floats) +{ + CHECK_EQ(420.69, 420.69); + CHECK_EQ(tauShouldDecomposeMacro("420.69", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", "420.69", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_numbers, floats_only_fractional_part) +{ + CHECK_EQ(.69, .69); + CHECK_EQ(tauShouldDecomposeMacro(".69", "1", 0), 0); + CHECK_EQ(tauShouldDecomposeMacro("1", ".69", 0), 0); +} + +TEST(test_tauShouldDecomposeMacro_c_identifiers, letters) +{ + const int myVar = 1; + CHECK_EQ(myVar, myVar); + CHECK_EQ(tauShouldDecomposeMacro("myVar", "a", 0), 1); + CHECK_EQ(tauShouldDecomposeMacro("a", "myVar", 0), 1); +} + +TEST(test_tauShouldDecomposeMacro_c_identifiers, letters_and_numbers) +{ + const int v1 = 1; + CHECK_EQ(v1, v1); + CHECK_EQ(tauShouldDecomposeMacro("v1", "a", 0), 1); + CHECK_EQ(tauShouldDecomposeMacro("a", "v1", 0), 1); +} + +TEST(test_tauShouldDecomposeMacro_c_identifiers, underscores_and_letters) +{ + const int __myVar__ = 1; + CHECK_EQ(__myVar__, __myVar__); + CHECK_EQ(tauShouldDecomposeMacro("__myVar__", "a", 0), 1); + CHECK_EQ(tauShouldDecomposeMacro("a", "__myVar__", 0), 1); +} + +TEST(test_tauShouldDecomposeMacro_c_identifiers, mixed) +{ +#define MYMACRO_2024dec10 1 + CHECK_EQ(MYMACRO_2024dec10, MYMACRO_2024dec10); +#undef MYMACRO_2024dec10 + CHECK_EQ(tauShouldDecomposeMacro("MYMACRO_2024dec10", "a", 0), 1); + CHECK_EQ(tauShouldDecomposeMacro("a", "MYMACRO_2024dec10", 0), 1); +} diff --git a/test/ThirdParty/6502Emulator/6502/6502Lib/src/private/m6502.cpp b/test/ThirdParty/6502Emulator/6502/6502Lib/src/private/m6502.cpp index 36c5340..6e864e0 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Lib/src/private/m6502.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Lib/src/private/m6502.cpp @@ -5,7 +5,7 @@ m6502::s32 m6502::CPU::Execute( s32 Cycles, Mem & memory ) { /** Load a Register with the value from the memory address */ - auto LoadRegister = + auto LoadRegister = [&Cycles,&memory,this] ( Word Address, Byte& Register ) { @@ -60,7 +60,7 @@ m6502::s32 m6502::CPU::Execute( s32 Cycles, Mem & memory ) }; /** Do add with carry given the the operand */ - auto ADC = [&Cycles, &memory, this] + auto ADC = [this] ( Byte Operand ) { ASSERT( Flag.D == false, "haven't handled decimal mode!" ); @@ -83,7 +83,7 @@ m6502::s32 m6502::CPU::Execute( s32 Cycles, Mem & memory ) }; /** Sets the processor status for a CMP/CPX/CPY instruction */ - auto RegisterCompare = [&Cycles, &memory, this] + auto RegisterCompare = [this] ( Byte Operand, Byte RegisterValue ) { Byte Temp = RegisterValue - Operand; @@ -143,7 +143,7 @@ m6502::s32 m6502::CPU::Execute( s32 Cycles, Mem & memory ) * Setting bits 4 & 5 on the stack */ auto PushPSToStack = [&Cycles, &memory, this]( ) { - Byte PSStack = PS | BreakFlagBit | UnusedFlagBit; + Byte PSStack = PS | BreakFlagBit | UnusedFlagBit; PushByteOntoStack( Cycles, PSStack, memory ); }; @@ -166,7 +166,7 @@ m6502::s32 m6502::CPU::Execute( s32 Cycles, Mem & memory ) { A &= FetchByte( Cycles, memory ); SetZeroAndNegativeFlags( A ); - } break; + } break; case INS_ORA_IM: { A |= FetchByte( Cycles, memory ); @@ -317,7 +317,7 @@ m6502::s32 m6502::CPU::Execute( s32 Cycles, Mem & memory ) case INS_LDA_ZP: { Word Address = AddrZeroPage( Cycles, memory ); - LoadRegister( Address, A ); + LoadRegister( Address, A ); } break; case INS_LDX_ZP: { @@ -453,27 +453,27 @@ m6502::s32 m6502::CPU::Execute( s32 Cycles, Mem & memory ) { Word Address = AddrAbsoluteY_5( Cycles, memory ); WriteByte( A, Cycles, Address, memory ); - } break; + } break; case INS_JSR: { Word SubAddr = FetchWord( Cycles, memory ); - PushPCMinusOneToStack( Cycles, memory ); + PushPCMinusOneToStack( Cycles, memory ); PC = SubAddr; Cycles--; } break; case INS_RTS: { Word ReturnAddress = PopWordFromStack( Cycles, memory ); - PC = ReturnAddress + 1; + PC = ReturnAddress + 1; Cycles -= 2; } break; //TODO: - //An original 6502 has does not correctly fetch the target + //An original 6502 has does not correctly fetch the target //address if the indirect vector falls on a page boundary //( e.g.$xxFF where xx is any value from $00 to $FF ). - //In this case fetches the LSB from $xxFF as expected but - //takes the MSB from $xx00.This is fixed in some later chips - //like the 65SC02 so for compatibility always ensure the + //In this case fetches the LSB from $xxFF as expected but + //takes the MSB from $xx00.This is fixed in some later chips + //like the 65SC02 so for compatibility always ensure the //indirect vector is not at the end of the page. case INS_JMP_ABS: { @@ -510,7 +510,7 @@ m6502::s32 m6502::CPU::Execute( s32 Cycles, Mem & memory ) case INS_PHP: { PushPSToStack(); - } break; + } break; case INS_PLP: { PopPSFromStack(); @@ -985,7 +985,7 @@ m6502::s32 m6502::CPU::Execute( s32 Cycles, Mem & memory ) case INS_ROR_ZP: { Word Address = AddrZeroPage( Cycles, memory ); - Byte Operand = ReadByte( Cycles, Address, memory ); + Byte Operand = ReadByte( Cycles, Address, memory ); Byte Result = ROR( Operand ); WriteByte( Result, Cycles, Address, memory ); } break; @@ -1102,7 +1102,7 @@ m6502::Word m6502::CPU::AddrAbsoluteY( s32& Cycles, const Mem& memory ) m6502::Word m6502::CPU::AddrAbsoluteY_5( s32& Cycles, const Mem& memory ) { Word AbsAddress = FetchWord( Cycles, memory ); - Word AbsAddressY = AbsAddress + Y; + Word AbsAddressY = AbsAddress + Y; Cycles--; return AbsAddressY; } diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502AND_EOR_ORA_Tests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502AND_EOR_ORA_Tests.cpp index 59a8d9f..e1c33dd 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502AND_EOR_ORA_Tests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502AND_EOR_ORA_Tests.cpp @@ -3,7 +3,7 @@ struct M6502AndEorOraBitTests { -public: +public: m6502::Mem mem; m6502::CPU cpu; @@ -23,9 +23,9 @@ struct M6502AndEorOraBitTests And, Eor, Or }; - m6502::Byte DoLogicalOp( - m6502::Byte A, - m6502::Byte B, + m6502::Byte DoLogicalOp( + m6502::Byte A, + m6502::Byte B, ELogicalOp LogicalOp ) { switch ( LogicalOp ) @@ -44,7 +44,7 @@ struct M6502AndEorOraBitTests throw - 1; //invalid Logical Op } - void TestLogicalOpImmediate( + void TestLogicalOpImmediate( ELogicalOp LogicalOp ) { // given: @@ -492,7 +492,7 @@ TEST_F_SETUP(M6502AndEorOraBitTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502AndEorOraBitTests){} +TEST_F_TEARDOWN(M6502AndEorOraBitTests){ (void)tau; } TEST_F( M6502AndEorOraBitTests, TestLogicalOpANDOnARegisterImmediate ) @@ -704,10 +704,9 @@ TEST_F( M6502AndEorOraBitTests, TestBitZeroPage ) using namespace m6502; tau->cpu.Flag.V = tau->cpu.Flag.N = false; tau->cpu.A = 0xCC; - tau->mem[0xFFFC] = CPU::INS_BIT_ZP; + tau->mem[0xFFFC] = CPU::INS_BIT_ZP; tau->mem[0xFFFD] = 0x42; tau->mem[0x0042] = 0xCC; - CPU CPUCopy = tau->cpu; constexpr s32 EXPECTED_CYCLES = 3; //when: @@ -730,7 +729,6 @@ TEST_F( M6502AndEorOraBitTests, TestBitZeroPageResultZero ) tau->mem[0xFFFC] = CPU::INS_BIT_ZP; tau->mem[0xFFFD] = 0x42; tau->mem[0x0042] = 0x33; - CPU CPUCopy = tau->cpu; constexpr s32 EXPECTED_CYCLES = 3; //when: @@ -753,7 +751,6 @@ TEST_F( M6502AndEorOraBitTests, TestBitZeroPageResultZeroBits6And7Zero ) tau->mem[0xFFFC] = CPU::INS_BIT_ZP; tau->mem[0xFFFD] = 0x42; tau->mem[0x0042] = 0xCC; - CPU CPUCopy = tau->cpu; constexpr s32 EXPECTED_CYCLES = 3; //when: @@ -796,7 +793,6 @@ TEST_F( M6502AndEorOraBitTests, TestBitAbsolute ) tau->mem[0xFFFD] = 0x00; tau->mem[0xFFFE] = 0x80; tau->mem[0x8000] = 0xCC; - CPU CPUCopy = tau->cpu; constexpr s32 EXPECTED_CYCLES = 4; //when: @@ -820,7 +816,6 @@ TEST_F( M6502AndEorOraBitTests, TestBitAbsoluteResultZero ) tau->mem[0xFFFD] = 0x00; tau->mem[0xFFFE] = 0x80; tau->mem[0x8000] = 0x33; - CPU CPUCopy = tau->cpu; constexpr s32 EXPECTED_CYCLES = 4; //when: @@ -844,7 +839,6 @@ TEST_F( M6502AndEorOraBitTests, TestBitAbsoluteResultZeroBit6And7Zero ) tau->mem[0xFFFD] = 0x00; tau->mem[0xFFFE] = 0x80; tau->mem[0x8000] = 0xCC; - CPU CPUCopy = tau->cpu; constexpr s32 EXPECTED_CYCLES = 4; //when: @@ -868,7 +862,6 @@ TEST_F( M6502AndEorOraBitTests, TestBitAbsoluteResultZeroBit6And7Mixed ) tau->mem[0xFFFD] = 0x00; tau->mem[0xFFFE] = 0x80; tau->mem[0x8000] = 0b10000000; - CPU CPUCopy = tau->cpu; constexpr s32 EXPECTED_CYCLES = 4; //when: @@ -877,4 +870,4 @@ TEST_F( M6502AndEorOraBitTests, TestBitAbsoluteResultZeroBit6And7Mixed ) //then: CHECK_FALSE( tau->cpu.Flag.V ); CHECK_TRUE( tau->cpu.Flag.N ); -} \ No newline at end of file +} diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502AddWithCarryTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502AddWithCarryTests.cpp index cbb4846..1102b4a 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502AddWithCarryTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502AddWithCarryTests.cpp @@ -32,11 +32,11 @@ struct M6502AddSubWithCarryTests { }; void TestSBCAbsolute( ADCTestData Test ) - { + { TestADCAbsolute( Test, EOperation::Subtract ); } - void TestADCAbsolute( ADCTestData Test, + void TestADCAbsolute( ADCTestData Test, EOperation Operation = EOperation::Add ) { // given: @@ -47,8 +47,8 @@ struct M6502AddSubWithCarryTests { cpu.Flag.Z = !Test.ExpectZ; cpu.Flag.N = !Test.ExpectN; cpu.Flag.V = !Test.ExpectV; - mem[0xFF00] = - (Operation == EOperation::Add) ? + mem[0xFF00] = + (Operation == EOperation::Add) ? CPU::INS_ADC_ABS : CPU::INS_SBC_ABS; mem[0xFF01] = 0x00; mem[0xFF02] = 0x80; @@ -152,7 +152,7 @@ struct M6502AddSubWithCarryTests { TestADCImmediate( Test, EOperation::Subtract ); } - void TestADCImmediate( ADCTestData Test, + void TestADCImmediate( ADCTestData Test, EOperation Operation = EOperation::Add ) { // given: @@ -199,7 +199,7 @@ struct M6502AddSubWithCarryTests { cpu.Flag.Z = !Test.ExpectZ; cpu.Flag.N = !Test.ExpectN; cpu.Flag.V = !Test.ExpectV; - mem[0xFF00] = + mem[0xFF00] = (Operation == EOperation::Add) ? CPU::INS_ADC_ZP : CPU::INS_SBC_ZP; mem[0xFF01] = 0x42; @@ -225,7 +225,7 @@ struct M6502AddSubWithCarryTests { TestADCZeroPageX( Test, EOperation::Subtract ); } - void TestADCZeroPageX( ADCTestData Test, + void TestADCZeroPageX( ADCTestData Test, EOperation Operation = EOperation::Add ) { // given: @@ -263,7 +263,7 @@ struct M6502AddSubWithCarryTests { TestADCIndirectX( Test, EOperation::Subtract ); } - void TestADCIndirectX( ADCTestData Test, + void TestADCIndirectX( ADCTestData Test, EOperation Operation = EOperation::Add ) { // given: @@ -303,7 +303,7 @@ struct M6502AddSubWithCarryTests { TestADCIndirectY( Test, EOperation::Subtract ); } - void TestADCIndirectY( ADCTestData Test, + void TestADCIndirectY( ADCTestData Test, EOperation Operation = EOperation::Add ) { // given: @@ -345,7 +345,7 @@ TEST_F_SETUP(M6502AddSubWithCarryTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502AddSubWithCarryTests){} +TEST_F_TEARDOWN(M6502AddSubWithCarryTests){ (void)tau; } TEST_F( M6502AddSubWithCarryTests, ADCAbsCanAddZeroToZeroAndGetZero ) { @@ -391,7 +391,7 @@ TEST_F( M6502AddSubWithCarryTests, ADCAbsCanAddTwoUnsignedNumbers ) TEST_F( M6502AddSubWithCarryTests, ADCAbsCanAddAPositiveAndNegativeNumber ) { - // A: 00010100 20 + // A: 00010100 20 // O: 11101111 -17 // =: 00000011 // C:1 N:0 V:0 Z:0 @@ -412,7 +412,7 @@ TEST_F( M6502AddSubWithCarryTests, ADCAbsCanAddOneToFFAndItWillCauseACarry ) { M6502AddSubWithCarryTests::ADCTestData Test; Test.Carry = false; - Test.A = 0xFF; + Test.A = 0xFF; Test.Operand = 1; Test.Answer = 0; Test.ExpectC = true; @@ -454,7 +454,7 @@ TEST_F( M6502AddSubWithCarryTests, ADCAbsWillSetTheOverflowFlagWhenSignedNegativ tau->TestADCAbsolute( Test ); } -TEST_F( M6502AddSubWithCarryTests, +TEST_F( M6502AddSubWithCarryTests, ADCAbsWillSetTheOverflowFlagWhenSignedNegativeAddtionPassedDueToInitalCarryFlag ) { // C: 00000001 @@ -477,7 +477,7 @@ TEST_F( M6502AddSubWithCarryTests, TEST_F( M6502AddSubWithCarryTests, ADCAbsWillSetTheOverflowFlagWhenSignedPositiveAddtionFails ) { - // A: 01111111 127 + // A: 01111111 127 // O: 00000001 1 // =: 10000000 128 // C:0 N:1 V:1 Z:0 @@ -509,7 +509,7 @@ TEST_F( M6502AddSubWithCarryTests, ADCImmediateCanAddTwoUnsignedNumbers ) TEST_F( M6502AddSubWithCarryTests, ADCImmediateCanAddAPositiveAndNegativeNumber ) { - // A: 00010100 20 + // A: 00010100 20 // O: 11101111 -17 // =: 00000011 // C:1 N:0 V:0 Z:0 @@ -542,7 +542,7 @@ TEST_F( M6502AddSubWithCarryTests, ADCZeroPageCanAddTwoUnsignedNumbers ) TEST_F( M6502AddSubWithCarryTests, ADCZeroPageCanAddAPositiveAndNegativeNumber ) { - // A: 00010100 20 + // A: 00010100 20 // O: 11101111 -17 // =: 00000011 // C:1 N:0 V:0 Z:0 @@ -575,7 +575,7 @@ TEST_F( M6502AddSubWithCarryTests, ADCZeroPageXCanAddTwoUnsignedNumbers ) TEST_F( M6502AddSubWithCarryTests, ADCZeroPageXCanAddAPositiveAndNegativeNumber ) { - // A: 00010100 20 + // A: 00010100 20 // O: 11101111 -17 // =: 00000011 // C:1 N:0 V:0 Z:0 @@ -608,7 +608,7 @@ TEST_F( M6502AddSubWithCarryTests, ADCAbsXCanAddTwoUnsignedNumbers ) TEST_F( M6502AddSubWithCarryTests, ADCAbsXCanAddAPositiveAndNegativeNumber ) { - // A: 00010100 20 + // A: 00010100 20 // O: 11101111 -17 // =: 00000011 // C:1 N:0 V:0 Z:0 @@ -641,7 +641,7 @@ TEST_F( M6502AddSubWithCarryTests, ADCAbsYCanAddTwoUnsignedNumbers ) TEST_F( M6502AddSubWithCarryTests, ADCAbsYCanAddAPositiveAndNegativeNumber ) { - // A: 00010100 20 + // A: 00010100 20 // O: 11101111 -17 // =: 00000011 // C:1 N:0 V:0 Z:0 @@ -674,7 +674,7 @@ TEST_F( M6502AddSubWithCarryTests, ADCIndXCanAddTwoUnsignedNumbers ) TEST_F( M6502AddSubWithCarryTests, ADCIndXCanAddAPositiveAndNegativeNumber ) { - // A: 00010100 20 + // A: 00010100 20 // O: 11101111 -17 // =: 00000011 // C:1 N:0 V:0 Z:0 @@ -707,7 +707,7 @@ TEST_F( M6502AddSubWithCarryTests, ADCIndYCanAddTwoUnsignedNumbers ) TEST_F( M6502AddSubWithCarryTests, ADCIndYCanAddAPositiveAndNegativeNumber ) { - // A: 00010100 20 + // A: 00010100 20 // O: 11101111 -17 // =: 00000011 // C:1 N:0 V:0 Z:0 @@ -1634,4 +1634,4 @@ TEST_F( M6502AddSubWithCarryTests, SBCIndirectYCanSubtractTwoNegativeNumbers ) Test.ExpectV = false; Test.ExpectZ = false; tau->TestSBCIndirectY( Test ); -} \ No newline at end of file +} diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502BranchTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502BranchTests.cpp index e42a249..5a000bb 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502BranchTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502BranchTests.cpp @@ -12,7 +12,7 @@ TEST_F_SETUP(M6502BranchTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502BranchTests){} +TEST_F_TEARDOWN(M6502BranchTests){ (void)tau; } TEST_F( M6502BranchTests, BEQCanBranchForwardsWhenZeroIsSet ) { @@ -260,4 +260,4 @@ TEST_F( M6502BranchTests, BVCCanBranchForwardsWhenOverflowNegativeIsNotSet ) CHECK_EQ( ActualCycles, EXPECTED_CYCLES ); CHECK_EQ( tau->cpu.PC, 0xFF03 ); CHECK_EQ( tau->cpu.PS, CPUCopy.PS ); -} \ No newline at end of file +} diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502CompareRegisterTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502CompareRegisterTests.cpp index 861d141..055e84a 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502CompareRegisterTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502CompareRegisterTests.cpp @@ -86,6 +86,8 @@ struct M6502CompareRegisterTests Byte Opcode = CPU::INS_CMP; switch ( RegisterToCompare ) { + case ERegister::A: + break; case ERegister::X: Register = &cpu.X; Opcode = CPU::INS_CPX; @@ -122,11 +124,13 @@ struct M6502CompareRegisterTests cpu.Flag.C = !Test.ExpectC; cpu.Flag.Z = !Test.ExpectZ; cpu.Flag.N = !Test.ExpectN; - + Byte* Register = &cpu.A; Byte Opcode = CPU::INS_CMP_ZP; switch ( RegisterToCompare ) { + case ERegister::A: + break; case ERegister::X: Register = &cpu.X; Opcode = CPU::INS_CPX_ZP; @@ -197,6 +201,8 @@ struct M6502CompareRegisterTests Byte Opcode = CPU::INS_CMP_ABS; switch ( RegisterToCompare ) { + case ERegister::A: + break; case ERegister::X: Register = &cpu.X; Opcode = CPU::INS_CPX_ABS; @@ -356,7 +362,7 @@ TEST_F_SETUP(M6502CompareRegisterTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502CompareRegisterTests){} +TEST_F_TEARDOWN(M6502CompareRegisterTests){ (void)tau; } TEST_F( M6502CompareRegisterTests, CMPImmediateCanCompareTwoIdenticalValues ) { @@ -725,7 +731,7 @@ TEST_F( M6502CompareRegisterTests, LoopTest ) { // given: using namespace m6502; - /* + /* * = $1000 lda #0 @@ -749,4 +755,4 @@ TEST_F( M6502CompareRegisterTests, LoopTest ) Clock -= tau->cpu.Execute( 1, tau->mem ); } } -#endif \ No newline at end of file +#endif diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502IncrementDecrementTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502IncrementDecrementTests.cpp index 8fd8dac..39acd80 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502IncrementDecrementTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502IncrementDecrementTests.cpp @@ -21,7 +21,7 @@ TEST_F_SETUP(M6502IncrementDecrementTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502IncrementDecrementTests){} +TEST_F_TEARDOWN(M6502IncrementDecrementTests){ (void)tau; } TEST_F( M6502IncrementDecrementTests, INXCanIncrementAZeroValue ) { @@ -519,7 +519,7 @@ TEST_F( M6502IncrementDecrementTests, TestLoadAProgramThatCanIncMemory ) inx jmp start */ - Byte TestPrg[] = + Byte TestPrg[] = { 0x0,0x10,0xA9,0x00,0x85,0x42,0xE6,0x42, 0xA6,0x42,0xE8,0x4C,0x04,0x10 }; @@ -531,4 +531,4 @@ TEST_F( M6502IncrementDecrementTests, TestLoadAProgramThatCanIncMemory ) { Clock -= tau->cpu.Execute( 1, tau->mem ); } -} \ No newline at end of file +} diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502JumpsAndCallsTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502JumpsAndCallsTests.cpp index 7b83f32..8cd8e8d 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502JumpsAndCallsTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502JumpsAndCallsTests.cpp @@ -3,7 +3,7 @@ struct M6502JumpsAndCallsTests { -public: +public: m6502::Mem mem; m6502::CPU cpu; }; @@ -12,7 +12,7 @@ TEST_F_SETUP(M6502JumpsAndCallsTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502JumpsAndCallsTests){} +TEST_F_TEARDOWN(M6502JumpsAndCallsTests){ (void)tau; } TEST_F( M6502JumpsAndCallsTests, CanJumpToASubroutineAndJumpBackAgain ) { diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502LoadPrgTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502LoadPrgTests.cpp index dc580dd..2942d2e 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502LoadPrgTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502LoadPrgTests.cpp @@ -1,7 +1,7 @@ #include #include "m6502.h" -/** +/** ; TestPrg * = $1000 @@ -23,7 +23,7 @@ static const m6502::u32 NumBytesInPrg = 14; struct M6502LoadPrgTests { -public: +public: m6502::Mem mem; m6502::CPU cpu; }; @@ -32,7 +32,7 @@ TEST_F_SETUP(M6502LoadPrgTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502LoadPrgTests){} +TEST_F_TEARDOWN(M6502LoadPrgTests){ (void)tau; } TEST_F( M6502LoadPrgTests, TestLoadProgramAProgramIntoTheCorrectAreaOfMemory ) { @@ -69,27 +69,3 @@ TEST_F( M6502LoadPrgTests, TestLoadProgramAProgramAndExecuteIt ) Clock -= tau->cpu.Execute( 1, tau->mem ); } } - -TEST_F( M6502LoadPrgTests, LoadThe6502TestPrg ) -{ -#if 0 - // given: - using namespace m6502; - - // when: - FILE* fp; - fopen_s( &fp, - "6502_functional_test.bin", "rb" ); - - fread( &tau->mem[0x000A], 1, 65526, fp ); - fclose( fp ); - - tau->cpu.PC = 0x400; - - //then: - while ( true ) - { - tau->cpu.Execute( 1, tau->mem ); - } -#endif -} \ No newline at end of file diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502LoadRegisterTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502LoadRegisterTests.cpp index 1de56c6..f2ce30a 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502LoadRegisterTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502LoadRegisterTests.cpp @@ -2,12 +2,12 @@ #include "m6502.h" struct M6502LoadRegisterTests { -public: +public: m6502::Mem mem; m6502::CPU cpu; - void TestLoadRegisterImmediate( - m6502::Byte Opcode, + void TestLoadRegisterImmediate( + m6502::Byte Opcode, m6502::Byte m6502::CPU::* ); void TestLoadRegisterZeroPage( @@ -47,10 +47,10 @@ TEST_F_SETUP(M6502LoadRegisterTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502LoadRegisterTests){} +TEST_F_TEARDOWN(M6502LoadRegisterTests){ (void)tau; } -static void VerfifyUnmodifiedFlagsFromLoadRegister( - const m6502::CPU& cpu, +static void VerfifyUnmodifiedFlagsFromLoadRegister( + const m6502::CPU& cpu, const m6502::CPU& CPUCopy ) { CHECK_EQ( cpu.Flag.C, CPUCopy.Flag.C ); @@ -79,7 +79,6 @@ TEST_F( M6502LoadRegisterTests, CPUCanExecuteMoreCyclesThanRequestedIfRequiredBy using namespace m6502; tau->mem[0xFFFC] = CPU::INS_LDA_IM; tau->mem[0xFFFD] = 0x84; - CPU CPUCopy = tau->cpu; constexpr s32 NUM_CYCLES = 1; //when: @@ -89,8 +88,8 @@ TEST_F( M6502LoadRegisterTests, CPUCanExecuteMoreCyclesThanRequestedIfRequiredBy CHECK_EQ( CyclesUsed, 2 ); } -void M6502LoadRegisterTests::TestLoadRegisterImmediate( - m6502::Byte OpcodeToTest, +void M6502LoadRegisterTests::TestLoadRegisterImmediate( + m6502::Byte OpcodeToTest, m6502::Byte m6502::CPU::*RegisterToTest ) { // given: @@ -103,7 +102,7 @@ void M6502LoadRegisterTests::TestLoadRegisterImmediate( s32 CyclesUsed = cpu.Execute( 2, mem ); //then: - CHECK_EQ( cpu.*RegisterToTest, 0x84 ); + CHECK_EQ( cpu.*RegisterToTest, 0x84 ); CHECK_EQ( CyclesUsed, 2 ); CHECK_FALSE( cpu.Flag.Z ); CHECK_TRUE( cpu.Flag.N ); @@ -473,7 +472,7 @@ TEST_F( M6502LoadRegisterTests, LDAIndirectXCanLoadAValueIntoTheARegister ) tau->mem[0xFFFC] = CPU::INS_LDA_INDX; tau->mem[0xFFFD] = 0x02; tau->mem[0x0006] = 0x00; //0x2 + 0x4 - tau->mem[0x0007] = 0x80; + tau->mem[0x0007] = 0x80; tau->mem[0x8000] = 0x37; constexpr s32 EXPECTED_CYCLES = 6; CPU CPUCopy = tau->cpu; @@ -497,7 +496,7 @@ TEST_F( M6502LoadRegisterTests, LDAIndirectYCanLoadAValueIntoTheARegister ) tau->cpu.Y = 0x04; tau->mem[0xFFFC] = CPU::INS_LDA_INDY; tau->mem[0xFFFD] = 0x02; - tau->mem[0x0002] = 0x00; + tau->mem[0x0002] = 0x00; tau->mem[0x0003] = 0x80; tau->mem[0x8004] = 0x37; //0x8000 + 0x4 constexpr s32 EXPECTED_CYCLES = 5; diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502ShiftsTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502ShiftsTests.cpp index a65dcff..9119738 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502ShiftsTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502ShiftsTests.cpp @@ -11,7 +11,7 @@ TEST_F_SETUP(M6502ShiftsTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502ShiftsTests){} +TEST_F_TEARDOWN(M6502ShiftsTests){ (void)tau; } TEST_F( M6502ShiftsTests, ASLCanShiftTheValueOfOne ) @@ -25,7 +25,6 @@ TEST_F( M6502ShiftsTests, ASLCanShiftTheValueOfOne ) tau->cpu.A = 1; tau->mem[0xFF00] = CPU::INS_ASL; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -35,7 +34,7 @@ TEST_F( M6502ShiftsTests, ASLCanShiftTheValueOfOne ) CHECK_EQ( tau->cpu.A, 2 ); CHECK_FALSE( tau->cpu.Flag.C ); CHECK_FALSE( tau->cpu.Flag.Z ); - CHECK_FALSE( tau->cpu.Flag.N ); + CHECK_FALSE( tau->cpu.Flag.N ); } TEST_F( M6502ShiftsTests, ASLCanShiftANegativeValue ) @@ -49,7 +48,6 @@ TEST_F( M6502ShiftsTests, ASLCanShiftANegativeValue ) tau->cpu.A = 0b11000010; tau->mem[0xFF00] = CPU::INS_ASL; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -74,7 +72,6 @@ TEST_F( M6502ShiftsTests, ASLZeroPageCanShiftTheValueOfOne ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 1; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -99,7 +96,6 @@ TEST_F( M6502ShiftsTests, ASLZeroPageCanShiftANegativeValue ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 0b11000010; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -125,7 +121,6 @@ TEST_F( M6502ShiftsTests, ASLZeroPageXCanShiftTheValueOfOne ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042 + 0x10] = 1; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -151,7 +146,6 @@ TEST_F( M6502ShiftsTests, ASLZeroPageXCanShiftANegativeValue ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042 + 0x10] = 0b11000010; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -177,7 +171,6 @@ TEST_F( M6502ShiftsTests, ASLAbsCanShiftTheValueOfOne ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 1; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -203,7 +196,6 @@ TEST_F( M6502ShiftsTests, ASLAbsCanShiftANegativeValue ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 0b11000010; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -230,7 +222,6 @@ TEST_F( M6502ShiftsTests, ASLAbsXCanShiftTheValueOfOne ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000 + 0x10] = 1; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -257,7 +248,6 @@ TEST_F( M6502ShiftsTests, ASLAbsXCanShiftANegativeValue ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000+0x10] = 0b11000010; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -281,7 +271,6 @@ TEST_F( M6502ShiftsTests, LSRCanShiftTheValueOfOne ) tau->cpu.A = 1; tau->mem[0xFF00] = CPU::INS_LSR; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -305,7 +294,6 @@ TEST_F( M6502ShiftsTests, LSRCanShiftAZeroIntoTheCarryFlag ) tau->cpu.A = 8; tau->mem[0xFF00] = CPU::INS_LSR; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -330,7 +318,6 @@ TEST_F( M6502ShiftsTests, LSRZeroPageCanShiftTheValueOfOne ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 1; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -355,7 +342,6 @@ TEST_F( M6502ShiftsTests, LSRZeroPageCanShiftAZeroIntoTheCarryFlag ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 8; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -381,7 +367,6 @@ TEST_F( M6502ShiftsTests, LSRZeroPageXCanShiftTheValueOfOne ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042+ 0x10] = 1; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -407,7 +392,6 @@ TEST_F( M6502ShiftsTests, LSRZeroPageXCanShiftAZeroIntoTheCarryFlag ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042+ 0x10] = 8; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -433,7 +417,6 @@ TEST_F( M6502ShiftsTests, LSRAbsCanShiftTheValueOfOne ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 1; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -459,7 +442,6 @@ TEST_F( M6502ShiftsTests, LSRAbsCanShiftAZeroIntoTheCarryFlag ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 8; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -486,7 +468,6 @@ TEST_F( M6502ShiftsTests, LSRAbsXCanShiftTheValueOfOne ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000+0x10] = 1; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -513,7 +494,6 @@ TEST_F( M6502ShiftsTests, LSRAbsXCanShiftAZeroIntoTheCarryFlag ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000 + 0x10] = 8; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -539,7 +519,6 @@ TEST_F( M6502ShiftsTests, ROLCanShiftABitOutOfTheCarryFlag ) tau->cpu.A = 0; tau->mem[0xFF00] = CPU::INS_ROL; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -563,7 +542,6 @@ TEST_F( M6502ShiftsTests, ROLCanShiftABitIntoTheCarryFlag ) tau->cpu.A = 0b10000000; tau->mem[0xFF00] = CPU::INS_ROL; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -587,7 +565,6 @@ TEST_F( M6502ShiftsTests, ROLCanShiftZeroWithNoCarry ) tau->cpu.A = 0; tau->mem[0xFF00] = CPU::INS_ROL; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -611,7 +588,6 @@ TEST_F( M6502ShiftsTests, ROLCanShiftAValueThatResultInANegativeValue ) tau->cpu.A = 0b01110011; tau->mem[0xFF00] = CPU::INS_ROL; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -638,7 +614,6 @@ TEST_F( M6502ShiftsTests, ROLZeroPageCanShiftABitOutOfTheCarryFlag ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 0; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -663,7 +638,6 @@ TEST_F( M6502ShiftsTests, ROLZeroPageCanShiftABitIntoTheCarryFlag ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 0b10000000; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -688,7 +662,6 @@ TEST_F( M6502ShiftsTests, ROLZeroPageCanShiftZeroWithNoCarry ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 0; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -713,7 +686,6 @@ TEST_F( M6502ShiftsTests, ROLZeroPageCanShiftAValueThatResultInANegativeValue ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 0b01110011; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -741,7 +713,6 @@ TEST_F( M6502ShiftsTests, ROLZeroPageXCanShiftABitOutOfTheCarryFlag ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042 + 0x10] = 0; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -767,7 +738,6 @@ TEST_F( M6502ShiftsTests, ROLZeroPageXCanShiftABitIntoTheCarryFlag ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042+0x10] = 0b10000000; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -793,7 +763,6 @@ TEST_F( M6502ShiftsTests, ROLZeroPageXCanShiftZeroWithNoCarry ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042 + 0x10] = 0; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -819,7 +788,6 @@ TEST_F( M6502ShiftsTests, ROLZeroPageXCanShiftAValueThatResultInANegativeValue ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042 + 0x10] = 0b01110011; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -847,7 +815,6 @@ TEST_F( M6502ShiftsTests, ROLAbsoluteCanShiftABitOutOfTheCarryFlag ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 0; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -873,7 +840,6 @@ TEST_F( M6502ShiftsTests, ROLAbsoluteCanShiftABitIntoTheCarryFlag ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 0b10000000; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -899,7 +865,6 @@ TEST_F( M6502ShiftsTests, ROLAbsoluteCanShiftZeroWithNoCarry ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 0; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -925,7 +890,6 @@ TEST_F( M6502ShiftsTests, ROLAbsoluteCanShiftAValueThatResultInANegativeValue ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 0b01110011; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -954,7 +918,6 @@ TEST_F( M6502ShiftsTests, ROLAbsoluteXCanShiftABitOutOfTheCarryFlag ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000+0x10] = 0; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -981,7 +944,6 @@ TEST_F( M6502ShiftsTests, ROLAbsoluteXCanShiftABitIntoTheCarryFlag ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000 + 0x10] = 0b10000000; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1008,7 +970,6 @@ TEST_F( M6502ShiftsTests, ROLAbsoluteXCanShiftZeroWithNoCarry ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000 + 0x10] = 0; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1035,7 +996,6 @@ TEST_F( M6502ShiftsTests, ROLAbsoluteXCanShiftAValueThatResultInANegativeValue ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000 + 0x10] = 0b01110011; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1061,7 +1021,6 @@ TEST_F( M6502ShiftsTests, RORCanShiftTheCarryFlagIntoTheOperand ) tau->cpu.A = 0; tau->mem[0xFF00] = CPU::INS_ROR; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1085,7 +1044,6 @@ TEST_F( M6502ShiftsTests, RORCanShiftAValueIntoTheCarryFlag ) tau->cpu.A = 1; tau->mem[0xFF00] = CPU::INS_ROR; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1109,7 +1067,6 @@ TEST_F( M6502ShiftsTests, RORCanRotateANumber ) tau->cpu.A = 0b01101101; tau->mem[0xFF00] = CPU::INS_ROR; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1136,7 +1093,6 @@ TEST_F( M6502ShiftsTests, RORZeroPageCanShiftTheCarryFlagIntoTheOperand ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 0; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1161,7 +1117,6 @@ TEST_F( M6502ShiftsTests, RORZeroPageCanShiftAValueIntoTheCarryFlag ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 1; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1186,7 +1141,6 @@ TEST_F( M6502ShiftsTests, RORZeroPageCanRotateANumber ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042] = 0b01101101; constexpr s32 EXPECTED_CYCLES = 5; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1214,7 +1168,6 @@ TEST_F( M6502ShiftsTests, RORZeroXPageCanShiftTheCarryFlagIntoTheOperand ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042 + 0x10] = 0; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1240,7 +1193,6 @@ TEST_F( M6502ShiftsTests, RORZeroXPageCanShiftAValueIntoTheCarryFlag ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042+0x10] = 1; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1266,7 +1218,6 @@ TEST_F( M6502ShiftsTests, RORZeroXPageCanRotateANumber ) tau->mem[0xFF01] = 0x42; tau->mem[0x0042 + 0x10] = 0b01101101; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1294,7 +1245,6 @@ TEST_F( M6502ShiftsTests, RORAbsolutePageCanShiftTheCarryFlagIntoTheOperand ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 0; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1320,7 +1270,6 @@ TEST_F( M6502ShiftsTests, RORAbsolutePageCanShiftAValueIntoTheCarryFlag ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 1; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1346,7 +1295,6 @@ TEST_F( M6502ShiftsTests, RORAbsolutePageCanRotateANumber ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000] = 0b01101101; constexpr s32 EXPECTED_CYCLES = 6; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1375,7 +1323,6 @@ TEST_F( M6502ShiftsTests, RORAbsoluteXPageCanShiftTheCarryFlagIntoTheOperand ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000 + 0x10] = 0; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1402,7 +1349,6 @@ TEST_F( M6502ShiftsTests, RORAbsoluteXPageCanShiftAValueIntoTheCarryFlag ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000+0x10] = 1; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1429,7 +1375,6 @@ TEST_F( M6502ShiftsTests, RORAbsoluteXPageCanRotateANumber ) tau->mem[0xFF02] = 0x80; tau->mem[0x8000 + 0x10] = 0b01101101; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -1440,4 +1385,4 @@ TEST_F( M6502ShiftsTests, RORAbsoluteXPageCanRotateANumber ) CHECK_TRUE( tau->cpu.Flag.C ); CHECK_FALSE( tau->cpu.Flag.Z ); CHECK_TRUE( tau->cpu.Flag.N ); -} \ No newline at end of file +} diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StackOperationsTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StackOperationsTests.cpp index d18f7b4..ae0812d 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StackOperationsTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StackOperationsTests.cpp @@ -3,7 +3,7 @@ struct M6502StackOperationsTests { -public: +public: m6502::Mem mem; m6502::CPU cpu; }; @@ -12,7 +12,7 @@ TEST_F_SETUP(M6502StackOperationsTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502StackOperationsTests){} +TEST_F_TEARDOWN(M6502StackOperationsTests){ (void)tau; } TEST_F( M6502StackOperationsTests, TSXCanTransferTheStackPointerToXRegister ) { @@ -24,7 +24,6 @@ TEST_F( M6502StackOperationsTests, TSXCanTransferTheStackPointerToXRegister ) tau->cpu.SP = 0x01; tau->mem[0xFF00] = CPU::INS_TSX; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -46,7 +45,6 @@ TEST_F( M6502StackOperationsTests, TSXCanTransferAZeroStackPointerToXRegister ) tau->cpu.SP = 0x00; tau->mem[0xFF00] = CPU::INS_TSX; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -68,7 +66,6 @@ TEST_F( M6502StackOperationsTests, TSXCanTransferANegativeStackPointerToXRegiste tau->cpu.SP = 0b10000000; tau->mem[0xFF00] = CPU::INS_TSX; constexpr s32 EXPECTED_CYCLES = 2; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -130,7 +127,6 @@ TEST_F( M6502StackOperationsTests, PLACanPullAValueFromTheStackIntoTheARegsiter tau->mem[0x01FF] = 0x42; tau->mem[0xFF00] = CPU::INS_PLA; constexpr s32 EXPECTED_CYCLES = 4; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -153,7 +149,6 @@ TEST_F( M6502StackOperationsTests, PLACanPullAZeroValueFromTheStackIntoTheARegsi tau->mem[0x01FF] = 0x00; tau->mem[0xFF00] = CPU::INS_PLA; constexpr s32 EXPECTED_CYCLES = 4; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -178,7 +173,6 @@ TEST_F( M6502StackOperationsTests, PLACanPullANegativeValueFromTheStackIntoTheAR tau->mem[0x01FF] = 0b10000001; tau->mem[0xFF00] = CPU::INS_PLA; constexpr s32 EXPECTED_CYCLES = 4; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -206,7 +200,7 @@ TEST_F( M6502StackOperationsTests, PHPCanPushProcessorStatusOntoTheStack ) // then: CHECK_EQ( ActualCycles, EXPECTED_CYCLES ); - CHECK_EQ( tau->mem[tau->cpu.SPToAddress() + 1], + CHECK_EQ( tau->mem[tau->cpu.SPToAddress() + 1], 0xCC | CPU::UnusedFlagBit | CPU::BreakFlagBit ); CHECK_EQ( tau->cpu.PS, CPUCopy.PS ); CHECK_EQ( tau->cpu.SP, 0xFE ); @@ -220,7 +214,6 @@ TEST_F( M6502StackOperationsTests, PHPAlwaysSetsBits4And5OnTheStack ) tau->cpu.PS = 0x0; tau->mem[0xFF00] = CPU::INS_PHP; constexpr s32 EXPECTED_CYCLES = 3; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -230,12 +223,12 @@ TEST_F( M6502StackOperationsTests, PHPAlwaysSetsBits4And5OnTheStack ) CHECK_EQ( ActualCycles, EXPECTED_CYCLES ); // https://wiki.nesdev.com/w/index.php/Status_flags - //Two interrupts (/IRQ and /NMI) and two instructions (PHP and BRK) push - // the flags to the stack. In the byte pushed, bit 5 is always set to 1, - //and bit 4 is 1 if from an instruction (PHP or BRK) or 0 if from an - // interrupt line being pulled low (/IRQ or /NMI). This is the only time - // and place where the B flag actually exists: not in the status register - // itself, but in bit 4 of the copy that is written to the stack. + //Two interrupts (/IRQ and /NMI) and two instructions (PHP and BRK) push + // the flags to the stack. In the byte pushed, bit 5 is always set to 1, + //and bit 4 is 1 if from an instruction (PHP or BRK) or 0 if from an + // interrupt line being pulled low (/IRQ or /NMI). This is the only time + // and place where the B flag actually exists: not in the status register + // itself, but in bit 4 of the copy that is written to the stack. const Byte FlagsOnStack = CPU::UnusedFlagBit | CPU::BreakFlagBit; CHECK_EQ( tau->mem[AddPSOnStack], FlagsOnStack ); } @@ -250,7 +243,6 @@ TEST_F( M6502StackOperationsTests, PLPCanPullAValueFromTheStackIntoTheProcessorS tau->mem[0x01FF] = 0x42 | CPU::BreakFlagBit | CPU::UnusedFlagBit; tau->mem[0xFF00] = CPU::INS_PLP; constexpr s32 EXPECTED_CYCLES = 4; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -270,7 +262,6 @@ TEST_F( M6502StackOperationsTests, PLPClearsBits4And5WhenPullingFromTheStack ) tau->mem[0x01FF] = CPU::BreakFlagBit | CPU::UnusedFlagBit; tau->mem[0xFF00] = CPU::INS_PLP; constexpr s32 EXPECTED_CYCLES = 4; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -278,4 +269,4 @@ TEST_F( M6502StackOperationsTests, PLPClearsBits4And5WhenPullingFromTheStack ) // then: CHECK_EQ( ActualCycles, EXPECTED_CYCLES ); CHECK_EQ( tau->cpu.PS, 0 ); -} \ No newline at end of file +} diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StatusFlagChangeTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StatusFlagChangeTests.cpp index 23ec78e..9784bb8 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StatusFlagChangeTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StatusFlagChangeTests.cpp @@ -12,7 +12,7 @@ TEST_F_SETUP(M6502StatusFlagChangeTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502StatusFlagChangeTests){} +TEST_F_TEARDOWN(M6502StatusFlagChangeTests){ (void)tau; } TEST_F( M6502StatusFlagChangeTests, CLCWillClearTheCarryFlag ) @@ -182,4 +182,3 @@ TEST_F( M6502StatusFlagChangeTests, CLVWillClearTheOverflowFlag ) CHECK_EQ( tau->cpu.Flag.I, CPUCopy.Flag.I ); CHECK_EQ( tau->cpu.Flag.N, CPUCopy.Flag.N ); } - diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StoreRegisterTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StoreRegisterTests.cpp index 0fe91dc..bc82d2b 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StoreRegisterTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502StoreRegisterTests.cpp @@ -15,7 +15,7 @@ static void VerfifyUnmodifiedFlagsFromStoreRegister( } struct M6502StoreRegisterTests { -public: +public: m6502::Mem mem; m6502::CPU cpu; @@ -115,7 +115,7 @@ TEST_F_SETUP(M6502StoreRegisterTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502StoreRegisterTests){} +TEST_F_TEARDOWN(M6502StoreRegisterTests){ (void)tau; } TEST_F( M6502StoreRegisterTests, STAZeroPageCanStoreTheARegisterIntoMemory ) diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502SystemFunctionsTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502SystemFunctionsTests.cpp index 4d435b6..d94b2d9 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502SystemFunctionsTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502SystemFunctionsTests.cpp @@ -11,7 +11,7 @@ TEST_F_SETUP(M6502SystemFunctionsTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502SystemFunctionsTests){} +TEST_F_TEARDOWN(M6502SystemFunctionsTests){ (void)tau; } TEST_F( M6502SystemFunctionsTests, NOPWillDoNothingButConsumeACycle ) { @@ -44,7 +44,6 @@ TEST_F( M6502SystemFunctionsTests, BRKWillLoadTheProgramCounterFromTheInterruptV tau->mem[0xFFFE] = 0x00; tau->mem[0xFFFF] = 0x80; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -63,7 +62,6 @@ TEST_F( M6502SystemFunctionsTests, BRKWillLoadTheProgramCounterFromTheInterruptV tau->mem[0xFFFE] = 0x00; tau->mem[0xFFFF] = 0x90; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -81,7 +79,6 @@ TEST_F( M6502SystemFunctionsTests, BRKWillSetTheBreakFlag ) tau->cpu.Flag.B = false; tau->mem[0xFF00] = CPU::INS_BRK; constexpr s32 EXPECTED_CYCLES = 7; - CPU CPUCopy = tau->cpu; // when: const s32 ActualCycles = tau->cpu.Execute( EXPECTED_CYCLES, tau->mem ); @@ -125,18 +122,18 @@ TEST_F( M6502SystemFunctionsTests, BRKWillPushPCandPSOntoTheStack ) CHECK_EQ( ActualCycles, EXPECTED_CYCLES ); CHECK_EQ( tau->mem[(0x100 | OldSP)-0], 0xFF ); // https://www.c64-wiki.com/wiki/BRK - // Note that since BRK increments the program counter by - // 2 instead of 1, it is advisable to use a NOP after it + // Note that since BRK increments the program counter by + // 2 instead of 1, it is advisable to use a NOP after it // to avoid issues CHECK_EQ( tau->mem[(0x100 | OldSP)-1], 0x02 ); - CHECK_EQ( tau->mem[(0x100 | OldSP)-2], - CPUCopy.PS - | CPU::UnusedFlagBit + CHECK_EQ( tau->mem[(0x100 | OldSP)-2], + CPUCopy.PS + | CPU::UnusedFlagBit | CPU::BreakFlagBit ); // https://wiki.nesdev.com/w/index.php/Status_flags - // Instruction |Bits 5 and 4 | Side effects after pushing - // BRK | 11 | I is set to 1 + // Instruction |Bits 5 and 4 | Side effects after pushing + // BRK | 11 | I is set to 1 CHECK_EQ( tau->cpu.Flag.I, true ); } @@ -164,5 +161,3 @@ TEST_F( M6502SystemFunctionsTests, RTICanReturnFromAnInterruptLeavingTheCPUInThe CHECK_EQ( 0xFF02, tau->cpu.PC ); CHECK_EQ( CPUCopy.PS, tau->cpu.PS ); } - - diff --git a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502TransferRegisterTests.cpp b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502TransferRegisterTests.cpp index f551fab..ab99f05 100644 --- a/test/ThirdParty/6502Emulator/6502/6502Test/src/6502TransferRegisterTests.cpp +++ b/test/ThirdParty/6502Emulator/6502/6502Test/src/6502TransferRegisterTests.cpp @@ -22,7 +22,7 @@ TEST_F_SETUP(M6502TransferRegistgerTests) { tau->cpu.Reset( tau->mem ); } -TEST_F_TEARDOWN(M6502TransferRegistgerTests){} +TEST_F_TEARDOWN(M6502TransferRegistgerTests){ (void)tau; } TEST_F( M6502TransferRegistgerTests, TAXCanTransferANonNegativeNonZeroValue ) { @@ -322,4 +322,4 @@ TEST_F( M6502TransferRegistgerTests, TYACanTransferANegativeValue ) CHECK_FALSE( tau->cpu.Flag.Z ); CHECK_TRUE( tau->cpu.Flag.N ); tau->ExpectUnaffectedRegisters( CPUCopy ); -} \ No newline at end of file +}