2024-12-21 10:04:04 +08:00
|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
|
#include "multitable_id_duplicate_test.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
multitable_id_duplicate_test::multitable_id_duplicate_test(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
multitable_id_duplicate_test::~multitable_id_duplicate_test(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><> <20><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ/<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
void multitable_id_duplicate_test::SetUp( void )
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void multitable_id_duplicate_test::TearDown( void )
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><EFBFBD>Ʈ <20><><EFBFBD>̽<EFBFBD> <20><>ü<EFBFBD><C3BC> <20>ش<EFBFBD><D8B4>ϴ<EFBFBD> <20>ʱ<EFBFBD>ȭ/<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
void multitable_id_duplicate_test::SetUpTestCase( void )
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void multitable_id_duplicate_test::TearDownTestCase( void )
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F( multitable_id_duplicate_test, TABLE_ID_DUPLICATE_TEST )
|
|
|
|
|
|
{
|
|
|
|
|
|
string strTableFileName;
|
|
|
|
|
|
vector<string> vlExtFilesToVerify;
|
|
|
|
|
|
|
|
|
|
|
|
vector<std::string> tokens;
|
|
|
|
|
|
string delimiters = ";";
|
|
|
|
|
|
|
|
|
|
|
|
TokenizeA( g_strTableName, tokens, delimiters );
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string>::iterator iter = tokens.begin();
|
|
|
|
|
|
for ( ; iter != tokens.end(); ++iter)
|
|
|
|
|
|
{
|
|
|
|
|
|
vlExtFilesToVerify.push_back( *iter );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int iNumExtToVerify = (int)vlExtFilesToVerify.size();
|
|
|
|
|
|
for( int iIndex = 0; iIndex < iNumExtToVerify; ++iIndex )
|
|
|
|
|
|
{
|
|
|
|
|
|
strTableFileName = vlExtFilesToVerify.at( iIndex );
|
|
|
|
|
|
strTableFileName.append( ".dnt" );
|
|
|
|
|
|
|
|
|
|
|
|
vector<string> vlFilePathsToVerify;
|
|
|
|
|
|
string strTableFullPath;
|
|
|
|
|
|
|
|
|
|
|
|
GatherConcernedExt( strTableFileName.c_str(), vlFilePathsToVerify, strTableFullPath );
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ǯ <20>н<EFBFBD><D0BD><EFBFBD> <20>ϳ<EFBFBD><CFB3><EFBFBD> <20><><EFBFBD>ٸ<EFBFBD> <20><> <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ƴϹǷ<CFB9> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʿ䰡 <20><><EFBFBD><EFBFBD>.
|
|
|
|
|
|
if( vlFilePathsToVerify.empty() )
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
// vlFilePathsToVerify <20><> <20>ε<EFBFBD><CEB5><EFBFBD>. <20><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD> <20><>ø<EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ش<EFBFBD> <20><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>˾Ƴ<CBBE><C6B3><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|
|
|
|
|
// -1 <20≯<EFBFBD> _ <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺<EFBFBD> <20≯<EFBFBD>.
|
|
|
|
|
|
vector<string> vlFilePaths = vlFilePathsToVerify;
|
|
|
|
|
|
int iTableFilePathIndex = -1;
|
|
|
|
|
|
|
|
|
|
|
|
// ó<><C3B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5>ؼ<EFBFBD> <20><><EFBFBD>̵<EFBFBD> <20>ߺ<EFBFBD> üũ<C3BC>ϰ<EFBFBD> <20>Ŀ<EFBFBD> <20><>ø<EFBFBD>ؼ<EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20>ݺ<EFBFBD>.
|
|
|
|
|
|
DNTableFileFormat* pSox = new DNTableFileFormat;
|
|
|
|
|
|
pSox->Load( strTableFileName.c_str(), false );
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺<EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʴ´ٸ<C2B4> <20>ø<EFBFBD><C3B8><EFBFBD> <20><> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ó<><C3B3><EFBFBD>Ѵ<EFBFBD>.
|
|
|
|
|
|
if( 0 == pSox->GetFieldCount() )
|
|
|
|
|
|
{
|
|
|
|
|
|
delete pSox;
|
|
|
|
|
|
pSox = new DNTableFileFormat;
|
|
|
|
|
|
pSox->Load( vlFilePathsToVerify.back().c_str(), false );
|
|
|
|
|
|
|
|
|
|
|
|
// <20><EFBFBD><F1B1B3B4><EFBFBD><EFBFBD><EFBFBD> <20>Ǵ<EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|
|
|
|
|
vlFilePathsToVerify.pop_back();
|
|
|
|
|
|
iTableFilePathIndex = (int)vlFilePaths.size()-1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
multimap<int, int> mmapIDToTableNameIndex;
|
|
|
|
|
|
set<int> setItemIDs;
|
|
|
|
|
|
for( int i = 0; i < pSox->GetItemCount(); ++i )
|
|
|
|
|
|
{
|
|
|
|
|
|
setItemIDs.insert( pSox->GetItemID( i ) );
|
|
|
|
|
|
mmapIDToTableNameIndex.insert( make_pair( pSox->GetItemID( i ), iTableFilePathIndex ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TCHAR atcTableSeriesFileName[ MAX_PATH ] = { 0 };
|
|
|
|
|
|
TCHAR atcTableFileName[ MAX_PATH ] = { 0 };
|
|
|
|
|
|
TCHAR atcFileName[ MAX_PATH ] = { 0 };
|
|
|
|
|
|
TCHAR atcFileExt[ MAX_PATH ] = { 0 };
|
|
|
|
|
|
TCHAR atcBuf[ 256 ] = { 0 };
|
|
|
|
|
|
for( DWORD i=0; i< vlFilePathsToVerify.size(); i++ )
|
|
|
|
|
|
{
|
|
|
|
|
|
DNTableFileFormat* pAddition = new DNTableFileFormat;
|
|
|
|
|
|
|
|
|
|
|
|
pAddition->Load( vlFilePathsToVerify[ i ].c_str(), false );
|
|
|
|
|
|
|
|
|
|
|
|
if( pSox->GetFieldCount() != pAddition->GetFieldCount() )
|
|
|
|
|
|
{
|
|
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, strTableFileName.c_str(), -1, atcTableSeriesFileName, MAX_PATH );
|
|
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, vlFilePathsToVerify[ i ].c_str(), -1, atcTableFileName, MAX_PATH );
|
|
|
|
|
|
_stprintf_s( atcBuf, _T("{TableSeriesName:%s, TableFilePath:%s, Note:<3A><><EFBFBD>̺<EFBFBD> <20><><EFBFBD>̺<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٸ<EFBFBD><D9B8>ϴ<EFBFBD>.}"), atcTableSeriesFileName, atcTableFileName );
|
|
|
|
|
|
SCOPED_TRACE( atcBuf );
|
|
|
|
|
|
EXPECT_TRUE( pSox->GetFieldCount() == pAddition->GetFieldCount() );
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set<int> setAdditionItemIDs;
|
|
|
|
|
|
for( int k = 0; k < pAddition->GetItemCount(); ++k )
|
|
|
|
|
|
setAdditionItemIDs.insert( pAddition->GetItemID( k ) );
|
|
|
|
|
|
|
|
|
|
|
|
vector<int> vlIntersection;
|
|
|
|
|
|
set_intersection( setItemIDs.begin(), setItemIDs.end(),
|
|
|
|
|
|
setAdditionItemIDs.begin(), setAdditionItemIDs.end(),
|
|
|
|
|
|
back_inserter( vlIntersection ) );
|
|
|
|
|
|
|
|
|
|
|
|
for( int k = 0; k < (int)vlIntersection.size(); ++k )
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ΰ<EFBFBD>?
|
|
|
|
|
|
pair<multimap<int, int>::iterator, multimap<int, int>::iterator> iter_pair = mmapIDToTableNameIndex.equal_range( vlIntersection.at(k) );
|
|
|
|
|
|
multimap<int, int>::iterator iter = iter_pair.first;
|
|
|
|
|
|
string strExistingIDFilePath;
|
|
|
|
|
|
if( -1 < iter->second )
|
|
|
|
|
|
strExistingIDFilePath = vlFilePaths.at( iter->second );
|
|
|
|
|
|
else
|
|
|
|
|
|
strExistingIDFilePath = strTableFileName;
|
|
|
|
|
|
|
|
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, strExistingIDFilePath.c_str(), -1, atcTableSeriesFileName, MAX_PATH );
|
|
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, vlFilePathsToVerify[ i ].c_str(), -1, atcTableFileName, MAX_PATH );
|
|
|
|
|
|
//_stprintf_s( atcBuf, _T("{ExistingFilePath:%s, TableFilePath:%s, ID:%d, Note:<3A><><EFBFBD>̺<EFBFBD> <20><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD> <20>ߺ<EFBFBD><DFBA>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD>ϴ<EFBFBD>.}"), atcTableSeriesFileName,
|
|
|
|
|
|
// atcTableFileName, vlIntersection.at(k) );
|
|
|
|
|
|
|
|
|
|
|
|
_tsplitpath_s( atcTableFileName, NULL, 0, NULL, 0, atcFileName, _countof(atcFileName), atcFileExt, _countof(atcFileName) );
|
|
|
|
|
|
tstring strFileName( atcFileName );
|
|
|
|
|
|
strFileName += atcFileExt;
|
|
|
|
|
|
_stprintf_s( atcBuf, _T("{TablenName:%s, Index:%d, Note:<3A><><EFBFBD>̺<EFBFBD> <20><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD> <20>ߺ<EFBFBD><DFBA>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD>ϴ<EFBFBD>.}"), strFileName.c_str(), vlIntersection.at(k) );
|
|
|
|
|
|
SCOPED_TRACE( atcBuf );
|
|
|
|
|
|
EXPECT_TRUE( vlIntersection.empty() );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for( int k = 0; k < pAddition->GetItemCount(); ++k )
|
|
|
|
|
|
{
|
|
|
|
|
|
setItemIDs.insert( pAddition->GetItemID( k ) );
|
|
|
|
|
|
mmapIDToTableNameIndex.insert( make_pair( pAddition->GetItemID( k ), i ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
delete pAddition;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
delete pSox;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//INSTANTIATE_TEST_CASE_P( SELECTED_TABLE, multitable_id_duplicate_test, ValuesIn() );
|