From f7aa1209f7e0af76ab9884170a965c6f88fcf0be Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Thu, 1 Oct 2020 23:20:24 +0000 Subject: [PATCH] Add initial tests FossilOrigin-Name: bda6d49813371eee28256e1f609091ca4ff664bb1ddeefcf308998b844a3eb14 --- .fossil-settings/ignore-glob | 2 ++ tests/Makefile | 2 +- tests/Tests.m | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob index 6871c87..e3d9c43 100644 --- a/.fossil-settings/ignore-glob +++ b/.fossil-settings/ignore-glob @@ -18,3 +18,5 @@ config.status configure extra.mk tests/tests +tests/tests.db +tests/tests.exe diff --git a/tests/Makefile b/tests/Makefile index 0076b98..c68ed80 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -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} diff --git a/tests/Tests.m b/tests/Tests.m index 22da739..4e71719 100644 --- a/tests/Tests.m +++ b/tests/Tests.m @@ -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