Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/Prefs.cpp

Issue 5163715573841920: Issue 768 - Switch from TR1 to C++11 (Closed)
Patch Set: Created July 11, 2014, 2:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <sstream> 18 #include <sstream>
19 19
20 #include "../src/Thread.h" 20 #include "../src/Thread.h"
21 #include "BaseJsTest.h" 21 #include "BaseJsTest.h"
22 22
23 namespace 23 namespace
24 { 24 {
25 typedef std::tr1::shared_ptr<AdblockPlus::FilterEngine> FilterEnginePtr; 25 typedef std::shared_ptr<AdblockPlus::FilterEngine> FilterEnginePtr;
26 26
27 class TestFileSystem : public LazyFileSystem 27 class TestFileSystem : public LazyFileSystem
28 { 28 {
29 public: 29 public:
30 std::string prefsContents; 30 std::string prefsContents;
31 31
32 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const 32 std::shared_ptr<std::istream> Read(const std::string& path) const
33 { 33 {
34 if (path == "prefs.json" && !prefsContents.empty()) 34 if (path == "prefs.json" && !prefsContents.empty())
35 return std::tr1::shared_ptr<std::istream>(new std::istringstream(prefsCo ntents)); 35 return std::shared_ptr<std::istream>(new std::istringstream(prefsContent s));
36 36
37 return LazyFileSystem::Read(path); 37 return LazyFileSystem::Read(path);
38 } 38 }
39 39
40 void Write(const std::string& path, std::tr1::shared_ptr<std::istream> conte nt) 40 void Write(const std::string& path, std::shared_ptr<std::istream> content)
41 { 41 {
42 if (path == "prefs.json") 42 if (path == "prefs.json")
43 { 43 {
44 std::stringstream ss; 44 std::stringstream ss;
45 ss << content->rdbuf(); 45 ss << content->rdbuf();
46 prefsContents = ss.str(); 46 prefsContents = ss.str();
47 } 47 }
48 else 48 else
49 LazyFileSystem::Write(path, content); 49 LazyFileSystem::Write(path, content);
50 } 50 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 ASSERT_EQ(12, filterEngine->GetPref("patternsbackupinterval")->AsInt()); 140 ASSERT_EQ(12, filterEngine->GetPref("patternsbackupinterval")->AsInt());
141 } 141 }
142 142
143 TEST_F(PrefsTest, SyntaxFailure) 143 TEST_F(PrefsTest, SyntaxFailure)
144 { 144 {
145 fileSystem->prefsContents = "{\"patternsbackupinterval\": 6, \"foo\"}"; 145 fileSystem->prefsContents = "{\"patternsbackupinterval\": 6, \"foo\"}";
146 Reset(); 146 Reset();
147 147
148 ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval")->AsInt()); 148 ASSERT_EQ(24, filterEngine->GetPref("patternsbackupinterval")->AsInt());
149 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld