git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@40494 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2017-04-27 09:12:22 +00:00
parent 823f329413
commit db4f1f32cb

View file

@ -73,7 +73,7 @@ main()
name: @"test" name: @"test"
max: 2 max: 2
min: 1] autorelease]; min: 1] autorelease];
#if 1 #if 0
{ {
NSAutoreleasePool *p; NSAutoreleasePool *p;
NSAutoreleasePool *q; NSAutoreleasePool *q;
@ -268,6 +268,7 @@ main()
else else
{ {
NSString *oddChars; NSString *oddChars;
NSString *oddNoNul;
NSString *nonLatin; NSString *nonLatin;
id e1, e2, e3, e4, e5; id e1, e2, e3, e4, e5;
id d; id d;
@ -277,7 +278,8 @@ main()
id r0; id r0;
id r1; id r1;
oddChars = @"'a\\b'c\r\nd'\\ed\\"; oddChars = @"'a\\b'c\0\r\nd'\\ed\\";
oddNoNul = @"'a\\b'c\r\nd'\\ed\\";
nonLatin = [[NSString stringWithCString: "\"\\U2A11\""] propertyList]; nonLatin = [[NSString stringWithCString: "\"\\U2A11\""] propertyList];
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
@ -310,7 +312,7 @@ main()
@")", @")",
nil]; nil];
if (1 != [db execute: @"insert into xxx (id, k, char1, boolval, intval," if (1 != [db execute: @"INSERT into xxx (id, k, char1, boolval, intval,"
@" when1, when2, b, extra1, extra2, extra3, extra4, extra5) " @" when1, when2, b, extra1, extra2, extra3, extra4, extra5) "
@"values (1," @"values (1,"
@"'{hello', " @"'{hello', "
@ -345,11 +347,11 @@ main()
NSLog(@"Insert failed to return row count"); NSLog(@"Insert failed to return row count");
} }
[db setDebugging: 9]; [db setDebugging: 0];
[db query: @"select * from xxx", nil]; [db query: @"select * from xxx", nil];
[db setDebugging: 0]; [db setDebugging: 0];
[db execute: @"insert into xxx " [db execute: @"INSERT into xxx "
@"(id, k, char1, boolval, intval, when1, when2, b) " @"(id, k, char1, boolval, intval, when1, when2, b) "
@"values (2," @"values (2,"
@"'hello', " @"'hello', "
@ -361,7 +363,7 @@ main()
[NSData dataWithBytes: "" length: 0], [NSData dataWithBytes: "" length: 0],
@")", @")",
nil]; nil];
[db execute: @"insert into xxx " [db execute: @"INSERT into xxx "
@"(id, k, char1, boolval, intval, when1, when2, b) " @"(id, k, char1, boolval, intval, when1, when2, b) "
@"values (3,", @"values (3,",
[db quote: oddChars], [db quote: oddChars],
@ -383,6 +385,8 @@ main()
records = [db cache: 1 query: @"select * from xxx order by id", nil]; records = [db cache: 1 query: @"select * from xxx order by id", nil];
NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed"); NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed");
db = [[[SQLClient alloc] initWithConfiguration: nil
name: @"test"] autorelease];
[db addObserver: l [db addObserver: l
selector: @selector(notified:) selector: @selector(notified:)
name: @"foo"]; name: @"foo"];
@ -416,10 +420,15 @@ main()
NSLog(@"Retrieved non-latin does not match saved string"); NSLog(@"Retrieved non-latin does not match saved string");
} }
id o = [[record objectForKey: @"k"] stringByTrimmingSpaces]; id o = [[record objectForKey: @"k"] stringByTrimmingSpaces];
if ([o isEqual: oddChars] == NO) if ([o isEqual: oddNoNul] == NO)
{ {
NSLog(@"Retrieved odd chars (%@) does not match saved string (%@)", o, oddChars); NSLog(@"Retrieved odd chars (%@) does not match oddNoNul (%@)",
o, oddNoNul);
} }
else
{
NSLog(@"Embedded nul correctly removed");
}
record = [records objectAtIndex: 0]; record = [records objectAtIndex: 0];
o = [record objectForKey: @"extra1"]; o = [record objectForKey: @"extra1"];
if ([o isEqual: e1] == NO) if ([o isEqual: e1] == NO)
@ -477,7 +486,7 @@ main()
@"when1 timestamp with time zone, " @"when1 timestamp with time zone, "
@"when2 timestamp)", @"when2 timestamp)",
nil]; nil];
[db execute: @"insert into xxx (id, when0, when1, when2) " [db execute: @"INSERT into xxx (id, when0, when1, when2) "
@"values (99,", @"values (99,",
d, @", ", d, @", ",
[NSDate distantPast], @", ", [NSDate distantPast], @", ",