Exemple #1
0
    def test_get(self):
        bitfield = FeaturesBitField(9)
        eq_(bitfield.get(0), False)
        bitfield.set(0, True)
        eq_(bitfield.get(0), True)

        eq_(bitfield.get(8), False)
        bitfield.set(8, True)
        eq_(bitfield.get(8), True)
Exemple #2
0
 def test_basic(self):
     bitfield = FeaturesBitField(8)
     eq_(bitfield.values, [0])
     bitfield = FeaturesBitField(9)
     eq_(bitfield.values, [0, 0])
     bitfield = FeaturesBitField(16)
     eq_(bitfield.values, [0, 0])
     bitfield = FeaturesBitField(53)
     eq_(bitfield.values, [0, 0, 0, 0, 0, 0, 0])
Exemple #3
0
    def test_get(self):
        bitfield = FeaturesBitField(9)
        eq_(bitfield.get(0), False)
        bitfield.set(0, True)
        eq_(bitfield.get(0), True)

        eq_(bitfield.get(8), False)
        bitfield.set(8, True)
        eq_(bitfield.get(8), True)
Exemple #4
0
 def test_set(self):
     bitfield = FeaturesBitField(9)
     bitfield.set(0, True)
     eq_(bitfield.values, [1, 0])
     bitfield.set(1, True)
     eq_(bitfield.values, [3, 0])
     bitfield.set(8, True)
     eq_(bitfield.values, [3, 1])
Exemple #5
0
 def test_set(self):
     bitfield = FeaturesBitField(9)
     bitfield.set(0, True)
     eq_(bitfield.values, [1, 0])
     bitfield.set(1, True)
     eq_(bitfield.values, [3, 0])
     bitfield.set(8, True)
     eq_(bitfield.values, [3, 1])
Exemple #6
0
 def test_from_base64(self):
     bitfield = FeaturesBitField.from_base64('gQE=', len(self.test_data))
     eq_(bitfield.to_list(), self.test_data)
     eq_(bitfield.to_base64(), 'gQE=')
Exemple #7
0
 def test_to_base64(self):
     bitfield = FeaturesBitField.from_list(self.test_data)
     eq_(bitfield.to_base64(), 'gQE=')
Exemple #8
0
 def test_from_list(self):
     bitfield = FeaturesBitField.from_list(self.test_data)
     eq_(bitfield.values, [129, 1])
     eq_(bitfield.to_list(), self.test_data)
Exemple #9
0
 def test_to_list(self):
     bitfield = FeaturesBitField(9)
     bitfield.set(0, True)
     bitfield.set(7, True)
     bitfield.set(8, True)
     eq_(bitfield.to_list(), self.test_data)
Exemple #10
0
 def test_basic_values(self):
     bitfield = FeaturesBitField(8, values=[0, 1, 3])
     eq_(bitfield.values, [0, 1, 3])
Exemple #11
0
 def test_from_base64_full_of_truth(self):
     bitfield = FeaturesBitField.from_base64('/wE=', len(self.test_data))
     eq_(bitfield.to_list(), [True] * 9)
     eq_(bitfield.values, [255, 1])
     eq_(bitfield.to_base64(), '/wE=')
Exemple #12
0
 def test_from_base64(self):
     bitfield = FeaturesBitField.from_base64('gQE=', len(self.test_data))
     eq_(bitfield.to_list(), self.test_data)
     eq_(bitfield.to_base64(), 'gQE=')
Exemple #13
0
 def test_to_base64(self):
     bitfield = FeaturesBitField.from_list(self.test_data)
     eq_(bitfield.to_base64(), 'gQE=')
Exemple #14
0
 def test_from_list(self):
     bitfield = FeaturesBitField.from_list(self.test_data)
     eq_(bitfield.values, [129, 1])
     eq_(bitfield.to_list(), self.test_data)
Exemple #15
0
 def test_to_list(self):
     bitfield = FeaturesBitField(9)
     bitfield.set(0, True)
     bitfield.set(7, True)
     bitfield.set(8, True)
     eq_(bitfield.to_list(), self.test_data)
Exemple #16
0
 def test_from_base64_full_of_truth(self):
     bitfield = FeaturesBitField.from_base64('/wE=', len(self.test_data))
     eq_(bitfield.to_list(), [True] * 9)
     eq_(bitfield.values, [255, 1])
     eq_(bitfield.to_base64(), '/wE=')
Exemple #17
0
 def test_from_base64_full_of_lies(self):
     bitfield = FeaturesBitField.from_base64('AAA=', len(self.test_data))
     eq_(bitfield.to_list(), [False] * 9)
     eq_(bitfield.values, [0, 0])
     eq_(bitfield.to_base64(), 'AAA=')
Exemple #18
0
 def test_from_base64_full_of_lies(self):
     bitfield = FeaturesBitField.from_base64('AAA=', len(self.test_data))
     eq_(bitfield.to_list(), [False] * 9)
     eq_(bitfield.values, [0, 0])
     eq_(bitfield.to_base64(), 'AAA=')