def attr_key_half_prev_STRUCT(a, v):
    (i, j, k, l) = struct.unpack("!LLLL", v)
    assert (i == j == k == l)
    k = sos.Key(attr=a)
    ii = i - HALF
    _v = struct.pack("!LLLL", ii, ii, ii, ii)
    k.set_value(_v)
    return k
Exemple #2
0
 def test_iter_inf_exact(self):
     for attr in self.schema:
         aid = attr.attr_id()
         itr = sos.AttrIter(attr)
         for data in self.input_data:
             key = sos.Key(attr=attr)
             key.set_value(data[aid])
             self.assertTrue(itr.find_inf(key))
             obj = itr.item()
             self.assertEqual(obj2tuple(obj), data,
                                 msg="bad result attr: %s"%attr.name())
Exemple #3
0
# Add data to test the inf/sup functions
data = [[1, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [4, 7], [4, 8], [4, 9],
        [5, 10], [5, 11], [5, 12]]

for entry in data:
    obj = schema.alloc()
    obj[0] = entry[0]
    obj[1] = entry[1]
    obj.index_add()

tests = TestContext(desc="AttrIter Unit Tests", detail=True)

key_attr = schema.attr_by_name('key')
it = key_attr.attr_iter()
key = Sos.Key(attr=key_attr)

key.set_value(0)
res = it.find(key)
tests.test('if key does not exist, then find(key) returns False',
           (res == False))
o = it.item()
tests.test('if find(key) is False, then it.item() returns None', (o == None))
k = it.key()
tests.test('if find(key) is False, then it.key() returns None', (k == None))

key.set_value(0)
res = it.find_inf(key)
tests.test('if key < min, then find_inf(key) returns False', (res == False))
o = it.item()
tests.test('if find_inf(key) is False, then it.item() returns None',
def attr_key_half_prev_INT32(a, v):
    k = sos.Key(attr=a)
    k.set_value(v - HALF)
    return k
def attr_key_half_next_INT32(a, v):
    k = sos.Key(attr=a)
    k.set_value(v + HALF)
    return k
Exemple #6
0
 def compare_join_split(self, values):
     k = Sos.Key(size=256)
     k.join(*values)
     result = k.split()
     self.assertEqual(values, result)