Skip to content

Commit 1263c6a

Browse files
authored
Fix rot13 test on big-endian platforms (#2386)
1 parent ef85155 commit 1263c6a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test-interp.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,13 @@ TEST_F(InterpTest, Rot13) {
505505

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

508+
#if WABT_BIG_ENDIAN
509+
std::copy(string_data.rbegin(), string_data.rbegin() + size,
510+
memory->UnsafeData() + memory->ByteSize() - ptr - size);
511+
#else
508512
std::copy(string_data.begin(), string_data.begin() + size,
509513
memory->UnsafeData() + ptr);
514+
#endif
510515

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

529534
string_data.resize(size);
535+
#if WABT_BIG_ENDIAN
536+
std::copy(memory->UnsafeData() + memory->ByteSize() - ptr - size,
537+
memory->UnsafeData() + memory->ByteSize() - ptr,
538+
string_data.rbegin());
539+
#else
530540
std::copy(memory->UnsafeData() + ptr, memory->UnsafeData() + ptr + size,
531541
string_data.begin());
542+
#endif
532543

533544
return Result::Ok;
534545
};

0 commit comments

Comments
 (0)