Skip to content

Commit

Permalink
[AD-678] add unit test for Get/Set Statement Attribute (#58)
Browse files Browse the repository at this point in the history
* [AD-678] add unit test for Get/Set Statement Attribute

* [AD-678] resolve code review comment

*change buffer to SQLINTEGER type to avoid reinterpreting cast

* [AD-678] remove unnecessary variable assignment in test

* [AD-678] code review feedback from Bruce

* we don't really need a buffer here, as SQLINTEGER suffice.

Co-Authored-By: Bruce Irschick <[email protected]>
  • Loading branch information
alinaliBQ and Bruce Irschick authored Mar 31, 2022
1 parent a10db9d commit 1b7ee5c
Showing 1 changed file with 30 additions and 1 deletion.
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

0 comments on commit 1b7ee5c

Please sign in to comment.