当前位置: 首页>>代码示例>>Python>>正文


Python data.StrObject类代码示例

本文整理汇总了Python中typhon.objects.data.StrObject的典型用法代码示例。如果您正苦于以下问题:Python StrObject类的具体用法?Python StrObject怎么用?Python StrObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StrObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testSplit

    def testSplit(self):
        """
        Strings can be split.
        """

        s = StrObject(u"first second")
        result = s.call(u"split", [StrObject(u" ")])
        pieces = [obj._s for obj in unwrapList(result)]
        self.assertEqual(pieces, [u"first", u"second"])
开发者ID:markrwilliams,项目名称:typhon,代码行数:9,代码来源:test_data.py

示例2: testContainsTrue

    def testContainsTrue(self):
        """
        String containment tests have true positives.
        """

        haystack = StrObject(u"needle in a haystack")
        needle = StrObject(u"needle")
        result = haystack.call(u"contains", [needle])
        self.assertTrue(result.isTrue())
开发者ID:markrwilliams,项目名称:typhon,代码行数:9,代码来源:test_data.py

示例3: testMakeIterator

    def testMakeIterator(self):
        """
        Strings are iterable.
        """

        s = StrObject(u"cs")
        iterator = s.call(u"_makeIterator", [])
        with Ejector() as ej:
            result = iterator.call(u"next", [ej])
            objs = unwrapList(result)
            self.assertEqual(objs[0].getInt(), 0)
            self.assertEqual(objs[1]._c, u'c')
            result = iterator.call(u"next", [ej])
            objs = unwrapList(result)
            self.assertEqual(objs[0].getInt(), 1)
            self.assertEqual(objs[1]._c, u's')
            self.assertRaises(Ejecting, iterator.call, u"next", [ej])
开发者ID:markrwilliams,项目名称:typhon,代码行数:17,代码来源:test_data.py

示例4: testGet

 def testGet(self):
     s = StrObject(u"index")
     result = s.call(u"get", [IntObject(2)])
     self.assertEqual(result._c, u'd')
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例5: testTrimWord

 def testTrimWord(self):
     s = StrObject(u"  testing  ")
     result = s.call(u"trim", [])
     self.assertEqual(result._s, u"testing")
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例6: testTrimSpaces

 def testTrimSpaces(self):
     s = StrObject(u"    ")
     result = s.call(u"trim", [])
     self.assertEqual(result._s, u"")
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例7: testLastIndexOfFail

 def testLastIndexOfFail(self):
     s = StrObject(u"needle")
     result = s.call(u"lastIndexOf", [StrObject(u"x")])
     self.assertEqual(result.getInt(), -1)
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例8: testIndexOf

 def testIndexOf(self):
     s = StrObject(u"needle")
     result = s.call(u"indexOf", [StrObject(u"e")])
     self.assertEqual(result.getInt(), 1)
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例9: testHashInequal

 def testHashInequal(self):
     a = StrObject(u"acerbic")
     b = StrObject(u"bitter")
     self.assertNotEqual(a.hash(), b.hash())
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例10: testHashEqual

 def testHashEqual(self):
     a = StrObject(u"acidic")
     b = StrObject(u"acidic")
     self.assertEqual(a.hash(), b.hash())
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例11: testToUpperCaseUnicode

 def testToUpperCaseUnicode(self):
     s = StrObject(u"¡Holá!")
     result = s.call(u"toUpperCase", [])
     self.assertEqual(result._s, u"¡HOLÁ!")
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例12: testToUpperCase

 def testToUpperCase(self):
     s = StrObject(u"lower")
     result = s.call(u"toUpperCase", [])
     self.assertEqual(result._s, u"LOWER")
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例13: testToLowerCaseUnicode

 def testToLowerCaseUnicode(self):
     s = StrObject(u"Α And Ω")
     result = s.call(u"toLowerCase", [])
     self.assertEqual(result._s, u"α and ω")
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例14: testSliceStartStop

 def testSliceStartStop(self):
     s = StrObject(u"the lime in the coconut")
     result = s.call(u"slice", [IntObject(4), IntObject(8)])
     self.assertEqual(result._s, u"lime")
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py

示例15: testSliceStart

 def testSliceStart(self):
     s = StrObject(u"slice of lemon")
     result = s.call(u"slice", [IntObject(9)])
     self.assertEqual(result._s, u"lemon")
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_data.py


注:本文中的typhon.objects.data.StrObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。