Skip to content

Commit

Permalink
add another test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Nov 22, 2024
1 parent 34b990b commit b26d783
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/rcheevos/test_runtime_progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,63 @@ static void test_memref_indirect()
rc_runtime_destroy(&runtime);
}

static void test_memref_indirect_delta()
{
uint8_t ram[] = { 1, 2, 3, 4, 5 };
uint8_t buffer1[512];
uint8_t buffer2[512];
memory_t memory;
rc_runtime_t runtime;

memory.ram = ram;
memory.size = sizeof(ram);

rc_runtime_init(&runtime);

/* byte(byte(2) + 1) == 5 - third condition just prevents the achievement from triggering*/
assert_activate_achievement(&runtime, 1, "I:0xH0002_d0xH0001=3_0xH0004=99");
assert_do_frame(&runtime, &memory); /* $2 = 3, $(3+1) = 5, delta = 0 */
ram[1] = 3;
ram[2] = 0;
assert_do_frame(&runtime, &memory); /* $2 = 0, $(0+1) = 3, delta = 5 */
assert_do_frame(&runtime, &memory); /* $2 = 0, $(0+1) = 3, delta = 3 */

assert_hitcount(&runtime, 1, 0, 0, 0);
assert_hitcount(&runtime, 1, 0, 1, 1);
assert_cond_memref(&runtime, 1, 0, 0, 0, 3, 0);
assert_cond_memref(&runtime, 1, 0, 1, 3, 5, 0);

assert_serialize(&runtime, buffer1, sizeof(buffer1));

assert_do_frame(&runtime, &memory); /* $2 = 0, $(0+1) = 3, delta = 3 */
ram[1] = 6;
ram[2] = 1;
assert_do_frame(&runtime, &memory); /* $2 = 1, $(1+1) = 1, delta = 3 */
assert_do_frame(&runtime, &memory); /* $2 = 1, $(1+1) = 1, delta = 1 */
assert_hitcount(&runtime, 1, 0, 0, 0);
assert_hitcount(&runtime, 1, 0, 1, 3);
assert_cond_memref(&runtime, 1, 0, 0, 1, 0, 0);
assert_cond_memref(&runtime, 1, 0, 1, 1, 3, 0);

assert_serialize(&runtime, buffer2, sizeof(buffer2));

reset_runtime(&runtime);
assert_deserialize(&runtime, buffer1);
assert_hitcount(&runtime, 1, 0, 0, 0);
assert_hitcount(&runtime, 1, 0, 1, 1);
assert_cond_memref(&runtime, 1, 0, 0, 0, 3, 0);
assert_cond_memref(&runtime, 1, 0, 1, 3, 5, 0);

reset_runtime(&runtime);
assert_deserialize(&runtime, buffer2);
assert_hitcount(&runtime, 1, 0, 0, 0);
assert_hitcount(&runtime, 1, 0, 1, 3);
assert_cond_memref(&runtime, 1, 0, 0, 1, 0, 0);
assert_cond_memref(&runtime, 1, 0, 1, 1, 3, 0);

rc_runtime_destroy(&runtime);
}

static void test_memref_double_indirect()
{
uint8_t ram[] = { 1, 2, 3, 4, 5 };
Expand Down Expand Up @@ -1742,6 +1799,7 @@ void test_runtime_progress(void) {
TEST(test_memref_shared_address);
TEST(test_memref_addsource);
TEST(test_memref_indirect);
TEST(test_memref_indirect_delta);
TEST(test_memref_double_indirect);

TEST(test_multiple_achievements);
Expand Down

0 comments on commit b26d783

Please sign in to comment.