diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/common/bitfield.py | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/tests/common/bitfield.py b/tests/common/bitfield.py index 717181c..e014111 100644 --- a/tests/common/bitfield.py +++ b/tests/common/bitfield.py @@ -1,21 +1,15 @@ -#!/usr/bin/python3-dbg -# -*- coding: utf-8 -*- - - -# Tests pour valider la manipulation des champs de bits. - from chrysacase import ChrysalideTestCase -from pychrysalide.common import bitfield +from pychrysalide.common import BitField -class TestBitfields(ChrysalideTestCase): - """TestCase for common.bitfield*""" +class TestBitFields(ChrysalideTestCase): + """TestCase for common.BitField*""" - def testDuplicateBitfield(self): + def testDuplicateBitField(self): """Check duplicated bitfield value.""" - bf = bitfield(10, 0) + bf = BitField(10, 0) bf2 = bf.dup() @@ -26,40 +20,40 @@ class TestBitfields(ChrysalideTestCase): self.assertEqual(bf.popcount, bf2.popcount) - def testBitfieldValues(self): + def testBitFieldValues(self): """Evaluate bitfields basic values.""" - bf_a = bitfield(75, 1) + bf_a = BitField(75, 1) - bf_b = bitfield(75, 0) + bf_b = BitField(75, 0) self.assertNotEqual(bf_a, bf_b) - bf_a = bitfield(75, 1) + bf_a = BitField(75, 1) - bf_b = bitfield(75, 0) + bf_b = BitField(75, 0) bf_b.set_all() self.assertEqual(bf_a, bf_b) self.assertEqual(bf_a.popcount, bf_b.popcount) - bf_a = bitfield(75, 1) + bf_a = BitField(75, 1) bf_a.reset_all() - bf_b = bitfield(75, 0) + bf_b = BitField(75, 0) self.assertEqual(bf_a, bf_b) self.assertEqual(bf_a.popcount, bf_b.popcount) - def testBitfieldLogicalOperations(self): + def testBitFieldLogicalOperations(self): """Perform logical operations on bitfields.""" - bf_a = bitfield(75, 1) + bf_a = BitField(75, 1) - bf_b = bitfield(75, 0) + bf_b = BitField(75, 0) self.assertEqual(bf_a.size, bf_b.size) @@ -76,14 +70,14 @@ class TestBitfields(ChrysalideTestCase): self.assertEqual(bf_f.popcount, bf_a.popcount) - def testBitfieldSwitch(self): + def testBitFieldSwitch(self): """Switch various bits in bitfields.""" - bf_1 = bitfield(75, 1) + bf_1 = BitField(75, 1) - bf_0 = bitfield(75, 0) + bf_0 = BitField(75, 0) - bf_t = bitfield(75, 0) + bf_t = BitField(75, 0) for i in range(75): bf_t.set(i, 1) @@ -100,10 +94,10 @@ class TestBitfields(ChrysalideTestCase): self.assertEqual(bf_t.popcount, bf_0.popcount) - def testBitfieldBits(self): + def testBitFieldBits(self): """Test bits in bitfields.""" - bf = bitfield(54, 1) + bf = BitField(54, 1) self.assertTrue(bf.test(0)) @@ -113,7 +107,7 @@ class TestBitfields(ChrysalideTestCase): self.assertFalse(bf.test_none(0, 54)) - bf = bitfield(54, 0) + bf = BitField(54, 0) self.assertFalse(bf.test(0)) @@ -124,23 +118,23 @@ class TestBitfields(ChrysalideTestCase): self.assertTrue(bf.test_none(0, 54)) - def testPopCountForBitfield(self): + def testPopCountForBitField(self): """Count bits set to 1 in bitfield.""" - bf = bitfield(65, 1) + bf = BitField(65, 1) self.assertEqual(bf.size, 65) self.assertEqual(bf.popcount, 65) - def testBitfieldComparison(self): + def testBitFieldComparison(self): """Check bitfield comparison.""" - bf_a = bitfield(9, 0) + bf_a = BitField(9, 0) bf_a.set(0, 1) bf_a.set(5, 1) - bf_b = bitfield(9, 1) + bf_b = BitField(9, 1) self.assertNotEqual(bf_a, bf_b) |