def test_generate_single_bits_arguments(self): rng = random.Random(0) args = sample_generator.generate_arguments( (BitsType(signed=False, size=42),), rng) self.assertLen(args, 1) self.assertTrue(args[0].is_ubits()) self.assertEqual(args[0].get_bit_count(), 42)
def test_generate_tuple_argument(self): rng = random.Random(0) args = sample_generator.generate_arguments((TupleType((BitsType( signed=False, size=123), BitsType(signed=True, size=22))), ), rng) self.assertLen(args, 1) self.assertTrue(args[0].is_tuple()) self.assertEqual(args[0].tuple_members[0].get_bit_count(), 123) self.assertEqual(args[0].tuple_members[1].get_bit_count(), 22)
def test_generate_array_argument(self): rng = random.Random(0) args = sample_generator.generate_arguments( (ArrayType(BitsType(signed=True, size=4), 24),), rng) self.assertLen(args, 1) self.assertTrue(args[0].is_array()) self.assertLen(args[0].array_payload.elements, 24) self.assertTrue(args[0].array_payload.index(0).is_sbits()) self.assertTrue(args[0].array_payload.index(0).get_bit_count(), 4)
def test_generate_mixed_bits_arguments(self): rng = random.Random(0) args = sample_generator.generate_arguments( (BitsType(signed=False, size=123), BitsType(signed=True, size=22)), rng) self.assertLen(args, 2) self.assertTrue(args[0].is_ubits()) self.assertEqual(args[0].get_bit_count(), 123) self.assertTrue(args[1].is_sbits()) self.assertEqual(args[1].get_bit_count(), 22)
def test_generate_empty_arguments(self): rng = random.Random(0) self.assertEqual(sample_generator.generate_arguments((), rng), ())