diff --git a/src/test/javacompat.cpp b/src/test/javacompat.cpp index 7ddda95..a6e6d7b 100644 --- a/src/test/javacompat.cpp +++ b/src/test/javacompat.cpp @@ -75,7 +75,16 @@ int main(){ tiny_utf8::string normalString = tiny_utf8::string(normalStdString); + // check for normal operation ASSERT(normalString == importedString); + + // check for mismatched size error + std::string javaStdStringCopy = javaStdString; + javaStdStringCopy[0]='b'; + ErrorOr errorString = JavaCompat::importJavaString(reinterpret_cast(javaStdStringCopy.data()), 0x75); + ASSERT(errorString.isError); + ASSERT(errorString.errorCode == ErrorCodes::MISMATCHEDSIZE); + std::cout << "Passed Import Java string test." << std::endl; //using normalString from when we read the file earlier @@ -91,5 +100,5 @@ int main(){ std::cout << "Passed Export Java string test." << std::endl; delete nextChar; -return 0; + return 0; }