[Feature] Checks for Nullable strings (#6050)

* Allows null strings in createString method c#

* Adds nullable strings to JS and swift

* Changes js checks

* Fixes typo
This commit is contained in:
mustiikhalil
2020-07-27 19:57:50 +03:00
committed by GitHub
parent 5d052f4e55
commit f1025b2847
6 changed files with 70 additions and 12 deletions

View File

@@ -50,7 +50,9 @@ function main() {
test64bit();
testUnicode();
fuzzTest1();
testNullStrings();
testSharedStrings();
console.log('FlatBuffers test: completed successfully');
}
@@ -437,4 +439,19 @@ function fuzzTest1() {
}
}
function testSharedStrings() {
var shared_string = "Hello world";
var builder = new flatbuffers.Builder();
let mainOffset = builder.createSharedString(shared_string);
assert.strictEqual(builder.createSharedString(shared_string), mainOffset);
}
function testNullStrings() {
var builder = new flatbuffers.Builder();
assert.strictEqual(builder.createString(null), 0);
assert.strictEqual(builder.createSharedString(null), 0);
assert.strictEqual(builder.createString(undefined), 0);
assert.strictEqual(builder.createSharedString(undefined), 0);
}
main();