void SuperMapSelectTest::select_sdb_boolean() { CPPUNIT_ASSERT_MESSAGE("FDO连接未打开!", m_connection != NULL); CPPUNIT_ASSERT_MESSAGE("FDO连接引用次数不为1!", m_connection->GetRefCount() == 1); FdoPtr<FdoISelect> Select; Select = (FdoISelect *)m_connection->CreateCommand(FdoCommandType_Select); if(Select) { Select->SetFeatureClassName(L"面"); FdoString *strFilter = L"TestBoolen = true"; Select->SetFilter( strFilter ); FdoPtr<FdoIFeatureReader> ret; try { ret = Select->Execute(); } catch (FdoException* ex) { FdoException* nex = ex; while (nex) { AfxMessageBox(ex->GetExceptionMessage()); nex = nex->GetCause(); } ex->Release(); } catch(...) { CPPUNIT_FAIL("unresolved exception"); } CPPUNIT_ASSERT_MESSAGE("返回的要素集合为空!", ret != NULL); int count = 0; int SmID; int UserID; bool TestBool = false; FdoPtr<FdoByteArray> geometry; try { while (ret->ReadNext ()) { count++; if(!ret->IsNull(L"SmID")) { SmID = ret->GetInt32 (L"SmID"); } if(!ret->IsNull(L"SmUserID")) { UserID = ret->GetInt32 (L"SmUserID"); } if(!ret->IsNull(L"TestBoolen")) { TestBool = ret->GetBoolean (L"TestBoolen"); } if(!ret->IsNull(L"Geometry")) { geometry = ret->GetGeometry (L"Geometry"); } CPPUNIT_ASSERT_MESSAGE ("几何对象类型不正确", FdoGeometryType_Polygon == *(int*)geometry->GetData()); } CPPUNIT_ASSERT_EQUAL(true, TestBool); CPPUNIT_ASSERT_MESSAGE ("未查出面数据集中的要素", 0 != count); } catch (FdoException* ex) { FdoException* nex = ex; while (nex) { AfxMessageBox(ex->GetExceptionMessage()); nex = nex->GetCause(); } ex->Release(); } } }
void SuperMapSelectTest::select_region() { CPPUNIT_ASSERT_MESSAGE("FDO连接未打开!", m_connection != NULL); CPPUNIT_ASSERT_MESSAGE("FDO连接引用次数不为1!", m_connection->GetRefCount() == 1); FdoPtr<FdoISelect> Select; Select = (FdoISelect *)m_connection->CreateCommand(FdoCommandType_Select); Select->SetFeatureClassName(L"面"); FdoPtr<FdoIFeatureReader> ret; try { ret = Select->Execute(); } catch (FdoException* ex) { FdoException* nex = ex; while (nex) { AfxMessageBox(ex->GetExceptionMessage()); nex = nex->GetCause(); } ex->Release(); } catch(...) { CPPUNIT_FAIL("unresolved exception"); } CPPUNIT_ASSERT_MESSAGE("返回的要素集合为空!", ret != NULL); int count = 0; int SmID; int UserID; double SmArea; double SmPerimeter; bool TestBoolen; short TestShort; float TestFloat; FdoString *str; FdoDateTime date; int length; FdoPtr<FdoByteArray> geometry; try { while (ret->ReadNext ()) { count++; if(!ret->IsNull(L"SmID")) { SmID = ret->GetInt32 (L"SmID"); } if(!ret->IsNull(L"SmUserID")) { UserID = ret->GetInt32 (L"SmUserID"); } if(!ret->IsNull(L"SmArea")) { SmArea = ret->GetDouble (L"SmArea"); } if(!ret->IsNull(L"SmPerimeter")) { SmPerimeter = ret->GetDouble (L"SmPerimeter"); } if(!ret->IsNull(L"TestBoolen")) { TestBoolen = ret->GetBoolean (L"TestBoolen"); } if(!ret->IsNull(L"TestShort")) { TestShort = ret->GetInt16(L"TestShort"); } if(!ret->IsNull(L"TestFloat")) { TestFloat = ret->GetSingle(L"TestFloat"); } if(!ret->IsNull(L"TestString")) { str = ret->GetString(L"TestString"); } if(!ret->IsNull(L"TestDate")) { date = ret->GetDateTime(L"TestDate"); } if(!ret->IsNull(L"长度")) { length = ret->GetInt32(L"长度"); } if(!ret->IsNull(L"Geometry")) { geometry = ret->GetGeometry (L"Geometry"); } CPPUNIT_ASSERT_MESSAGE ("几何对象类型不正确", FdoGeometryType_Polygon == *(int*)geometry->GetData()); } CPPUNIT_ASSERT_MESSAGE ("未查出面数据集中的要素", 0 != count); } catch (FdoException* ex) { FdoException* nex = ex; while (nex) { AfxMessageBox(ex->GetExceptionMessage()); nex = nex->GetCause(); } ex->Release(); } catch(...) { CPPUNIT_FAIL("unresolved exception"); } }