Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -1,8 +1,10 @@ +include ../extra.mk + PROG_NOINST = tests SRCS = tests.m include ../buildsys.mk CPPFLAGS += -I../src -I../src/exceptions -LIBS += -L../src -lobjpgsql +LIBS := -L../src -lobjpgsql ${OBJFW_LIBS} ${LIBS} LD = ${OBJC} Index: tests/tests.m ================================================================== --- tests/tests.m +++ tests/tests.m @@ -1,7 +1,7 @@ /* - * Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017 + * Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018 * Jonathan Schleifer * * https://heap.zone/git/objpgsql.git * * Permission to use, copy, modify, and/or distribute this software for any @@ -24,13 +24,13 @@ #import #import "PGConnection.h" #import "PGConnectionFailedException.h" -@interface Test: OFObject +@interface Test: OFObject { - PGConnection *connection; + PGConnection *_connection; } @end OF_APPLICATION_DELEGATE(Test) @@ -39,46 +39,46 @@ { OFString *username = [[OFApplication environment] objectForKey: @"USER"]; PGResult *result; - connection = [[PGConnection alloc] init]; - [connection setParameters: + _connection = [[PGConnection alloc] init]; + [_connection setParameters: [OFDictionary dictionaryWithKeysAndObjects: @"user", username, @"dbname", username, nil]]; - [connection connect]; - - [connection executeCommand: @"DROP TABLE IF EXISTS test"]; - [connection executeCommand: @"CREATE TABLE test (" - @" id integer," - @" name varchar(255)," - @" content text," - @" success boolean" - @")"]; - [connection executeCommand: @"INSERT INTO test (id, name, content) " - @"VALUES ($1, $2, $3)" - parameters: [OFNumber numberWithInt: 1], @"foo", - @"Hallo Welt!", nil]; - [connection executeCommand: @"INSERT INTO test (id, content, success) " - @"VALUES ($1, $2, $3)" - parameters: [OFNumber numberWithInt: 2], - [OFNumber numberWithInt: 2], - [OFNumber numberWithBool: true], nil]; - [connection insertRow: [OFDictionary dictionaryWithKeysAndObjects: - @"content", @"Hallo!", @"name", @"foo", nil] - intoTable: @"test"]; - - result = [connection executeCommand: @"SELECT * FROM test"]; + [_connection connect]; + + [_connection executeCommand: @"DROP TABLE IF EXISTS test"]; + [_connection executeCommand: @"CREATE TABLE test (" + @" id integer," + @" name varchar(255)," + @" content text," + @" success boolean" + @")"]; + [_connection executeCommand: @"INSERT INTO test (id, name, content) " + @"VALUES ($1, $2, $3)" + parameters: [OFNumber numberWithInt: 1], @"foo", + @"Hallo Welt!", nil]; + [_connection executeCommand: @"INSERT INTO test (id, content, success) " + @"VALUES ($1, $2, $3)" + parameters: [OFNumber numberWithInt: 2], + [OFNumber numberWithInt: 2], + [OFNumber numberWithBool: true], nil]; + [_connection insertRow: [OFDictionary dictionaryWithKeysAndObjects: + @"content", @"Hallo!", @"name", @"foo", nil] + intoTable: @"test"]; + + result = [_connection executeCommand: @"SELECT * FROM test"]; of_log(@"%@", result); of_log(@"JSON: %@", [result JSONRepresentation]); for (id row in result) for (id col in row) of_log(@"%@", col); - result = [connection executeCommand: @"SELECT COUNT(*) FROM test"]; + result = [_connection executeCommand: @"SELECT COUNT(*) FROM test"]; of_log(@"%@", result); [OFApplication terminate]; } @end