Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions server/test/framework/Regression_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,34 @@ namespace {
"f4");
}

static bool checkAlignmentInNode(const tests::Tests::TestCaseParamValue &param) {
static const size_t HEX = 16;
static const size_t NODE_ALIGNMENT = 8;

const auto stringPointer = param.view->getSubViews().at(1)->getEntryValue(nullptr);
const size_t address = strtoull(stringPointer.c_str(), nullptr, HEX);
bool result = (address % NODE_ALIGNMENT == 0);

for (const auto &innerLazyValueParam : param.lazyValues) {
result &= checkAlignmentInNode(innerLazyValueParam);
}
return result;
}

TEST_F(Regression_Test, Pointers_Alignment) {
fs::path source = getTestFilePath("issue-195.c");
auto [testGen, status] = createTestForFunction(source, 8);

ASSERT_TRUE(status.ok()) << status.error_message();

for (const tests::Tests::MethodTestCase &testCase :
testGen.tests.at(source).methods.begin().value().testCases) {
for (const auto &paramValue : testCase.paramValues) {
EXPECT_TRUE(checkAlignmentInNode(paramValue));
}
}
}

TEST_F(Regression_Test, Generate_Folder) {
fs::path folderPath = getTestFilePath("ISSUE-140");
auto [testGen, status] = createTestForFolder(folderPath, true, true);
Expand Down
2 changes: 2 additions & 0 deletions server/test/suites/regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ target_compile_definitions(issue-276 PUBLIC EXPORT2="")
target_compile_definitions(issue-276 PUBLIC EXPORT3=4)
target_compile_definitions(issue-276 PUBLIC EXPORT4="4")

add_library(issue-195 issue-195.c)

set_target_properties(regression PROPERTIES LINK_WHAT_YOU_USE TRUE)
15 changes: 15 additions & 0 deletions server/test/suites/regression/issue-195.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdlib.h>

typedef struct Node {
int value;
struct Node *next;
} Node;

int list_sum(Node *head) {
int sum = 0;
while (head != NULL) {
sum += head->value;
head = head->next;
}
return sum;
}