[fdo-commits] r170 - trunk/Providers/SHP/Src/UnitTest
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Mon Jan 29 14:57:14 EST 2007
Author: danstoica
Date: 2007-01-29 14:57:14 -0500 (Mon, 29 Jan 2007)
New Revision: 170
Modified:
trunk/Providers/SHP/Src/UnitTest/ExtendedSelectTests.cpp
trunk/Providers/SHP/Src/UnitTest/ExtendedSelectTests.h
trunk/Providers/SHP/Src/UnitTest/FilterTests.cpp
Log:
Merged branch 3.2.x to Trunk
Modified: trunk/Providers/SHP/Src/UnitTest/ExtendedSelectTests.cpp
===================================================================
--- trunk/Providers/SHP/Src/UnitTest/ExtendedSelectTests.cpp 2007-01-29 18:46:29 UTC (rev 169)
+++ trunk/Providers/SHP/Src/UnitTest/ExtendedSelectTests.cpp 2007-01-29 19:57:14 UTC (rev 170)
@@ -165,33 +165,14 @@
const wchar_t *name = reader->GetString(L"NAME");
CPPUNIT_ASSERT_MESSAGE("Unexpected value", wcscmp(name,expected[count-1])==0 );
printf("%ls \t %d\n", name, reader->GetInt32( L"FeatId" ) );
- }
+ }
}while( reader->ReadNext() );
finish = clock ();
printf ("Read forward(%d) time: %2.3f seconds\n\n\n",count, (double)(finish - start) / CLOCKS_PER_SEC);
CPPUNIT_ASSERT_MESSAGE("Unexpected number of records", count==419 );
- // IndexOf() on an ordered collection.
- if( reader->ReadFirst() )
- do
- {
- if( count++ < 10 )
- {
- FdoPtr<FdoPropertyValueCollection> key1 = FdoPropertyValueCollection::Create();
- FdoPtr<FdoInt32Value> featid1 = FdoInt32Value::Create(count);
- key1->Add( FdoPropertyValue::Create(L"FeatId", featid1) );
-
- FdoInt32 index = reader->IndexOf(key1);
- reader->ReadAtIndex(index); // this increments
- const wchar_t *name = reader->GetString(L"NAME");
- int featid = reader->GetInt32( L"FeatId");
- CPPUNIT_ASSERT_MESSAGE("Unexpected value", featid1 = featid );
- }
- }while( count < 10 );
-
-
// Iterate in the backward direction from last to first
wchar_t* expected2[] = {L"Zimbabwe",L"Zambia",L"Zaire",L"Western Sahara",L"Virgin Islands",L"Vietnam",L"Venezuela",L"Venezuela",L"Uzbekistan",L"Uruguay"};
count = 0;
@@ -242,144 +223,3 @@
}
}
-#ifdef _WIN32
-#define LOCATION2 L"..\\..\\TestData\\Bike_Network"
-#else
-#define LOCATION2 L"../../TestData/Bike_Network"
-#endif
-
-#define CLASS_NAME2 L"dpt_bike_network"
-
-
-void ExtendedSelectTests::WithNullValues()
-{
- int count = 0;
-
- try
- {
- FdoPtr<FdoIConnection> connection = ShpTests::GetConnection ();
-
- connection->SetConnectionString (L"DefaultFileLocation=" LOCATION2);
- CPPUNIT_ASSERT_MESSAGE ("connection state not open", FdoConnectionState_Open == connection->Open ());
-
- FdoPtr<ShpIExtendedSelect> select = (ShpIExtendedSelect*)connection->CreateCommand(ShpCommandType_ExtendedSelect);
- select->SetFeatureClassName (CLASS_NAME2);
-
- // List properties
-
- // Use ordering properties
- FdoPtr<FdoIdentifierCollection> orders = select->GetOrdering();
- orders->Add( FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"STREETNAME")));
- select->SetOrderingOption(L"STREETNAME", FdoOrderingOption_Ascending);
-
- // execute
- FdoPtr<ShpIScrollableFeatureReader> reader = select->ExecuteScrollable();
-
- // Iterate in the forward direction from first to last
- wchar_t* expected[] = {L"Afghanistan",L"Albania",L"Algeria",L"Andorra",L"Angola",L"Angola",L"Antigua and Barbuda",L"Argentina",L"Argentina",L"Argentina"};
- count = 0;
- int count_null = 0;
-
- if( reader->ReadFirst() )
- do
- {
- count++;
-
- if ( reader->IsNull(L"STREETNAME") )
- {
- count_null++;
- printf("null at %d\n", count);
- continue;
- }
- const wchar_t *name = reader->GetString(L"STREETNAME");
- //CPPUNIT_ASSERT_MESSAGE("Unexpected value", wcscmp(name,expected[count-1])==0 );
- //printf("%ls \t %d\n", name, reader->GetInt32( L"FeatId" ) );
-
- }while( reader->ReadNext() );
- printf("count %ld (null %ld)\n", count, count_null);
- }
- catch (FdoException *ex )
- {
- printf("FDO error: %ls\n", ex->GetExceptionMessage());
- return;
- }
-}
-
-#ifdef _WIN32
-#define LOCATION3 L"..\\..\\TestData\\Realtor_Neighborhoods"
-#else
-#define LOCATION3 L"../../TestData/Realtor_Neighborhoods"
-#endif
-
-#define CLASS_NAME3 L"realtor_neighborhoods"
-#define PROP_NAME3 L"SFAR_DISTR"
-
-void ExtendedSelectTests::WithFilter()
-{
- int count = 0;
-
- try
- {
- FdoPtr<FdoIConnection> connection = ShpTests::GetConnection ();
-
- connection->SetConnectionString (L"DefaultFileLocation=" LOCATION3);
- CPPUNIT_ASSERT_MESSAGE ("connection state not open", FdoConnectionState_Open == connection->Open ());
-
- // do DESCRIBE
- FdoPtr<FdoIDescribeSchema> descSchema = (FdoIDescribeSchema*)connection->CreateCommand(FdoCommandType_DescribeSchema);
- FdoPtr<FdoFeatureSchemaCollection> schemas = descSchema->Execute();
- FdoPtr<FdoFeatureSchema> schema = schemas->GetItem(L"Default");
- FdoPtr<FdoClassCollection> classes = schema->GetClasses();
- FdoPtr<FdoClassDefinition> classDef = classes->GetItem(CLASS_NAME3);
- FdoPtr<FdoPropertyDefinitionCollection> props = classDef->GetProperties();
-
- for (int i=0; i<props->GetCount(); i++)
- {
- FdoPtr<FdoPropertyDefinition> prop = props->GetItem(i);
- printf("name: %ls\n", prop->GetName());
- }
-
- // Do SELECT
- FdoPtr<ShpIExtendedSelect> select = (ShpIExtendedSelect*)connection->CreateCommand(ShpCommandType_ExtendedSelect);
- select->SetFeatureClassName (CLASS_NAME3);
-
- // Create a filter
- select->SetFilter (FdoPtr<FdoFilter>(FdoFilter::Parse (L"SFAR_DISTR = 'District 5 - Central'")));
-
- // Use ordering properties
- FdoPtr<FdoIdentifierCollection> orders = select->GetOrdering();
- //orders->Add( FdoPtr<FdoIdentifier>(FdoIdentifier::Create(PROP_NAME3)));
- //select->SetOrderingOption(PROP_NAME3, FdoOrderingOption_Ascending);
-
- // execute
- FdoPtr<ShpIScrollableFeatureReader> reader = select->ExecuteScrollable();
-
- // Iterate in the forward direction from first to last
- // wchar_t* expected[] = {L"Afghanistan",L"Albania",L"Algeria",L"Andorra",L"Angola",L"Angola",L"Antigua and Barbuda",L"Argentina",L"Argentina",L"Argentina"};
- count = 0;
- int count_null = 0;
-
- if( reader->ReadFirst() )
- do
- {
- count++;
-
- if ( reader->IsNull(PROP_NAME3) )
- {
- count_null++;
- printf("null at %d\n", count);
- continue;
- }
- const wchar_t *name = reader->GetString(PROP_NAME3);
- //CPPUNIT_ASSERT_MESSAGE("Unexpected value", wcscmp(name,expected[count-1])==0 );
- printf("%ld. %ls \n", reader->GetInt32( L"FeatId" ), (FdoString*) name );
-
- }while( reader->ReadNext() );
- printf("count %ld (null %ld)\n", count, count_null);
- }
- catch (FdoException *ex )
- {
- printf("FDO error: %ls\n", ex->GetExceptionMessage());
- return;
- }
-}
Modified: trunk/Providers/SHP/Src/UnitTest/ExtendedSelectTests.h
===================================================================
--- trunk/Providers/SHP/Src/UnitTest/ExtendedSelectTests.h 2007-01-29 18:46:29 UTC (rev 169)
+++ trunk/Providers/SHP/Src/UnitTest/ExtendedSelectTests.h 2007-01-29 19:57:14 UTC (rev 170)
@@ -13,8 +13,6 @@
{
CPPUNIT_TEST_SUITE( ExtendedSelectTests );
CPPUNIT_TEST( WorldTest );
- CPPUNIT_TEST( WithNullValues );
- CPPUNIT_TEST( WithFilter );
CPPUNIT_TEST_SUITE_END();
public:
@@ -24,9 +22,6 @@
protected:
void WorldTest();
- void WithNullValues();
- void WithFilter();
-
};
Modified: trunk/Providers/SHP/Src/UnitTest/FilterTests.cpp
===================================================================
--- trunk/Providers/SHP/Src/UnitTest/FilterTests.cpp 2007-01-29 18:46:29 UTC (rev 169)
+++ trunk/Providers/SHP/Src/UnitTest/FilterTests.cpp 2007-01-29 19:57:14 UTC (rev 170)
@@ -603,6 +603,11 @@
long expected[100];
+ query = L"FeatId = 10 - 20";
+ count = featid_roads_query( query, 1, 0, NULL );
+
+ // Write more binary expressions...
+
query = L"FeatId = 41";
expected[0] = 41;
count = featid_roads_query( query, 1, 1, expected );
More information about the fdo-commits
mailing list