@@ -1281,6 +1281,50 @@ TYPED_TEST(StatementTest, TestSQLNativeSqlReturnsErrorOnBadInputs) {
12811281 VerifyOdbcErrorState (SQL_HANDLE_DBC, this ->conn , kErrorStateHY090 );
12821282}
12831283
1284+ TYPED_TEST (StatementTest, SQLNumResultColsReturnsColumnsOnSelect) {
1285+ SQLSMALLINT column_count = 0 ;
1286+ SQLSMALLINT expected_value = 3 ;
1287+ SQLWCHAR sql_query[] = L" SELECT 1 AS col1, 'One' AS col2, 3 AS col3" ;
1288+ SQLINTEGER query_length = static_cast <SQLINTEGER>(wcslen (sql_query));
1289+
1290+ ASSERT_EQ (SQL_SUCCESS, SQLExecDirect (this ->stmt , sql_query, query_length));
1291+
1292+ ASSERT_EQ (SQL_SUCCESS, SQLFetch (this ->stmt ));
1293+
1294+ CheckIntColumn (this ->stmt , 1 , 1 );
1295+ CheckStringColumnW (this ->stmt , 2 , L" One" );
1296+ CheckIntColumn (this ->stmt , 3 , 3 );
1297+
1298+ ASSERT_EQ (SQL_SUCCESS, SQLNumResultCols (this ->stmt , &column_count));
1299+
1300+ EXPECT_EQ (expected_value, column_count);
1301+ }
1302+
1303+ TYPED_TEST (StatementTest, SQLNumResultColsReturnsSuccessOnNullptr) {
1304+ SQLWCHAR sql_query[] = L" SELECT 1 AS col1, 'One' AS col2, 3 AS col3" ;
1305+ SQLINTEGER query_length = static_cast <SQLINTEGER>(wcslen (sql_query));
1306+
1307+ ASSERT_EQ (SQL_SUCCESS, SQLExecDirect (this ->stmt , sql_query, query_length));
1308+
1309+ ASSERT_EQ (SQL_SUCCESS, SQLFetch (this ->stmt ));
1310+
1311+ CheckIntColumn (this ->stmt , 1 , 1 );
1312+ CheckStringColumnW (this ->stmt , 2 , L" One" );
1313+ CheckIntColumn (this ->stmt , 3 , 3 );
1314+
1315+ ASSERT_EQ (SQL_SUCCESS, SQLNumResultCols (this ->stmt , nullptr ));
1316+ }
1317+
1318+ TYPED_TEST (StatementTest, SQLNumResultColsFunctionSequenceErrorOnNoQuery) {
1319+ SQLSMALLINT column_count = 0 ;
1320+ SQLSMALLINT expected_value = 0 ;
1321+
1322+ ASSERT_EQ (SQL_ERROR, SQLNumResultCols (this ->stmt , &column_count));
1323+ VerifyOdbcErrorState (SQL_HANDLE_STMT, this ->stmt , kErrorStateHY010 );
1324+
1325+ EXPECT_EQ (expected_value, column_count);
1326+ }
1327+
12841328TYPED_TEST (StatementTest, SQLRowCountReturnsNegativeOneOnSelect) {
12851329 SQLLEN row_count = 0 ;
12861330 SQLLEN expected_value = -1 ;
0 commit comments