Mercurial > hg > orthanc-databases
comparison SQLite/UnitTests/UnitTestsMain.cpp @ 157:275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 06 Jul 2020 12:45:58 +0200 |
parents | 063aa53b5917 |
children | 3236894320d6 |
comparison
equal
deleted
inserted
replaced
156:710537acb488 | 157:275e14f57f1e |
---|---|
20 | 20 |
21 | 21 |
22 #include "../../Framework/SQLite/SQLiteDatabase.h" | 22 #include "../../Framework/SQLite/SQLiteDatabase.h" |
23 #include "../Plugins/SQLiteIndex.h" | 23 #include "../Plugins/SQLiteIndex.h" |
24 | 24 |
25 #include <Compatibility.h> // For std::unique_ptr<> | |
25 #include <Logging.h> | 26 #include <Logging.h> |
26 #include <SystemToolbox.h> | 27 #include <SystemToolbox.h> |
27 | 28 |
28 #include <gtest/gtest.h> | 29 #include <gtest/gtest.h> |
29 | 30 |
66 | 67 |
67 ASSERT_FALSE(db.DoesTableExist("test")); | 68 ASSERT_FALSE(db.DoesTableExist("test")); |
68 ASSERT_FALSE(db.DoesTableExist("test2")); | 69 ASSERT_FALSE(db.DoesTableExist("test2")); |
69 | 70 |
70 { | 71 { |
71 std::auto_ptr<OrthancDatabases::ITransaction> t(db.CreateTransaction(false)); | 72 std::unique_ptr<OrthancDatabases::ITransaction> t(db.CreateTransaction(false)); |
72 ASSERT_FALSE(t->IsImplicit()); | 73 ASSERT_FALSE(t->IsImplicit()); |
73 } | 74 } |
74 | 75 |
75 { | 76 { |
76 OrthancDatabases::Query query("CREATE TABLE test(id INT)", false); | 77 OrthancDatabases::Query query("CREATE TABLE test(id INT)", false); |
77 std::auto_ptr<OrthancDatabases::IPrecompiledStatement> s(db.Compile(query)); | 78 std::unique_ptr<OrthancDatabases::IPrecompiledStatement> s(db.Compile(query)); |
78 | 79 |
79 std::auto_ptr<OrthancDatabases::ITransaction> t(db.CreateTransaction(true)); | 80 std::unique_ptr<OrthancDatabases::ITransaction> t(db.CreateTransaction(true)); |
80 ASSERT_TRUE(t->IsImplicit()); | 81 ASSERT_TRUE(t->IsImplicit()); |
81 ASSERT_THROW(t->Commit(), Orthanc::OrthancException); | 82 ASSERT_THROW(t->Commit(), Orthanc::OrthancException); |
82 ASSERT_THROW(t->Rollback(), Orthanc::OrthancException); | 83 ASSERT_THROW(t->Rollback(), Orthanc::OrthancException); |
83 | 84 |
84 OrthancDatabases::Dictionary args; | 85 OrthancDatabases::Dictionary args; |
90 } | 91 } |
91 | 92 |
92 { | 93 { |
93 // An implicit transaction does not need to be explicitely committed | 94 // An implicit transaction does not need to be explicitely committed |
94 OrthancDatabases::Query query("CREATE TABLE test2(id INT)", false); | 95 OrthancDatabases::Query query("CREATE TABLE test2(id INT)", false); |
95 std::auto_ptr<OrthancDatabases::IPrecompiledStatement> s(db.Compile(query)); | 96 std::unique_ptr<OrthancDatabases::IPrecompiledStatement> s(db.Compile(query)); |
96 | 97 |
97 std::auto_ptr<OrthancDatabases::ITransaction> t(db.CreateTransaction(true)); | 98 std::unique_ptr<OrthancDatabases::ITransaction> t(db.CreateTransaction(true)); |
98 | 99 |
99 OrthancDatabases::Dictionary args; | 100 OrthancDatabases::Dictionary args; |
100 t->ExecuteWithoutResult(*s, args); | 101 t->ExecuteWithoutResult(*s, args); |
101 } | 102 } |
102 | 103 |