Added more test cases for utf::previous and utf::unchecked::previous to the smoke-test

git-svn-id: http://svn.code.sf.net/p/utfcpp/code@26 a809a056-fc17-0410-9590-b4f493f8b08e
This commit is contained in:
ntrifunovic 2006-07-26 17:57:22 +00:00
parent 5a0f1d3fc4
commit b24be40542

View file

@ -8,6 +8,12 @@ using namespace std;
int main() int main()
{ {
unsigned char u10ffff[] = {0xf4, 0x8f, 0xbf, 0xbf};
unsigned char* uit = u10ffff;
unsigned int cp_u10ffff = next (uit, u10ffff + 4);
assert (cp_u10ffff == 0x10ffff);
return 0;
//append //append
unsigned char u[5] = {0,0,0,0,0}; unsigned char u[5] = {0,0,0,0,0};
@ -46,6 +52,17 @@ int main()
assert (cp == 0x65e5); assert (cp == 0x65e5);
assert (w == twochars); assert (w == twochars);
w = threechars + 9;
cp = previous(w, threechars - 1);
assert (cp == 0x0448);
assert (w == threechars + 7);
cp = previous(w, threechars -1);
assert (cp == 0x65e5);
assert (w == threechars + 4);
cp = previous(w, threechars - 1);
assert (cp == 0x10346);
assert (w == threechars);
// advance // advance
w = twochars; w = twochars;
advance (w, 2, twochars + 6); advance (w, 2, twochars + 6);
@ -132,11 +149,21 @@ int main()
//previous //previous
w = twochars + 3; w = twochars + 3;
//previous
cp = unchecked::previous (w); cp = unchecked::previous (w);
assert (cp == 0x65e5); assert (cp == 0x65e5);
assert (w == twochars); assert (w == twochars);
w = threechars + 9;
cp = unchecked::previous(w);
assert (cp == 0x0448);
assert (w == threechars + 7);
cp = unchecked::previous(w);
assert (cp == 0x65e5);
assert (w == threechars + 4);
cp = unchecked::previous(w);
assert (cp == 0x10346);
assert (w == threechars);
// advance // advance
w = twochars; w = twochars;
unchecked::advance (w, 2); unchecked::advance (w, 2);