MODULE test_open ; (* m2SQLITE smoke test: open/close an in-memory database, including the open_v2 path with a NIL (default) VFS. *) FROM SYSTEM IMPORT ADDRESS; FROM SQLite IMPORT DbHandle, SQLiteOk, SQLiteOpenReadWrite, SQLiteOpenCreate, sqlite3_open, sqlite3_open_v2, sqlite3_close, sqlite3_errcode; FROM libc IMPORT printf; VAR db: DbHandle; rc: INTEGER; BEGIN db := NIL; rc := sqlite3_open(":memory:", db); printf("open rc=%d\n", rc); IF rc # SQLiteOk THEN printf("FAIL test_open: sqlite3_open rc=%d\n", rc); HALT(1) END; IF db = NIL THEN printf("FAIL test_open: NIL handle\n"); HALT(1) END; rc := sqlite3_close(db); IF rc # SQLiteOk THEN printf("FAIL test_open: close rc=%d\n", rc); HALT(1) END; db := NIL; rc := sqlite3_open_v2(":memory:", db, SQLiteOpenReadWrite + SQLiteOpenCreate, NIL); printf("open_v2 rc=%d\n", rc); IF rc # SQLiteOk THEN printf("FAIL test_open: open_v2 rc=%d\n", rc); HALT(1) END; IF sqlite3_errcode(db) # SQLiteOk THEN printf("FAIL test_open: errcode after open\n"); HALT(1) END; rc := sqlite3_close(db); IF rc # SQLiteOk THEN printf("FAIL test_open: close2 rc=%d\n", rc); HALT(1) END; printf("PASS test_open\n") END test_open.