test/javacompat: add test for mismatched size

Soda
BodgeMaster 2022-08-15 12:24:03 +02:00
parent a1fc0ce4b4
commit 91d16ea451
1 changed files with 10 additions and 1 deletions

View File

@ -75,7 +75,16 @@ int main(){
tiny_utf8::string normalString = tiny_utf8::string(normalStdString); tiny_utf8::string normalString = tiny_utf8::string(normalStdString);
// check for normal operation
ASSERT(normalString == importedString); ASSERT(normalString == importedString);
// check for mismatched size error
std::string javaStdStringCopy = javaStdString;
javaStdStringCopy[0]='b';
ErrorOr<tiny_utf8::string> errorString = JavaCompat::importJavaString(reinterpret_cast<uint8_t*>(javaStdStringCopy.data()), 0x75);
ASSERT(errorString.isError);
ASSERT(errorString.errorCode == ErrorCodes::MISMATCHEDSIZE);
std::cout << "Passed Import Java string test." << std::endl; std::cout << "Passed Import Java string test." << std::endl;
//using normalString from when we read the file earlier //using normalString from when we read the file earlier