Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: sql/recovery_unittest.cc

Issue 1851913002: Convert //sql to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IWYU fixup in precache_url_table_unittest.cc Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sql/recovery.cc ('k') | sql/test/sql_test_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/recovery_unittest.cc
diff --git a/sql/recovery_unittest.cc b/sql/recovery_unittest.cc
index d3b04b1eb900a888cb955aa5fdfab36a83038c92..b215777560dd55674a828204359d087cfeec8a4f 100644
--- a/sql/recovery_unittest.cc
+++ b/sql/recovery_unittest.cc
@@ -5,6 +5,8 @@
#include "sql/recovery.h"
#include <stddef.h>
+
+#include <memory>
#include <string>
#include <utility>
@@ -80,7 +82,8 @@ TEST_F(SQLRecoveryTest, RecoverBasic) {
// If the Recovery handle goes out of scope without being
// Recovered(), the database is razed.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
}
EXPECT_FALSE(db().is_open());
@@ -95,7 +98,8 @@ TEST_F(SQLRecoveryTest, RecoverBasic) {
// Unrecoverable() also razes.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
sql::Recovery::Unrecoverable(std::move(recovery));
@@ -108,7 +112,8 @@ TEST_F(SQLRecoveryTest, RecoverBasic) {
// Attempting to recover a previously-recovered handle fails early.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
recovery.reset();
@@ -128,7 +133,8 @@ TEST_F(SQLRecoveryTest, RecoverBasic) {
// Recovered() replaces the original with the "recovered" version.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
// Create the new version of the table.
@@ -155,7 +161,8 @@ TEST_F(SQLRecoveryTest, RecoverBasic) {
// Rollback() discards recovery progress and leaves the database as it was.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
@@ -181,7 +188,8 @@ TEST_F(SQLRecoveryTest, VirtualTable) {
// Successfully recover the database.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
// Tables to recover original DB, now at [corrupt].
const char kRecoveryCreateSql[] =
@@ -221,7 +229,7 @@ void RecoveryCallback(sql::Connection* db, const base::FilePath& db_path,
// Clear the error callback to prevent reentrancy.
db->reset_error_callback();
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(db, db_path);
+ std::unique_ptr<sql::Recovery> recovery = sql::Recovery::Begin(db, db_path);
ASSERT_TRUE(recovery.get());
ASSERT_TRUE(recovery->db()->Execute(create_table));
@@ -386,7 +394,8 @@ TEST_F(SQLRecoveryTest, Meta) {
// Test expected case where everything works.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
EXPECT_TRUE(recovery->SetupMeta());
int version = 0;
EXPECT_TRUE(recovery->GetMetaVersionNumber(&version));
@@ -399,7 +408,8 @@ TEST_F(SQLRecoveryTest, Meta) {
// Test version row missing.
EXPECT_TRUE(db().Execute("DELETE FROM meta WHERE key = 'version'"));
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
EXPECT_TRUE(recovery->SetupMeta());
int version = 0;
EXPECT_FALSE(recovery->GetMetaVersionNumber(&version));
@@ -414,7 +424,8 @@ TEST_F(SQLRecoveryTest, Meta) {
{
sql::ScopedErrorIgnorer ignore_errors;
ignore_errors.IgnoreError(SQLITE_CORRUPT); // From virtual table.
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
EXPECT_FALSE(recovery->SetupMeta());
ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
}
@@ -439,7 +450,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTable) {
ASSERT_NE(orig_schema, GetSchema(&db()));
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
// Save a copy of the temp db's schema before recovering the table.
@@ -466,7 +478,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTable) {
// Recovery fails if the target table doesn't exist.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
// TODO(shess): Should this failure implicitly lead to Raze()?
@@ -523,7 +536,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableWithDefault) {
}
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
// Different default to detect which table provides the default.
ASSERT_TRUE(recovery->db()->Execute(final_schema.c_str()));
@@ -560,7 +574,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableNullFilter) {
ASSERT_NE(kOrigSchema, GetSchema(&db()));
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kFinalSchema));
size_t rows = 0;
@@ -599,7 +614,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableWithRowid) {
ASSERT_NE(orig_schema, GetSchema(&db()));
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
size_t rows = 0;
@@ -644,7 +660,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableWithCompoundKey) {
ASSERT_NE(orig_schema, GetSchema(&db()));
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
size_t rows = 0;
@@ -690,7 +707,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableMissingColumns) {
// Recover the previous version of the table into the altered version.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
ASSERT_TRUE(recovery->db()->Execute(kAlterSql));
size_t rows = 0;
@@ -718,7 +736,8 @@ TEST_F(SQLRecoveryTest, Bug387868) {
ASSERT_TRUE(Reopen());
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
// Create the new version of the table.
@@ -738,7 +757,8 @@ TEST_F(SQLRecoveryTest, Bug387868) {
// Memory-mapped I/O interacts poorly with I/O errors. Make sure the recovery
// database doesn't accidentally enable it.
TEST_F(SQLRecoveryTest, NoMmap) {
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
// In the current implementation, the PRAGMA successfully runs with no result
« no previous file with comments | « sql/recovery.cc ('k') | sql/test/sql_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698