本文整理汇总了Python中Vector.Vector.extend方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.extend方法的具体用法?Python Vector.extend怎么用?Python Vector.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector.Vector
的用法示例。
在下文中一共展示了Vector.extend方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testExtendByNonVector
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import extend [as 别名]
def testExtendByNonVector(self):
vec1 = Vector()
vec2 = Vector()
vec1.extend(["a", "b"])
vec2.append("a")
vec2.append("b")
self.assertEqual(vec1, vec2)
示例2: testExtendEmpty
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import extend [as 别名]
def testExtendEmpty(self):
vec = Vector()
vec.extend(self.bigVec)
self.assertEqual(self.bigVec, vec)
示例3: testExtendEmptyByEmpty
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import extend [as 别名]
def testExtendEmptyByEmpty(self):
vec = Vector()
vec.extend(Vector())
self.assertEqual(vec, Vector())
示例4: VectorTester
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import extend [as 别名]
#.........这里部分代码省略.........
#TESTING METHODS FOR ITERATOR
#--------------------------------------------------------
def testIteratorBigVec(self):
i = 0
for item in self.bigVec:
#make sure the correct values are retrieved
self.assertEquals(i, item)
i += 1
#Make sure the right number of steps took place.
self.assertEqual(i, BIG_VEC_SIZE)
self.assertEqual(self.bigVec, self.cleanBigVec)
def testIteratorBigVecDirectly(self):
i = 0
it = iter(self.bigVec)
for item in it:
self.assertEquals(i, item)
i += 1
self.assertEqual(i, BIG_VEC_SIZE)
self.assertEqual(self.bigVec, self.cleanBigVec)
def testIteratorEmptyVec(self):
for _ in self.emptyVec:
#Should never get here. Raise an exception if we do.
self.assertTrue(False)
#--------------------------------------------------------
#TESTING METHODS FOR EXTEND
#--------------------------------------------------------
def testExtendByEmpty(self):
vec = Vector()
for i in range(BIG_VEC_SIZE):
vec.append(i)
self.bigVec.extend(Vector())
self.assertEqual(self.bigVec, vec)
self.assertEqual(self.bigVec, self.cleanBigVec)
def testExtendEmpty(self):
vec = Vector()
vec.extend(self.bigVec)
self.assertEqual(self.bigVec, vec)
def testExtendEmptyByEmpty(self):
vec = Vector()
vec.extend(Vector())
self.assertEqual(vec, Vector())
def testExtendBySelf(self):
self.assertRaises(NotImplementedError,self.bigVec.extend, self.bigVec )
self.assertEqual(self.bigVec, self.cleanBigVec)
def testExtendGood(self):
vec = Vector()
for i in range(BIG_VEC_SIZE):
vec.append(i)
vec.append(10)
self.bigVec.extend(self.oneVec)
self.assertEqual(self.bigVec, vec)
def testExtendByNonVector(self):
vec1 = Vector()
vec2 = Vector()
vec1.extend(["a", "b"])
vec2.append("a")
vec2.append("b")