2020-02-28 21:28:33 +01:00
|
|
|
#include <Platform.h>
|
2020-02-23 21:23:31 +01:00
|
|
|
#include "../cpp_foundation/XStringWArray.h"
|
|
|
|
|
|
|
|
int XStringWArray_tests()
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef JIEF_DEBUG
|
|
|
|
DebugLog(2, "XStringWArray_tests -> Enter\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
XStringWArray array1;
|
|
|
|
|
|
|
|
if ( !array1.IsNull() ) return 1;
|
|
|
|
|
|
|
|
array1.Add(L"1");
|
|
|
|
if ( array1.IsNull() ) return 2;
|
|
|
|
array1.Add(L"2");
|
|
|
|
|
|
|
|
if ( array1[0] != L"1" ) return 3;
|
|
|
|
if ( array1[1] != L"2" ) return 4;
|
|
|
|
|
|
|
|
if ( !array1.Contains(L"2") ) return 5;
|
|
|
|
|
|
|
|
// Test == and !=
|
|
|
|
{
|
|
|
|
XStringWArray array1bis;
|
|
|
|
array1bis.Add(L"1");
|
|
|
|
array1bis.Add(L"2");
|
|
|
|
|
|
|
|
if ( !(array1 == array1bis) ) return 10;
|
|
|
|
if ( array1 != array1bis ) return 11;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test concat and Split
|
|
|
|
{
|
|
|
|
XStringW c = array1.ConcatAll(L", ", L"^", L"$");
|
|
|
|
if ( c != L"^1, 2$" ) return 1;
|
|
|
|
|
|
|
|
// Split doesn't handle prefix and suffix yet.
|
|
|
|
c = array1.ConcatAll(L", ");
|
|
|
|
|
|
|
|
XStringWArray array1bis = Split(c);
|
|
|
|
if ( array1 != array1bis ) return 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
XStringWArray array2;
|
|
|
|
array2.Add(L"2");
|
|
|
|
array2.Add(L"1");
|
|
|
|
|
|
|
|
if ( array2[0] != L"2" ) return 30;
|
|
|
|
if ( array2[1] != L"1" ) return 31;
|
|
|
|
|
|
|
|
|
|
|
|
if ( array1 == array2 ) return 40; // Array != because order is different
|
|
|
|
if ( !array1.Same(array2) ) return 41; // Arrays are the same
|
|
|
|
|
|
|
|
array1.AddNoNull(L"3");
|
2020-02-27 15:34:29 +01:00
|
|
|
if ( array1.size() != 3 ) return 50;
|
2020-02-23 21:23:31 +01:00
|
|
|
array1.AddNoNull(L"");
|
2020-02-27 15:34:29 +01:00
|
|
|
if ( array1.size() != 3 ) return 51;
|
2020-02-23 21:23:31 +01:00
|
|
|
array1.AddEvenNull(XStringW());
|
2020-02-27 15:34:29 +01:00
|
|
|
if ( array1.size() != 4 ) return 52;
|
2020-02-23 21:23:31 +01:00
|
|
|
array1.AddID(L"2");
|
2020-02-27 15:34:29 +01:00
|
|
|
if ( array1.size() != 4 ) return 53;
|
2020-02-23 21:23:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|