Add a proper build system
FossilOrigin-Name: 8679c61b2c82da9daa316ed5eb90ba1b69e608127afa318cbdbff56b53d65a74
This commit is contained in:
parent
71342537cf
commit
35212e3305
28 changed files with 5118 additions and 76 deletions
54
tests/tests.m
Normal file
54
tests/tests.m
Normal file
|
@ -0,0 +1,54 @@
|
|||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
#import "PGConnection.h"
|
||||
#import "PGConnectionFailedException.h"
|
||||
|
||||
@interface Test: OFObject
|
||||
{
|
||||
PGConnection *connection;
|
||||
}
|
||||
@end
|
||||
|
||||
OF_APPLICATION_DELEGATE(Test)
|
||||
|
||||
@implementation Test
|
||||
- (void)applicationDidFinishLaunching
|
||||
{
|
||||
PGResult *result;
|
||||
|
||||
connection = [[PGConnection alloc] init];
|
||||
[connection setParameters:
|
||||
[OFDictionary dictionaryWithKeysAndObjects: @"user", @"js",
|
||||
@"dbname", @"js", 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: @1, @"foo", @"Hallo Welt!", nil];
|
||||
[connection executeCommand: @"INSERT INTO test (id, content, success) "
|
||||
@"VALUES ($1, $2, $3)"
|
||||
parameters: @2, @2, @YES, nil];
|
||||
[connection insertRow: @{ @"content": @"Hallo!", @"name": @"foo" }
|
||||
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"];
|
||||
of_log(@"%@", result);
|
||||
|
||||
[OFApplication terminate];
|
||||
}
|
||||
@end
|
Loading…
Add table
Add a link
Reference in a new issue