blob: 9f0e22f381ba1ee1521af1ec1c3193ad40308dce [file] [log] [blame]
Ben Murdoch7dbb3d52013-07-17 14:55:54 +01001// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "sql/test/error_callback_support.h"
6
7#include "testing/gtest/include/gtest/gtest.h"
8
9namespace sql {
10
11void CaptureErrorCallback(int* error_pointer, int error, sql::Statement* stmt) {
12 *error_pointer = error;
13}
14
15ScopedErrorCallback::ScopedErrorCallback(
16 sql::Connection* db,
17 const sql::Connection::ErrorCallback& cb)
18 : db_(db) {
19 // Make sure someone isn't trying to nest things.
20 EXPECT_FALSE(db_->has_error_callback());
21 db_->set_error_callback(cb);
22}
23
24ScopedErrorCallback::~ScopedErrorCallback() {
25 db_->reset_error_callback();
26}
27
28} // namespace