Skip to content

Commit b0607f7

Browse files
committed
tests: Fix failing CString test on armv7 devices
Memory for the temporary buffer created during marshalling to `functionWithUCharPtr` was accidentally being left intact on Intel and arm64 architectures, but on `armv7` it is overwritten, leading to CString test failing to check the actual result.
1 parent e37bbc7 commit b0607f7

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tests/TestRunner/app/Marshalling/ReferenceTests.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,17 @@ describe(module.id, function () {
153153

154154
it("CString should be passed as its UTF8 encoding and returned as a reference to unsigned characters", function () {
155155
const str = "test АБВГ";
156-
const result = functionWithUCharPtr(str);
156+
const ptr = interop.alloc(str.length*2 + 1); // alloc 2 bytes per character (although some of them are 1-byte chars)
157+
strcpy(ptr, str);
158+
159+
const result = functionWithUCharPtr(ptr);
157160

158161
expect(TNSGetOutput()).toBe(str);
159162

160163
const strUtf8 = utf8.encode(str);
161164
for (i in strUtf8) {
162-
const actual = strUtf8.charCodeAt(i);
163-
const expected = result[i];
165+
const actual = result[i];
166+
const expected = strUtf8.charCodeAt(i);
164167
expect(actual).toBe(expected, `Char code difference at index ${i} ("${actual}" vs "${expected}")`);
165168
}
166169
});

0 commit comments

Comments
 (0)