From: Neil T. <nt...@us...> - 2006-08-19 12:06:52
|
Update of /cvsroot/pgsqlformac/pgCocoaDB/UnitTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10405/UnitTest Modified Files: pgCocoaDBSchemaTest.m Log Message: Add display of index column names. Index: pgCocoaDBSchemaTest.m =================================================================== RCS file: /cvsroot/pgsqlformac/pgCocoaDB/UnitTest/pgCocoaDBSchemaTest.m,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pgCocoaDBSchemaTest.m 13 Aug 2006 23:50:24 -0000 1.13 --- pgCocoaDBSchemaTest.m 19 Aug 2006 12:06:48 -0000 1.14 *************** *** 21,25 **** NSString* const PGCocoaTestPassword = @""; NSString* const PGCocoaTestHost = @"localhost"; ! NSString* const PGCocoaTestPort = @"5432"; // Uncomment the following line to automatically drop and recreate the test database. --- 21,25 ---- NSString* const PGCocoaTestPassword = @""; NSString* const PGCocoaTestHost = @"localhost"; ! NSString* const PGCocoaTestPort = @"5433"; // Uncomment the following line to automatically drop and recreate the test database. *************** *** 993,996 **** --- 993,1032 ---- } + -(void)testIndexColumns + { + RecordSet * results; + unsigned int i; + NSNumber *aFoundCount = [NSNumber numberWithInt:0]; + NSArray * columnCount = [NSArray arrayWithObjects: aFoundCount, nil]; + NSArray * columnNames = [NSArray arrayWithObjects: @"address_id", nil]; + NSMutableDictionary * columnLookup = [[NSMutableDictionary alloc] initWithObjects:columnCount forKeys:columnNames]; + NSString* aColumnName; + NSNumber *newValue; + + results = [testSchema getIndexColumnNamesFromSchema:PGCocoaTestSchema fromTableName:@"address" fromIndexName:@"address_pkey"]; + STAssertTrue([results count] == 1, @"Too many columns for index address_pkey on table address."); + for (i = 0; i < [results count]; i++) + { + aColumnName = [[[[results itemAtIndex: i] fields] itemAtIndex:0] value]; + aFoundCount = [columnLookup objectForKey: aColumnName]; + if (aFoundCount != nil) + { + newValue = [NSNumber numberWithInt:[aFoundCount intValue]+1]; + [columnLookup setObject:newValue forKey:aColumnName]; + } + else + { + STFail(@"Found extra column name (%@) in index %@.", aColumnName, @"address_pkey"); + } + } + + NSLog(@"Checking columns in index %@:", @"address_pkey"); + NSEnumerator *enumerator = [columnLookup keyEnumerator]; + while ((aColumnName = [enumerator nextObject])) { + aFoundCount = [columnLookup objectForKey: aColumnName]; + NSLog(@" %@ count = %d.", aColumnName, [aFoundCount intValue]); + STAssertTrue([aFoundCount intValue] == 1, @"Problem finding column name (%@) in index %@.", aColumnName, @"address_pkey"); + } + } @end |