X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cf1014a2e11a3b06fecfb674a85a37120703a5c1..80a779275ae04443c568dca919adb26cf6f5002c:/tests/arrays/arrays.cpp?ds=sidebyside diff --git a/tests/arrays/arrays.cpp b/tests/arrays/arrays.cpp index f9ef9df2b7..049fbf09ae 100644 --- a/tests/arrays/arrays.cpp +++ b/tests/arrays/arrays.cpp @@ -1,17 +1,17 @@ /////////////////////////////////////////////////////////////////////////////// // Name: tests/arrays/arrays.cpp // Purpose: wxArray unit test -// Author: Wlodzimierz ABX Skiba +// Author: Vadim Zeitlin, Wlodzimierz ABX Skiba // Created: 2004-04-01 // RCS-ID: $Id$ -// Copyright: (c) 2004 Wlodzimierz Skiba +// Copyright: (c) 2004 Vadim Zeitlin, Wlodzimierz Skiba /////////////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- -#include "wx/wxprec.h" +#include "testprec.h" #ifdef __BORLANDC__ #pragma hdrstop @@ -23,8 +23,6 @@ #include "wx/dynarray.h" -#include "wx/cppunit.h" - // ---------------------------------------------------------------------------- // helpers for testing values and sizes // ---------------------------------------------------------------------------- @@ -190,7 +188,7 @@ void ArraysTestCase::wxStringArrayTest() wxArrayString a2(a1); - CPPUNIT_ASSERT( COMPARE_8_VALUES( a2 , _T("thermit") , + CPPUNIT_ASSERT( COMPARE_8_VALUES( a2 , _T("thermit") , _T("condor") , _T("lion") , _T("lion") , @@ -202,7 +200,7 @@ void ArraysTestCase::wxStringArrayTest() wxSortedArrayString a3(a1); - CPPUNIT_ASSERT( COMPARE_8_VALUES( a3 , _T("alligator") , + CPPUNIT_ASSERT( COMPARE_8_VALUES( a3 , _T("alligator") , _T("condor") , _T("dog") , _T("human") , @@ -216,7 +214,7 @@ void ArraysTestCase::wxStringArrayTest() for (wxArrayString::iterator it = a1.begin(), en = a1.end(); it != en; ++it) a4.Add(*it); - CPPUNIT_ASSERT( COMPARE_8_VALUES( a4 , _T("alligator") , + CPPUNIT_ASSERT( COMPARE_8_VALUES( a4 , _T("alligator") , _T("condor") , _T("dog") , _T("human") , @@ -270,6 +268,22 @@ void ArraysTestCase::wxStringArrayTest() _T("thermit") , _T("alligator") ) ); CPPUNIT_ASSERT( COMPARE_COUNT( a1 , 5 ) ); + CPPUNIT_ASSERT( a1.Index( _T("dog") ) == 0 ); + CPPUNIT_ASSERT( a1.Index( _T("human") ) == 1 ); + CPPUNIT_ASSERT( a1.Index( _T("humann") ) == wxNOT_FOUND ); + CPPUNIT_ASSERT( a1.Index( _T("condor") ) == 2 ); + CPPUNIT_ASSERT( a1.Index( _T("thermit") ) == 3 ); + CPPUNIT_ASSERT( a1.Index( _T("alligator") ) == 4 ); + + wxArrayString a5; + + CPPUNIT_ASSERT( a5.Add( _T("x"), 1 ) == 0 ); + CPPUNIT_ASSERT( a5.Add( _T("a"), 3 ) == 1 ); + + CPPUNIT_ASSERT( COMPARE_4_VALUES( a5, _T("x") , + _T("a") , + _T("a") , + _T("a") ) ); } void ArraysTestCase::wxObjArrayTest() @@ -332,6 +346,13 @@ void ArraysTestCase::wxArray ## name ## Test() \ \ CPPUNIT_ASSERT( COMPARE_4_VALUES(b,1,3,5,17) ); \ CPPUNIT_ASSERT( COMPARE_COUNT( b , 4 ) ); \ + CPPUNIT_ASSERT( b.Index( 0 ) == wxNOT_FOUND ); \ + CPPUNIT_ASSERT( b.Index( 1 ) == 0 ); \ + CPPUNIT_ASSERT( b.Index( 3 ) == 1 ); \ + CPPUNIT_ASSERT( b.Index( 4 ) == wxNOT_FOUND ); \ + CPPUNIT_ASSERT( b.Index( 5 ) == 2 ); \ + CPPUNIT_ASSERT( b.Index( 6 ) == wxNOT_FOUND ); \ + CPPUNIT_ASSERT( b.Index( 17 ) == 3 ); \ } TestArrayOf(UShort);