Added a regression test to detect a sequence of multiple trail surrogate code units
git-svn-id: http://svn.code.sf.net/p/utfcpp/code@99 a809a056-fc17-0410-9590-b4f493f8b08e Conflicts: v2_0/test_drivers/regression_tests/reg_tests_driver.cpp
This commit is contained in:
parent
6adb83ba84
commit
94bfe8d2d3
2 changed files with 31 additions and 1 deletions
24
test_drivers/regression_tests/r2_2_2/basic_functionality.h
Executable file
24
test_drivers/regression_tests/r2_2_2/basic_functionality.h
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#include "../../../source/utf8.h"
|
||||||
|
using namespace utf8;
|
||||||
|
|
||||||
|
// [ 2852872 ] invalid utf16 strings were parsed without any error
|
||||||
|
void id_2852872()
|
||||||
|
{
|
||||||
|
const unsigned short two_trail_surrogates[] = {0xdd00, 0xdd01, 0};
|
||||||
|
vector<char> utf8_result;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
utf8::utf16to8(two_trail_surrogates, two_trail_surrogates+2, back_inserter(utf8_result));
|
||||||
|
// should throw in the previous line and never get here
|
||||||
|
check(false);
|
||||||
|
}
|
||||||
|
catch(utf8::invalid_utf16&)
|
||||||
|
{
|
||||||
|
// this is what we expect
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
// an unexpected exception happened
|
||||||
|
check(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
inline void check_impl (bool condition, const char* file, int line)
|
inline void check_impl (bool condition, const char* file, int line)
|
||||||
|
@ -18,7 +19,8 @@ inline void check_impl (bool condition, const char* file, int line)
|
||||||
// Release 1.0 Beta 3
|
// Release 1.0 Beta 3
|
||||||
#include "r1_0Beta3/basic_functionality.h"
|
#include "r1_0Beta3/basic_functionality.h"
|
||||||
|
|
||||||
|
// Release 2.2.2
|
||||||
|
#include "r2_2_2/basic_functionality.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
@ -37,4 +39,8 @@ int main()
|
||||||
// Release 1.0 Beta 3
|
// Release 1.0 Beta 3
|
||||||
//r1_0Beta3/basic_functionality.h
|
//r1_0Beta3/basic_functionality.h
|
||||||
id_1538338();
|
id_1538338();
|
||||||
|
|
||||||
|
// Release 2.2.2
|
||||||
|
//r2_2_2/basic_functionality.h
|
||||||
|
id_2852872();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue