Add initial tests

FossilOrigin-Name: bda6d49813371eee28256e1f609091ca4ff664bb1ddeefcf308998b844a3eb14
This commit is contained in:
Jonathan Schleifer 2020-10-01 23:20:24 +00:00
parent 68eee4790f
commit f7aa1209f7
3 changed files with 34 additions and 1 deletions

View file

@ -41,5 +41,5 @@ run:
${PROG_NOINST}: ${LIBOBJSQLITE3_DEP}
CPPFLAGS += -I../src
LIBS := ${OBJFW_LIBS} ${LIBS}
LIBS := -L../src -lobjsqlite3 ${OBJFW_LIBS} ${LIBS}
LD = ${OBJC}

View file

@ -33,6 +33,37 @@ OF_APPLICATION_DELEGATE(Tests)
@implementation Tests
- (void)applicationDidFinishLaunching
{
OFFileManager *fileManager = [OFFileManager defaultManager];
SL3Connection *conn;
SL3PreparedStatement *stmt;
if ([fileManager fileExistsAtPath: @"tests.db"])
[fileManager removeItemAtPath: @"tests.db"];
conn = [SL3Connection connectionWithPath: @"tests.db"];
[conn executeStatement: @"CREATE TABLE test (a INT, b TEXT, c BLOB)"];
stmt = [conn prepareStatement:
@"INSERT INTO test (a, b, c) VALUES ($a, $b, $c)"];
[stmt bindWithArray: [OFArray arrayWithObjects:
[OFNumber numberWithInt: 5],
@"String",
[OFData dataWithItems: "abc"
count: 3],
nil]];
[stmt step];
stmt = [conn prepareStatement:
@"INSERT INTO test (a, b, c) VALUES ($a, $b, $c)"];
[stmt bindWithDictionary: [OFDictionary dictionaryWithKeysAndObjects:
@"$a", [OFNumber numberWithInt: 7],
@"$b", @"Test",
@"$c", [OFData dataWithItems: "xyz"
count: 3],
nil]];
[stmt step];
[OFApplication terminate];
}
@end