Compare commits
3 Commits
ca7b121c4d
...
5272636cb8
Author | SHA1 | Date |
---|---|---|
BodgeMaster | 5272636cb8 | |
BodgeMaster | 91d16ea451 | |
BodgeMaster | a1fc0ce4b4 |
|
@ -154,6 +154,9 @@ namespace NBT {
|
|||
if (stringSize.isError) {
|
||||
return ErrorOr<tiny_utf8::string>(true, stringSize.errorCode);
|
||||
}
|
||||
if (currentPosition + (uint64_t) stringSize.value + 2 > dataSize) {
|
||||
return ErrorOr<tiny_utf8::string>(true, ErrorCodes::OVERRUN);
|
||||
}
|
||||
|
||||
ErrorOr<tiny_utf8::string> output = JavaCompat::importJavaString(data+currentPosition, stringSize.value);
|
||||
if(output.isError){
|
||||
|
|
|
@ -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<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;
|
||||
|
||||
//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;
|
||||
}
|
||||
|
|
|
@ -490,9 +490,10 @@ int main(){
|
|||
|
||||
tiny_utf8::string normalString = tiny_utf8::string(normalStdString);
|
||||
|
||||
ASSERT(normalString == NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), 0x75, 0).value)
|
||||
ASSERT(NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), 0xFFFFF, 0).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), 0xF, 0).errorCode == ErrorCodes::MISMATCHEDSIZE);
|
||||
ASSERT(normalString == NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), javaStdString.size(), 0).value)
|
||||
|
||||
javaStdString[0] = '1';
|
||||
ASSERT(NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), javaStdString.size(), 0).errorCode == ErrorCodes::OVERRUN);
|
||||
std::cout << "Passed readString NBT helper test." << std::endl;
|
||||
delete nextChar;
|
||||
|
||||
|
|
Loading…
Reference in New Issue