aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/tester1.c-pp.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-12-05 11:54:13 +0000
committerstephan <stephan@noemail.net>2022-12-05 11:54:13 +0000
commitcf8f0d20463adf368cedb434d6d70cd255ab185a (patch)
tree6e1f9950b61d1451c5319ef8ba6c6e6409582f27 /ext/wasm/tester1.c-pp.js
parent0adef0937451b9c93688c00e26a792915361af5d (diff)
downloadsqlite-cf8f0d20463adf368cedb434d6d70cd255ab185a.tar.gz
sqlite-cf8f0d20463adf368cedb434d6d70cd255ab185a.zip
Rename 'static-string' argument adapter to 'string:static'. Replace JS unit tests which were lost via editing a generated copy of tester1.js instead of the original tester1.c-pp.js input file.
FossilOrigin-Name: 9d81d51d5a255b42f8416da850c992a9e4c8eebc940e0702a9262cfcaa6d7b2f
Diffstat (limited to 'ext/wasm/tester1.c-pp.js')
-rw-r--r--ext/wasm/tester1.c-pp.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js
index 0aaee9769..aa5fa41d2 100644
--- a/ext/wasm/tester1.c-pp.js
+++ b/ext/wasm/tester1.c-pp.js
@@ -660,6 +660,26 @@ self.sqlite3InitModule = sqlite3InitModule;
T.assert(rc>0 && Number.isFinite(rc));
rc = w.xCallWrapped('sqlite3_wasm_enum_json','utf8');
T.assert('string'===typeof rc).assert(rc.length>300);
+
+
+ { // 'string:static' argAdapter() sanity checks...
+ let argAd = w.xWrap.argAdapter('string:static');
+ let p0 = argAd('foo'), p1 = argAd('bar');
+ T.assert(w.isPtr(p0) && w.isPtr(p1))
+ .assert(p0 !== p1)
+ .assert(p0 === argAd('foo'))
+ .assert(p1 === argAd('bar'));
+ }
+
+ // 'flexible-string' argAdapter() sanity checks...
+ w.scopedAllocCall(()=>{
+ const argAd = w.xWrap.argAdapter('flexible-string');
+ const cj = (v)=>w.cstringToJs(argAd(v));
+ T.assert('Hi' === cj('Hi'))
+ .assert('hi' === cj(['h','i']))
+ .assert('HI' === cj(new Uint8Array([72, 73])));
+ });
+
if(haveWasmCTests()){
if(!sqlite3.config.useStdAlloc){
fw = w.xWrap('sqlite3_wasm_test_str_hello', 'utf8:dealloc',['i32']);