vCard writing tests
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7401 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1187,7 +1187,7 @@ static void DumpVObject(size_t level, const wxVCardObject& vcard)
|
|||||||
while ( vcObj )
|
while ( vcObj )
|
||||||
{
|
{
|
||||||
printf("%s%s",
|
printf("%s%s",
|
||||||
wxString(_T('\t'), level),
|
wxString(_T('\t'), level).c_str(),
|
||||||
vcObj->GetName().c_str());
|
vcObj->GetName().c_str());
|
||||||
|
|
||||||
wxString value;
|
wxString value;
|
||||||
@@ -1390,6 +1390,28 @@ static void TestVCardRead()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void TestVCardWrite()
|
||||||
|
{
|
||||||
|
puts("*** Testing wxVCard writing ***\n");
|
||||||
|
|
||||||
|
wxVCard vcard;
|
||||||
|
if ( !vcard.IsOk() )
|
||||||
|
{
|
||||||
|
puts("ERROR: couldn't create vCard.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// set some fields
|
||||||
|
vcard.SetName("Zeitlin", "Vadim");
|
||||||
|
vcard.SetFullName("Vadim Zeitlin");
|
||||||
|
vcard.SetOrganization("wxWindows", "R&D");
|
||||||
|
|
||||||
|
// just dump the vCard back
|
||||||
|
puts("Entire vCard follows:\n");
|
||||||
|
puts(vcard.Write());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // TEST_VCARD
|
#endif // TEST_VCARD
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -2658,6 +2680,55 @@ static int StringLenCompare(const wxString& first, const wxString& second)
|
|||||||
return first.length() - second.length();
|
return first.length() - second.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "wx/dynarray.h"
|
||||||
|
|
||||||
|
class Bar // Foo is already taken in the hash test
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Bar(const wxString& name) : m_name(name) { ms_bars++; }
|
||||||
|
~Bar() { ms_bars--; }
|
||||||
|
|
||||||
|
static size_t GetNumber() { return ms_bars; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_name;
|
||||||
|
|
||||||
|
static size_t ms_bars;
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t Bar::ms_bars = 0;
|
||||||
|
|
||||||
|
WX_DECLARE_OBJARRAY(Bar, ArrayBars);
|
||||||
|
#include "wx/arrimpl.cpp"
|
||||||
|
WX_DEFINE_OBJARRAY(ArrayBars);
|
||||||
|
|
||||||
|
static void TestArrayOfObjects()
|
||||||
|
{
|
||||||
|
puts("*** Testing wxObjArray ***\n");
|
||||||
|
|
||||||
|
{
|
||||||
|
ArrayBars bars;
|
||||||
|
Bar bar("second bar");
|
||||||
|
|
||||||
|
printf("Initially: %u objects in the array, %u objects total.\n",
|
||||||
|
bars.GetCount(), Bar::GetNumber());
|
||||||
|
|
||||||
|
bars.Add(new Bar("first bar"));
|
||||||
|
bars.Add(bar);
|
||||||
|
|
||||||
|
printf("Now: %u objects in the array, %u objects total.\n",
|
||||||
|
bars.GetCount(), Bar::GetNumber());
|
||||||
|
|
||||||
|
bars.Empty();
|
||||||
|
|
||||||
|
printf("After Empty(): %u objects in the array, %u objects total.\n",
|
||||||
|
bars.GetCount(), Bar::GetNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Finally: no more objects in the array, %u objects total.\n",
|
||||||
|
Bar::GetNumber());
|
||||||
|
}
|
||||||
|
|
||||||
#endif // TEST_ARRAYS
|
#endif // TEST_ARRAYS
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -3121,6 +3192,8 @@ int main(int argc, char **argv)
|
|||||||
puts("*** After sorting a1 by the string length");
|
puts("*** After sorting a1 by the string length");
|
||||||
a1.Sort(StringLenCompare);
|
a1.Sort(StringLenCompare);
|
||||||
PrintArray("a1", a1);
|
PrintArray("a1", a1);
|
||||||
|
|
||||||
|
TestArrayOfObjects();
|
||||||
#endif // TEST_ARRAYS
|
#endif // TEST_ARRAYS
|
||||||
|
|
||||||
#ifdef TEST_DIR
|
#ifdef TEST_DIR
|
||||||
@@ -3252,7 +3325,9 @@ int main(int argc, char **argv)
|
|||||||
#endif // TEST_DATETIME
|
#endif // TEST_DATETIME
|
||||||
|
|
||||||
#ifdef TEST_VCARD
|
#ifdef TEST_VCARD
|
||||||
|
if ( 0 )
|
||||||
TestVCardRead();
|
TestVCardRead();
|
||||||
|
TestVCardWrite();
|
||||||
#endif // TEST_VCARD
|
#endif // TEST_VCARD
|
||||||
|
|
||||||
#ifdef TEST_WCHAR
|
#ifdef TEST_WCHAR
|
||||||
|
Reference in New Issue
Block a user