Пример #1
0
 def test_dec_to_bin(self):
     """
     Test Case #1
     Check return type
     """
     result = type(CA.dec_to_bin(8, 4))
     self.assertTrue(result is list)
     """
     Test Case #2
     Check for expected value
     Values are ordinal so they need to be reversed
     """
     result = CA.dec_to_bin(8, 4)
     expected = [1, 0, 0, 0]
     expected = expected[::-1]  # reversed
     self.assertEqual(result, expected)
     """
     Test Case #3
     Check for edge case
     """
     result = CA.dec_to_bin(0, 4)
     expected = [0, 0, 0, 0]
     expected = expected[::-1]  # reversed
     self.assertEqual(result, expected)
     """
     Test Case #3
     Check for edge case
     """
     result = CA.dec_to_bin(15, 4)
     expected = [1, 1, 1, 1]
     expected = expected[::-1]  # reversed
     self.assertEqual(result, expected)
def get_ca_weight_4():
    rule_nums = []
    num_CA = 256
    for i in range(0, 256):
        rule_table = CA.dec_to_bin(i)
        if sum(rule_table) <= len(rule_table) / 2 - 1:
            rule_nums.append(i)
    return rule_nums
def balanced_three_n_CA():
    rule_nums = []
    num_CA = 256
    for i in range(0, 256):
        rule_table = CA.dec_to_bin(i)
        if sum(rule_table) == len(rule_table) / 2:
            rule_nums.append(i)
    return rule_nums