bool GenderProcessed = FALSE;
bool BirthdayProcessed = FALSE;
bool AnniversaryProcessed = FALSE;
+ bool UIDProcessed = FALSE;
int ContactLineLen = 0;
int QuoteBreakPoint = 0;
int GroupCount = 0;
int CalendarAddressCount = 0;
int FreeBusyAddressCount = 0;
int KeyCount = 0;
+ int VendorCount = 0;
+ int XTokenCount = 0;
wxString ContactLine;
wxString PropertyLine;
wxString PropertySeg1;
ProcessKind(PropertySeg2);
+ } else if (Property == wxT("UID") && UIDProcessed == FALSE){
+
+ UIDToken = PropertySeg2;
+ UIDProcessed = TRUE;
+
} else if (Property == wxT("MEMBER")){
ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
KeyCount++;
+ } else if (Property.Mid(0, 3) == wxT("VND")){
+
+ ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
+ VendorCount++;
+
+ } else if (Property.Mid(0, 2) == wxT("X-")){
+
+ XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
+ XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
+ XTokenCount++;
+
}
}
}
+void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
+
+ // Split the Vendor three ways.
+
+ wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
+
+ wxString wxSVNDID;
+ wxString wxSVNDPropName;
+ long ListCtrlIndex;
+
+ while (wSTVendorDetails.HasMoreTokens() == TRUE){
+
+ wSTVendorDetails.GetNextToken();
+ wxSVNDID = wSTVendorDetails.GetNextToken();
+ wxSVNDPropName = wSTVendorDetails.GetNextToken();
+ break;
+
+ }
+
+ if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
+
+ // Add the data to the vendor variables.
+
+ VendorList.erase(*VendorCount);
+ VendorListPEN.erase(*VendorCount);
+ VendorListElement.erase(*VendorCount);
+
+ VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
+ VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
+ VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
+
+ }
+
+}
+
void SplitValues(wxString *PropertyLine,
std::map<int,int> *SplitPoints,
std::map<int,int> *SplitLength,
}
+TEST(ContactLoad, UIDTest){
+
+ ContactDataObject TestFile;
+
+ // Check that the vCard 4.0 file loads OK.
+
+ ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+
+ ASSERT_EQ("903588-9082374-989120310-AAFECDBCDF", TestFile.UIDToken);
+
+}
+
TEST(ContactLoad, NicknameTests){
ContactDataObject TestFile;
}
+TEST(ContactLoad, VendorTests){
+
+ ContactDataObject TestFile;
+
+ ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+
+ std::map<int,wxString>::iterator TestFileIter;
+ std::map<int,int>::iterator TestFileIntIter;
+
+ // Start with the first vendor namespace.
+
+ TestFileIter = TestFile.VendorList.find(0);
+ ASSERT_NE(TestFile.VendorList.end(), TestFileIter);
+ ASSERT_EQ("Lemon", TestFileIter->second);
+
+ TestFileIter = TestFile.VendorListPEN.find(0);
+ ASSERT_NE(TestFile.VendorListPEN.end(), TestFileIter);
+ ASSERT_EQ("696", TestFileIter->second);
+
+ TestFileIter = TestFile.VendorListElement.find(0);
+ ASSERT_NE(TestFile.VendorListElement.end(), TestFileIter);
+ ASSERT_EQ("CAKE", TestFileIter->second);
+
+ // Start with the second vendor namespace.
+
+ TestFileIter = TestFile.VendorList.find(1);
+ ASSERT_NE(TestFile.VendorList.end(), TestFileIter);
+ ASSERT_EQ("Orange", TestFileIter->second);
+
+ TestFileIter = TestFile.VendorListPEN.find(1);
+ ASSERT_NE(TestFile.VendorListPEN.end(), TestFileIter);
+ ASSERT_EQ("696", TestFileIter->second);
+
+ TestFileIter = TestFile.VendorListElement.find(1);
+ ASSERT_NE(TestFile.VendorListElement.end(), TestFileIter);
+ ASSERT_EQ("DRINK", TestFileIter->second);
+
+ // Start with the third vendor namespace.
+
+ TestFileIter = TestFile.VendorList.find(2);
+ ASSERT_NE(TestFile.VendorList.end(), TestFileIter);
+ ASSERT_EQ("Shiena Nishizawa", TestFileIter->second);
+
+ TestFileIter = TestFile.VendorListPEN.find(2);
+ ASSERT_NE(TestFile.VendorListPEN.end(), TestFileIter);
+ ASSERT_EQ("696", TestFileIter->second);
+
+ TestFileIter = TestFile.VendorListElement.find(2);
+ ASSERT_NE(TestFile.VendorListElement.end(), TestFileIter);
+ ASSERT_EQ("MUSIC", TestFileIter->second);
+
+}
+
+TEST(ContactLoad, XTokenTest){
+
+ ContactDataObject TestFile;
+
+ ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+
+ std::map<int,wxString>::iterator TestFileIter;
+ std::map<int,int>::iterator TestFileIntIter;
+
+ // Three X-FARM variables.
+
+ TestFileIter = TestFile.XTokenList.find(0);
+ ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+ ASSERT_EQ("Yard", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenListTokens.find(0);
+ ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+ ASSERT_EQ("FARM", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenList.find(1);
+ ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+ ASSERT_EQ("Animals", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenListTokens.find(1);
+ ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+ ASSERT_EQ("FARM", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenList.find(2);
+ ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+ ASSERT_EQ("Shed", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenListTokens.find(2);
+ ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+ ASSERT_EQ("FARM;LOCATION=Back;TYPE=Vehicles", TestFileIter->second.ToStdString());
+
+ // Three X-DISKSERIAL variables.
+
+ TestFileIter = TestFile.XTokenList.find(3);
+ ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+ ASSERT_EQ("14444", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenListTokens.find(3);
+ ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+ ASSERT_EQ("DISKSERIAL", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenList.find(4);
+ ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+ ASSERT_EQ("7555", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenListTokens.find(4);
+ ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+ ASSERT_EQ("DISKSERIAL", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenList.find(5);
+ ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+ ASSERT_EQ("3250539032590", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenListTokens.find(5);
+ ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+ ASSERT_EQ("DISKSERIAL;STATUS=DESTROYED;TYPE=FLASH", TestFileIter->second.ToStdString());
+
+ // Three X-FOODS variables.
+
+ TestFileIter = TestFile.XTokenList.find(6);
+ ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+ ASSERT_EQ("Lemon Cake", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenListTokens.find(6);
+ ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+ ASSERT_EQ("FOODS;STATUS=HIGH", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenList.find(7);
+ ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+ ASSERT_EQ("Starrey Gazey Pie", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenListTokens.find(7);
+ ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+ ASSERT_EQ("FOODS;STATUS=LOW", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenList.find(8);
+ ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+ ASSERT_EQ("Cornish Pasties", TestFileIter->second);
+
+ TestFileIter = TestFile.XTokenListTokens.find(8);
+ ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+ ASSERT_EQ("FOODS;STATUS=FAVOURITE;TYPE=CHEESEANDONION", TestFileIter->second.ToStdString());
+
+}
+
// TODO: Add tests for the Contact Loading process.
\ No newline at end of file