Skip to content

Commit

Permalink
Use pointer-to-struct instead of std::array for data test
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed May 21, 2024
1 parent 7aff1aa commit 8f2e667
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ext/libriscv
16 changes: 8 additions & 8 deletions tests/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,20 @@ TEST_CASE("Verify dynamic calls with arguments", "[Basic]")
Script::set_dynamic_call("void sys_test_data (TestData*, int, TestData*)",
[&] (Script& script) {
struct TestData { int a = 0, b = 0, c = 0; float x = 0, y = 0, z = 0; };
// A dynamic span uses 2 registers, while std::array uses 1 (as it's a fixed size array)
auto [data, data2] = script.args<std::span<TestData>, std::array<TestData, 1>> ();
// A dynamic span uses 2 registers, while pointer-to-struct uses 1 (size is known at compile time)
auto [data, data2] = script.args<std::span<TestData>, TestData*> ();
REQUIRE(data[0].a == 123);
REQUIRE(data[0].b == 456);
REQUIRE(data[0].c == 789);
REQUIRE(data[0].x == 10.0f);
REQUIRE(data[0].y == 100.0f);
REQUIRE(data[0].z == 1000.0f);
REQUIRE(data2[0].a == 123);
REQUIRE(data2[0].b == 456);
REQUIRE(data2[0].c == 789);
REQUIRE(data2[0].x == 10.0f);
REQUIRE(data2[0].y == 100.0f);
REQUIRE(data2[0].z == 1000.0f);
REQUIRE(data2->a == 123);
REQUIRE(data2->b == 456);
REQUIRE(data2->c == 789);
REQUIRE(data2->x == 10.0f);
REQUIRE(data2->y == 100.0f);
REQUIRE(data2->z == 1000.0f);
data_called += 1;
});

Expand Down

0 comments on commit 8f2e667

Please sign in to comment.