Added regression test for [ 2857454 ] dereference invalid iterator when lead surrogate was last element of the string

git-svn-id: http://svn.code.sf.net/p/utfcpp/code@101 a809a056-fc17-0410-9590-b4f493f8b08e
This commit is contained in:
ntrifunovic 2009-09-27 18:47:45 +00:00 committed by King_DuckZ
parent 0b6b8b5cf8
commit 8f19d3aa84
2 changed files with 22 additions and 0 deletions

View file

@ -22,3 +22,24 @@ void id_2852872()
check(false);
}
}
// [ 2857454 ] dereference invalid iterator when lead surrogate was last element of the string
void id_2857454()
{
const unsigned short lead_surrogate_last[] = {0x65, 0xd800, 0};
vector<char> utf8_result;
try
{
utf8::utf16to8(lead_surrogate_last, lead_surrogate_last + 2, back_inserter(utf8_result));
// should throw in the previous line and never get here
}
catch(utf8::invalid_utf16&)
{
// this is what we expect
}
catch(...)
{
// an unexpected exception happened
check(false);
}
}

View file

@ -43,4 +43,5 @@ int main()
// Release 2.2.2
//r2_2_2/basic_functionality.h
id_2852872();
id_2857454();
}