From 4c57149c77686ae44daa4156911cf25db5840e38 Mon Sep 17 00:00:00 2001 From: Matthew Landowski Date: Sun, 22 Nov 2015 10:03:11 -0600 Subject: [PATCH] passed database object by refence into threads --- test/src/unittest_SQLiteDatabase.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/src/unittest_SQLiteDatabase.cpp b/test/src/unittest_SQLiteDatabase.cpp index 539c907..bb29750 100644 --- a/test/src/unittest_SQLiteDatabase.cpp +++ b/test/src/unittest_SQLiteDatabase.cpp @@ -235,7 +235,7 @@ TEST_F(SQLiteDatabaseTestFixture, remove_test) { } // Helper function for multi_threaded_insert_test -void call_from_thread(sqlite::SQLiteDatabase db, std::string table) { +void call_from_thread(sqlite::SQLiteDatabase& db, std::string table) { db.insert(table, std::vector{"mpg", "weight"}, std::vector{"34", "2000"}, "", std::vector{}); } @@ -256,10 +256,10 @@ TEST_F(SQLiteDatabaseTestFixture, multi_threaded_insert_test) { const std::string table = "cars"; - std::thread t0(call_from_thread, db, table); - std::thread t1(call_from_thread, db, table); - std::thread t2(call_from_thread, db, table); - std::thread t3(call_from_thread, db, table); + std::thread t0(call_from_thread, std::ref(db), table); + std::thread t1(call_from_thread, std::ref(db), table); + std::thread t2(call_from_thread, std::ref(db), table); + std::thread t3(call_from_thread, std::ref(db), table); t0.join(); t1.join(); @@ -269,7 +269,6 @@ TEST_F(SQLiteDatabaseTestFixture, multi_threaded_insert_test) { sqlite::Cursor c = db.query("select * from cars;"); int count = c.getCount(); - std::cout << count; EXPECT_EQ(count, 4); db.close();