From 2ee1fe41786742332d190b01e28ba88a72c59f43 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 13 Jan 2016 16:31:54 -0800 Subject: =?UTF-8?q?[core]=20std::shared=5Fptr=20?= =?UTF-8?q?=E2=87=A2=20const=20Response&?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/storage/cache_response.cpp | 12 ++++++------ test/storage/cache_size.cpp | 16 ++++++++-------- test/storage/database.cpp | 31 +++++++++++++------------------ 3 files changed, 27 insertions(+), 32 deletions(-) (limited to 'test/storage') diff --git a/test/storage/cache_response.cpp b/test/storage/cache_response.cpp index 4f68edf0c4..df895ab7b4 100644 --- a/test/storage/cache_response.cpp +++ b/test/storage/cache_response.cpp @@ -64,8 +64,8 @@ TEST_F(Storage, CacheNotFound) { const Resource resource{ Resource::Unknown, "http://127.0.0.1:3000/not-found" }; // Insert existing data into the cache that will be marked as stale. - auto response = std::make_shared(); - response->data = std::make_shared("existing data"); + Response response; + response.data = std::make_shared("existing data"); cache.put(resource, response, SQLiteCache::Hint::Full); std::unique_ptr req1; @@ -122,8 +122,8 @@ TEST_F(Storage, DontCacheConnectionErrors) { const Resource resource{ Resource::Unknown, "http://127.0.0.1:3001" }; // Insert existing data into the cache that will be marked as stale. - auto response = std::make_shared(); - response->data = std::make_shared("existing data"); + Response response; + response.data = std::make_shared("existing data"); cache.put(resource, response, SQLiteCache::Hint::Full); std::unique_ptr req1; @@ -178,8 +178,8 @@ TEST_F(Storage, DontCacheServerErrors) { const Resource resource{ Resource::Unknown, "http://127.0.0.1:3000/permanent-error" }; // Insert existing data into the cache that will be marked as stale. - auto response = std::make_shared(); - response->data = std::make_shared("existing data"); + Response response; + response.data = std::make_shared("existing data"); cache.put(resource, response, SQLiteCache::Hint::Full); std::unique_ptr req1; diff --git a/test/storage/cache_size.cpp b/test/storage/cache_size.cpp index f94c52d234..7cea572139 100644 --- a/test/storage/cache_size.cpp +++ b/test/storage/cache_size.cpp @@ -38,10 +38,10 @@ void insertTile(mbgl::SQLiteCache* cache, unsigned id, uint64_t size) { auto url = std::string("http://tile") + mbgl::util::toString(id); - auto response = std::make_shared(); - response->modified = toSeconds(SystemClock::now()); - response->expires = toSeconds(SystemClock::now()) + Seconds(5000); - response->etag = url; + Response response; + response.modified = toSeconds(SystemClock::now()); + response.expires = toSeconds(SystemClock::now()) + Seconds(5000); + response.etag = url; auto data = std::make_shared(size, 0); @@ -50,7 +50,7 @@ void insertTile(mbgl::SQLiteCache* cache, unsigned id, uint64_t size) { static std::mt19937 generator; std::generate_n(data->begin(), size, generator); - response->data = data; + response.data = data; Resource resource{ Resource::Kind::Tile, url }; cache->put(resource, response, SQLiteCache::Hint::Full); @@ -61,9 +61,9 @@ void refreshTile(mbgl::SQLiteCache* cache, unsigned id) { auto url = std::string("http://tile") + mbgl::util::toString(id); - auto response = std::make_shared(); - response->modified = toSeconds(SystemClock::now()); - response->expires = toSeconds(SystemClock::now()) + Seconds(5000); + Response response; + response.modified = toSeconds(SystemClock::now()); + response.expires = toSeconds(SystemClock::now()) + Seconds(5000); Resource resource{ Resource::Kind::Tile, url }; cache->put(resource, response, SQLiteCache::Hint::Refresh); diff --git a/test/storage/database.cpp b/test/storage/database.cpp index 82a0296cc1..700b58ed24 100644 --- a/test/storage/database.cpp +++ b/test/storage/database.cpp @@ -75,9 +75,7 @@ TEST_F(Storage, DatabaseVersion) { { SQLiteCache::Impl cache(path); - - auto response = std::make_shared(); - cache.put({ Resource::Unknown, "mapbox://test" }, response); + cache.put({ Resource::Unknown, "mapbox://test" }, Response()); } sqlite3* db; @@ -193,8 +191,7 @@ TEST_F(Storage, DatabaseLockedWrite) { // Adds a file (which should fail). Log::setObserver(std::make_unique()); - auto response = std::make_shared(); - cache.put({ Resource::Unknown, "mapbox://test" }, response); + cache.put({ Resource::Unknown, "mapbox://test" }, Response()); cache.get({ Resource::Unknown, "mapbox://test" }, [] (std::unique_ptr res) { EXPECT_EQ(nullptr, res.get()); }); @@ -211,8 +208,8 @@ TEST_F(Storage, DatabaseLockedWrite) { // Then, set a file and obtain it again. Log::setObserver(std::make_unique()); - auto response = std::make_shared(); - response->data = std::make_shared("Demo"); + Response response; + response.data = std::make_shared("Demo"); cache.put({ Resource::Unknown, "mapbox://test" }, response); cache.get({ Resource::Unknown, "mapbox://test" }, [] (std::unique_ptr res) { ASSERT_NE(nullptr, res.get()); @@ -244,8 +241,8 @@ TEST_F(Storage, DatabaseLockedRefresh) { // Adds a file. Log::setObserver(std::make_unique()); - auto response = std::make_shared(); - response->data = std::make_shared("Demo"); + Response response; + response.data = std::make_shared("Demo"); cache.put({ Resource::Unknown, "mapbox://test" }, response); cache.get({ Resource::Unknown, "mapbox://test" }, [] (std::unique_ptr res) { EXPECT_EQ(nullptr, res.get()); @@ -260,9 +257,7 @@ TEST_F(Storage, DatabaseLockedRefresh) { // Then, try to refresh it. Log::setObserver(std::make_unique()); - auto response = std::make_shared(); - response->data = std::make_shared("Demo"); - cache.refresh({ Resource::Unknown, "mapbox://test" }, response->expires); + cache.refresh({ Resource::Unknown, "mapbox://test" }, Seconds::zero()); cache.get({ Resource::Unknown, "mapbox://test" }, [] (std::unique_ptr res) { EXPECT_EQ(nullptr, res.get()); }); @@ -289,8 +284,8 @@ TEST_F(Storage, DatabaseDeleted) { // Adds a file. Log::setObserver(std::make_unique()); - auto response = std::make_shared(); - response->data = std::make_shared("Demo"); + Response response; + response.data = std::make_shared("Demo"); cache.put({ Resource::Unknown, "mapbox://test" }, response); cache.get({ Resource::Unknown, "mapbox://test" }, [] (std::unique_ptr res) { ASSERT_NE(nullptr, res.get()); @@ -307,8 +302,8 @@ TEST_F(Storage, DatabaseDeleted) { // Adds a file. Log::setObserver(std::make_unique()); - auto response = std::make_shared(); - response->data = std::make_shared("Demo"); + Response response; + response.data = std::make_shared("Demo"); cache.put({ Resource::Unknown, "mapbox://test" }, response); cache.get({ Resource::Unknown, "mapbox://test" }, [] (std::unique_ptr res) { ASSERT_NE(nullptr, res.get()); @@ -338,8 +333,8 @@ TEST_F(Storage, DatabaseInvalid) { // Adds a file. Log::setObserver(std::make_unique()); - auto response = std::make_shared(); - response->data = std::make_shared("Demo"); + Response response; + response.data = std::make_shared("Demo"); cache.put({ Resource::Unknown, "mapbox://test" }, response); cache.get({ Resource::Unknown, "mapbox://test" }, [] (std::unique_ptr res) { ASSERT_NE(nullptr, res.get()); -- cgit v1.2.1