Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
IDKWNTCMF committed Aug 17, 2023
1 parent 8b661b6 commit 64851c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions server/src/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ std::shared_ptr<StructValueView> KTestObjectParser::structView(const std::vector
return true;
};

if (prevFieldEndOffset < fieldStartOffset) {
if (prevFieldEndOffset < fieldStartOffset && curStruct.subType == types::SubType::Union) {
// check an alignment gap
for (int i = prevFieldEndOffset/8; i < fieldStartOffset/8; ++i) {
if (dirtyCheck(i)) {
Expand Down Expand Up @@ -392,12 +392,12 @@ std::shared_ptr<StructValueView> KTestObjectParser::structView(const std::vector
throw NoSuchTypeException(message);
}

if (!dirtyInitializedField && sizeOfFieldToInitUnion < fieldLen) {
if (!dirtyInitializedField && sizeOfFieldToInitUnion < fieldLen &&
curStruct.subType == types::SubType::Union) {
fieldIndexToInitUnion = fieldIndex;
sizeOfFieldToInitUnion = fieldLen;
} else {
dirtyInitializedStruct = true;
}
dirtyInitializedStruct |= dirtyInitializedField;
prevFieldEndOffset = fieldEndOffset;
++fieldIndex;
}
Expand Down
6 changes: 2 additions & 4 deletions server/test/framework/Syntax_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1881,8 +1881,7 @@ namespace {
[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) ==
stoi(testCase.paramValues[1].view->getEntryValue(nullptr)) &&
StringUtils::startsWith(testCase.returnValue.view->getEntryValue(nullptr),
"{from_bytes<StructWithStructInUnion::DeepUnion>({");
testCase.returnValue.view->getEntryValue(nullptr) == "{{{'k', 1.010100e+00}}}";
},
[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) >
Expand All @@ -1909,8 +1908,7 @@ namespace {
[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) ==
stoi(testCase.paramValues[1].view->getEntryValue(nullptr)) &&
StringUtils::startsWith(testCase.returnValue.view->getEntryValue(nullptr),
"{from_bytes<StructWithUnionOfUnnamedType_un>({");
testCase.returnValue.view->getEntryValue(nullptr) == "{{{'k', 1.010100e+00}}}";
},
[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) >
Expand Down

0 comments on commit 64851c8

Please sign in to comment.