Mercurial > hg > orthanc
comparison UnitTestsSources/SQLiteChromiumTests.cpp @ 2884:497a637366b4 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 12 Oct 2018 15:18:10 +0200 |
parents | c196d76cb8fa |
children | 22524fd06225 |
comparison
equal
deleted
inserted
replaced
1762:2b91363cc1d1 | 2884:497a637366b4 |
---|---|
1 /** | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4 * Department, University Hospital of Liege, Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium | |
5 * | 6 * |
6 * This program is free software: you can redistribute it and/or | 7 * This program is free software: you can redistribute it and/or |
7 * modify it under the terms of the GNU General Public License as | 8 * modify it under the terms of the GNU General Public License as |
8 * published by the Free Software Foundation, either version 3 of the | 9 * published by the Free Software Foundation, either version 3 of the |
9 * License, or (at your option) any later version. | 10 * License, or (at your option) any later version. |
48 /******************************************************************** | 49 /******************************************************************** |
49 ** Tests from | 50 ** Tests from |
50 ** http://src.chromium.org/viewvc/chrome/trunk/src/sql/connection_unittest.cc | 51 ** http://src.chromium.org/viewvc/chrome/trunk/src/sql/connection_unittest.cc |
51 ********************************************************************/ | 52 ********************************************************************/ |
52 | 53 |
53 class SQLConnectionTest : public testing::Test | 54 namespace |
54 { | 55 { |
55 public: | 56 class SQLConnectionTest : public testing::Test |
56 SQLConnectionTest() | 57 { |
57 { | 58 public: |
58 } | 59 SQLConnectionTest() |
59 | 60 { |
60 virtual ~SQLConnectionTest() | 61 } |
61 { | 62 |
62 } | 63 virtual ~SQLConnectionTest() |
63 | 64 { |
64 virtual void SetUp() | 65 } |
65 { | 66 |
66 db_.OpenInMemory(); | 67 virtual void SetUp() |
67 } | 68 { |
68 | 69 db_.OpenInMemory(); |
69 virtual void TearDown() | 70 } |
70 { | 71 |
71 db_.Close(); | 72 virtual void TearDown() |
72 } | 73 { |
73 | 74 db_.Close(); |
74 Connection& db() | 75 } |
75 { | 76 |
76 return db_; | 77 Connection& db() |
77 } | 78 { |
78 | 79 return db_; |
79 private: | 80 } |
80 Connection db_; | 81 |
81 }; | 82 private: |
83 Connection db_; | |
84 }; | |
85 } | |
82 | 86 |
83 | 87 |
84 | 88 |
85 TEST_F(SQLConnectionTest, Execute) | 89 TEST_F(SQLConnectionTest, Execute) |
86 { | 90 { |
263 /******************************************************************** | 267 /******************************************************************** |
264 ** Tests from | 268 ** Tests from |
265 ** http://src.chromium.org/viewvc/chrome/trunk/src/sql/transaction_unittest.cc | 269 ** http://src.chromium.org/viewvc/chrome/trunk/src/sql/transaction_unittest.cc |
266 ********************************************************************/ | 270 ********************************************************************/ |
267 | 271 |
268 class SQLTransactionTest : public SQLConnectionTest | 272 namespace |
269 { | 273 { |
270 public: | 274 class SQLTransactionTest : public SQLConnectionTest |
271 virtual void SetUp() | 275 { |
272 { | 276 public: |
273 SQLConnectionTest::SetUp(); | 277 virtual void SetUp() |
274 ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)")); | 278 { |
275 } | 279 SQLConnectionTest::SetUp(); |
276 | 280 ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)")); |
277 // Returns the number of rows in table "foo". | 281 } |
278 int CountFoo() | 282 |
279 { | 283 // Returns the number of rows in table "foo". |
280 Statement count(db(), "SELECT count(*) FROM foo"); | 284 int CountFoo() |
281 count.Step(); | 285 { |
282 return count.ColumnInt(0); | 286 Statement count(db(), "SELECT count(*) FROM foo"); |
283 } | 287 count.Step(); |
284 }; | 288 return count.ColumnInt(0); |
289 } | |
290 }; | |
291 } | |
285 | 292 |
286 | 293 |
287 TEST_F(SQLTransactionTest, Commit) { | 294 TEST_F(SQLTransactionTest, Commit) { |
288 { | 295 { |
289 Transaction t(db()); | 296 Transaction t(db()); |