Skip to content

Commit 86d2425

Browse files
authored
[ffi] test zero termination of Utf8 string (dart-archive/ffi#147)
1 parent d7082a4 commit 86d2425

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkgs/ffi/test/utf8_test.dart

+8
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,12 @@ void main() {
116116
}
117117
fail('Expected an error.');
118118
});
119+
120+
test('zero terminated', () {
121+
final string = 'Hello';
122+
final utf8Pointer = string.toNativeUtf8();
123+
final charPointer = utf8Pointer.cast<Char>();
124+
expect(charPointer[utf8Pointer.length], 0);
125+
calloc.free(utf8Pointer);
126+
});
119127
}

0 commit comments

Comments
 (0)