@@ -40,36 +40,47 @@ def test_size
4040 assert_equal 3 , stmts . size
4141 end
4242
43- def test_prepared_statement
43+ def test_prepared_statement_first
4444 stmts = DuckDB ::ExtractedStatements . new ( @con , 'SELECT 1; SELECT 2; SELECT 3' )
4545 stmt = stmts . prepared_statement ( @con , 0 )
4646
4747 assert_instance_of ( DuckDB ::PreparedStatement , stmt )
4848 r = stmt . execute
4949
5050 assert_equal ( [ [ 1 ] ] , r . to_a )
51+ end
5152
53+ def test_prepared_statement_second
54+ stmts = DuckDB ::ExtractedStatements . new ( @con , 'SELECT 1; SELECT 2; SELECT 3' )
5255 stmt = stmts . prepared_statement ( @con , 1 )
5356 r = stmt . execute
5457
5558 assert_equal ( [ [ 2 ] ] , r . to_a )
59+ end
5660
61+ def test_prepared_statement_third
62+ stmts = DuckDB ::ExtractedStatements . new ( @con , 'SELECT 1; SELECT 2; SELECT 3' )
5763 stmt = stmts . prepared_statement ( @con , 2 )
5864 r = stmt . execute
5965
6066 assert_equal ( [ [ 3 ] ] , r . to_a )
6167 end
6268
63- def test_prepared_statement_with_invalid_index
69+ def test_prepared_statement_with_invalid_positive_index
6470 stmts = DuckDB ::ExtractedStatements . new ( @con , 'SELECT 1; SELECT 2; SELECT 3' )
6571 ex = assert_raises DuckDB ::Error do
6672 stmts . prepared_statement ( @con , 3 )
6773 end
74+
6875 assert_equal 'Failed to create DuckDB::PreparedStatement object.' , ex . message
76+ end
6977
78+ def test_prepared_statement_with_invalid_negative_index
79+ stmts = DuckDB ::ExtractedStatements . new ( @con , 'SELECT 1; SELECT 2; SELECT 3' )
7080 ex = assert_raises DuckDB ::Error do
7181 stmts . prepared_statement ( @con , -1 )
7282 end
83+
7384 assert_equal 'Failed to create DuckDB::PreparedStatement object.' , ex . message
7485 end
7586
0 commit comments