Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: third_party/gsutil/gslib/tests/test_plurality_checkable_iterator.py

Issue 12317103: Added gsutil to depot tools (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: added readme Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2012 Google Inc. All Rights Reserved.
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions:
10 #
11 # The above copyright notice and this permission notice shall be included
12 # in all copies or substantial portions of the Software.
13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 # IN THE SOFTWARE.
21
22 """Unit tests for PluralityCheckableIterator"""
23
24 from gslib.plurality_checkable_iterator import PluralityCheckableIterator
25 import gslib.tests.testcase as testcase
26
27 class PluralityCheckableIteratorTests(testcase.GsUtilUnitTestCase):
28
29 def testPluralityCheckableIteratorWith0Elems(self):
30 """Tests empty PluralityCheckableIterator."""
31 input_list = range(0)
32 it = iter(input_list)
33 pcit = PluralityCheckableIterator(it)
34 self.assertTrue(pcit.is_empty())
35 self.assertFalse(pcit.has_plurality())
36 output_list = list(pcit)
37 self.assertEqual(input_list, output_list)
38
39 def testPluralityCheckableIteratorWith1Elem(self):
40 """Tests PluralityCheckableIterator with 1 element."""
41 input_list = range(1)
42 it = iter(input_list)
43 pcit = PluralityCheckableIterator(it)
44 self.assertFalse(pcit.is_empty())
45 self.assertFalse(pcit.has_plurality())
46 output_list = list(pcit)
47 self.assertEqual(input_list, output_list)
48
49 def testPluralityCheckableIteratorWith2Elems(self):
50 """Tests PluralityCheckableIterator with 2 elements."""
51 input_list = range(2)
52 it = iter(input_list)
53 pcit = PluralityCheckableIterator(it)
54 self.assertFalse(pcit.is_empty())
55 self.assertTrue(pcit.has_plurality())
56 output_list = list(pcit)
57 self.assertEqual(input_list, output_list)
58
59 def testPluralityCheckableIteratorWith3Elems(self):
60 """Tests PluralityCheckableIterator with 3 elements."""
61 input_list = range(3)
62 it = iter(input_list)
63 pcit = PluralityCheckableIterator(it)
64 self.assertFalse(pcit.is_empty())
65 self.assertTrue(pcit.has_plurality())
66 output_list = list(pcit)
67 self.assertEqual(input_list, output_list)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698