Skip to content

Commit

Permalink
Fix rot13 test on big-endian platforms (#2386)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoniEx2 authored Feb 8, 2024
1 parent ef85155 commit 1263c6a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test-interp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,13 @@ TEST_F(InterpTest, Rot13) {

EXPECT_LT(ptr + size, memory->ByteSize());

#if WABT_BIG_ENDIAN
std::copy(string_data.rbegin(), string_data.rbegin() + size,
memory->UnsafeData() + memory->ByteSize() - ptr - size);
#else
std::copy(string_data.begin(), string_data.begin() + size,
memory->UnsafeData() + ptr);
#endif

results[0].Set(size);
return Result::Ok;
Expand All @@ -527,8 +532,14 @@ TEST_F(InterpTest, Rot13) {
EXPECT_LT(ptr + size, memory->ByteSize());

string_data.resize(size);
#if WABT_BIG_ENDIAN
std::copy(memory->UnsafeData() + memory->ByteSize() - ptr - size,
memory->UnsafeData() + memory->ByteSize() - ptr,
string_data.rbegin());
#else
std::copy(memory->UnsafeData() + ptr, memory->UnsafeData() + ptr + size,
string_data.begin());
#endif

return Result::Ok;
};
Expand Down

0 comments on commit 1263c6a

Please sign in to comment.