Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AD-678] add unit test for Get/Set Statement Attribute #58

Merged
merged 4 commits into from
Mar 31, 2022
Merged
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
31 changes: 30 additions & 1 deletion src/odbc-test/src/api_robustness_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct ApiRobustnessTestSuiteFixture : public odbc::OdbcTestSuite {
* Constructor.
*/
ApiRobustnessTestSuiteFixture() : testCache(0) {
// No-op
// No-op
}

/**
Expand Down Expand Up @@ -166,6 +166,35 @@ BOOST_AUTO_TEST_CASE(TestSQLPrimaryKeysEmpty) {
BOOST_CHECK_EQUAL(SQL_NO_DATA, ret);
}

BOOST_AUTO_TEST_CASE(TestSQLSetStmtAttrGetStmtAttr) {
// check that statement array size is set correctly

std::string dsnConnectionString;
CreateDsnConnectionStringForLocalServer(dsnConnectionString);

Connect(dsnConnectionString);

SQLINTEGER actual_row_array_size;
SQLINTEGER resLen = 0;

// repeat test for different values
SQLULEN valList[5] = {10, 52, 81, 103, 304};
for (SQLULEN val : valList) {
SQLRETURN ret =
SQLSetStmtAttr(stmt, SQL_ATTR_ROW_ARRAY_SIZE,
reinterpret_cast< SQLPOINTER >(val), sizeof(val));

ODBC_FAIL_ON_ERROR(ret, SQL_HANDLE_STMT, stmt);

ret = SQLGetStmtAttr(stmt, SQL_ATTR_ROW_ARRAY_SIZE, &actual_row_array_size,
sizeof(actual_row_array_size), &resLen);

ODBC_FAIL_ON_ERROR(ret, SQL_HANDLE_STMT, stmt);

BOOST_CHECK_EQUAL(actual_row_array_size, val);
}
}

BOOST_AUTO_TEST_CASE(TestSQLDriverConnect, *disabled()) {
// There are no checks because we do not really care what is the result of
// these calls as long as they do not cause segmentation fault.
Expand Down