Exemple #1
0
    def test_write_bad_value(self):
        """
        Test that an Exception is raised when the Boolean write operation fails
        on a bad boolean value.
        """
        stream = BytearrayStream()
        boolean = Boolean()
        boolean.value = 'invalid'

        self.assertRaises(Exception, boolean.write, stream)
Exemple #2
0
    def test_read_false(self):
        """
        Test that a Boolean object representing the value False can be read
        from a byte stream.
        """
        encoding = (b'\x42\x00\x00\x06\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00'
                    b'\x00\x00')
        stream = BytearrayStream(encoding)
        boolean = Boolean()

        boolean.read(stream)

        self.assertFalse(boolean.value)
Exemple #3
0
    def test_write_false(self):
        """
        Test that a Boolean object representing the value False can be written
        to a byte stream.
        """
        encoding = (b'\x42\x00\x00\x06\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00'
                    b'\x00\x00')
        stream = BytearrayStream()
        boolean = Boolean(False)

        boolean.write(stream)

        self.assertEqual(encoding, stream.read())
Exemple #4
0
 def test_validate_on_valid_unset(self):
     """
     Test that a Boolean object with no preset value can be validated.
     """
     boolean = Boolean()
     boolean.validate()
Exemple #5
0
 def test_validate_on_valid(self):
     """
     Test that a Boolean object can be validated on good input.
     """
     boolean = Boolean(True)
     boolean.validate()