summaryrefslogtreecommitdiffstats
path: root/sql/test/error_callback_support.cc
blob: 9f0e22f381ba1ee1521af1ec1c3193ad40308dce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "sql/test/error_callback_support.h"

#include "testing/gtest/include/gtest/gtest.h"

namespace sql {

void CaptureErrorCallback(int* error_pointer, int error, sql::Statement* stmt) {
  *error_pointer = error;
}

ScopedErrorCallback::ScopedErrorCallback(
    sql::Connection* db,
    const sql::Connection::ErrorCallback& cb)
    : db_(db) {
  // Make sure someone isn't trying to nest things.
  EXPECT_FALSE(db_->has_error_callback());
  db_->set_error_callback(cb);
}

ScopedErrorCallback::~ScopedErrorCallback() {
  db_->reset_error_callback();
}

}  // namespace