Skip to content

Commit 2610ff1

Browse files
edusperoniNathanWalker
authored andcommitted
test: add test for marshalling null characters
1 parent 705346f commit 2610ff1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

TestRunner/app/tests/Marshalling/NSStringTests.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,27 @@ describe(module.id, function () {
1717
var str = NSString.alloc().initWithString('hello hello');
1818
expect(str.isKindOfClass(NSString)).toBe(true);
1919
});
20+
21+
it("Marshals NSString with null character", function() {
22+
var JSObject = NSObject.extend({
23+
'x': function () {
24+
return this._x;
25+
}, 'setX:': function (x) {
26+
this._x = x;
27+
}
28+
}, {
29+
exposedMethods: {
30+
x: { returns: NSString },
31+
'setX:': { returns: interop.types.void, params: [NSString] }
32+
}
33+
});
34+
35+
const data = 'null coming up: ' + String.fromCharCode(0) + ' and extra';
36+
37+
var instance = JSObject.alloc().init();
38+
instance.setValueForKey(data, 'x');
39+
expect(instance.valueForKey('x')).toBe(data);
40+
});
2041

2142
it("String", function () {
2243
var str = NSString.string();

0 commit comments

Comments
 (0)