def testStrOrder(self):
    contents = ["", "a", "aa", "aaa", "aab", "ab", "aba", "abb", "b", "ba",
                "baa", "bab", "bb", "bba", "bbb"]
    contents.sort()

    weights = property_range._get_weights(3)
    previous_ordinal = -1
    for c in contents:
      ordinal = property_range._str_to_ord(c, weights)
      self.assertTrue(previous_ordinal < ordinal)
      previous_ordinal = ordinal
Example #2
0
    def testStrOrder(self):
        contents = [
            "", "a", "aa", "aaa", "aab", "ab", "aba", "abb", "b", "ba", "baa",
            "bab", "bb", "bba", "bbb"
        ]
        contents.sort()

        weights = property_range._get_weights(3)
        previous_ordinal = -1
        for c in contents:
            ordinal = property_range._str_to_ord(c, weights)
            self.assertTrue(previous_ordinal < ordinal)
            previous_ordinal = ordinal
 def testOrdAndStrConversion(self):
   contents = ["abcdefg",
               ",=37   {%",
               string.printable,
               string.ascii_letters,
               string.punctuation,
               # Invisible control chars in hex.
               "\x01\x02\x03"]
   for c in contents:
     weights = property_range._get_weights(len(c))
     self.assertEquals(
         c, property_range._ord_to_str(
             property_range._str_to_ord(c, weights), weights))
Example #4
0
 def testOrdAndStrConversion(self):
     contents = [
         "abcdefg",
         ",=37   {%",
         string.printable,
         string.ascii_letters,
         string.punctuation,
         # Invisible control chars in hex.
         "\x01\x02\x03"
     ]
     for c in contents:
         weights = property_range._get_weights(len(c))
         self.assertEquals(
             c,
             property_range._ord_to_str(
                 property_range._str_to_ord(c, weights), weights))