-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19d92fd
commit a2a6f29
Showing
30 changed files
with
509 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
cplusplus/tests/source/should_add_value_to_value_in_registry.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x01, 0x70, 0x01 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0x2 == registers->get(0)); | ||
} |
16 changes: 16 additions & 0 deletions
16
cplusplus/tests/source/should_add_value_to_value_in_registry_and_resolve_overflow.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0xFF, 0x70, 0xFF }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(254 == registers->get(0)); | ||
} |
16 changes: 16 additions & 0 deletions
16
cplusplus/tests/source/should_not_skip_next_instruction_if_equals.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x01, 0x40, 0x01 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(516 == cpu->getPc()); | ||
} |
16 changes: 16 additions & 0 deletions
16
cplusplus/tests/source/should_not_skip_next_instruction_if_vx_not_equals_vy.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x01, 0x61, 0x02, 0x50, 0x10 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(518 == cpu->getPc()); | ||
} |
16 changes: 16 additions & 0 deletions
16
cplusplus/tests/source/should_skip_next_instruction_if_vx_equals_vy.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x01, 0x61, 0x01, 0x50, 0x10 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(520 == cpu->getPc()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x01 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0x1 == registers->get(0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x01, 0x62, 0x02, 0x80, 0x20 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, 4); | ||
|
||
// assert | ||
assert(0x1 == registers->get(0)); | ||
emulate(cpu, 2); | ||
assert(0x2 == registers->get(0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x01, 0x61, 0x06, 0x80, 0x11 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0x7 == registers->get(0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x0C, 0x61, 0x06, 0x80, 0x12 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0x4 == registers->get(0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x09, 0x61, 0x05, 0x80, 0x13 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(12 == registers->get(0)); | ||
} |
17 changes: 17 additions & 0 deletions
17
cplusplus/tests/source/should_test_opcode_0x8xy4_no_carry_set_register_f_to_zero.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x01, 0x61, 0x01, 0x80, 0x14 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0x2 == registers->get(0)); | ||
assert(0 == registers->get(0xF)); | ||
} |
17 changes: 17 additions & 0 deletions
17
cplusplus/tests/source/should_test_opcode_0x8xy4_with_carry_set_register_f_to_one.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0xF1, 0x61, 0xF1, 0x80, 0x14}; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(226 == registers->get(0)); | ||
assert(1 == registers->get(0xF)); | ||
} |
17 changes: 17 additions & 0 deletions
17
cplusplus/tests/source/should_test_opcode_0x8xy5_if_sum_is_negative_value.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x02, 0x61, 0x03, 0x80, 0x15 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0xFF == registers->get(0)); | ||
assert(0 == registers->get(0xF)); | ||
} |
17 changes: 17 additions & 0 deletions
17
cplusplus/tests/source/should_test_opcode_0x8xy5_if_sum_is_non_negative_value.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x03, 0x61, 0x02, 0x80, 0x15 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(1 == registers->get(0)); | ||
assert(1 == registers->get(0xF)); | ||
} |
17 changes: 17 additions & 0 deletions
17
cplusplus/tests/source/should_test_opcode_0x8xy6_if_sum_has_least_significant_bit_of_one.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x03, 0x80, 0x16 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0x1 == registers->get(0)); | ||
assert(0x1 == registers->get(0xF)); | ||
} |
17 changes: 17 additions & 0 deletions
17
...splus/tests/source/should_test_opcode_0x8xy6_if_sum_has_least_significant_bit_of_zero.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x02, 0x80, 0x16 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0x1 == registers->get(0)); | ||
assert(0x0 == registers->get(0xF)); | ||
} |
17 changes: 17 additions & 0 deletions
17
cplusplus/tests/source/should_test_opcode_0x8xy7_if_there_is_borrow_set_vf_to_zero.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x02, 0x61, 0x03, 0x80, 0x17 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0x1 == registers->get(0)); | ||
assert(0x1 == registers->get(0xF)); | ||
} |
17 changes: 17 additions & 0 deletions
17
cplusplus/tests/source/should_test_opcode_0x8xy7_if_there_is_no_borrow_set_vf_to_one.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0x02, 0x61, 0x03, 0x80, 0x17 }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0x1 == registers->get(0)); | ||
assert(0x1 == registers->get(0xF)); | ||
} |
17 changes: 17 additions & 0 deletions
17
cplusplus/tests/source/should_test_opcode_0x8xye_mbs_should_be_zero.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "tests_common.h" | ||
|
||
int main() { | ||
// arrange | ||
auto memory = std::make_shared<Chip8::Memory>(); | ||
auto registers = std::make_shared<Chip8::Registers>(); | ||
auto cpu = std::make_shared<Chip8::CPU>(memory, registers); | ||
uint8_t data[] = { 0x60, 0xFF, 0x80, 0x0E }; | ||
memory->load(512, data, sizeof(data)); | ||
|
||
// act | ||
emulate(cpu, sizeof(data)); | ||
|
||
// assert | ||
assert(0xFE == registers->get(0)); | ||
assert(0x1 == registers->get(0xF)); | ||
} |
Oops, something went wrong.