def test_mcast_sender(self):
        """Unit test for mcast_sender.
        """
        mcgroup = (str(random.randint(224, 239)) + "." +
                   str(random.randint(0, 255)) + "." +
                   str(random.randint(0, 255)) + "." +
                   str(random.randint(0, 255)))
        socket, group = bbmcast.mcast_sender(mcgroup)
        if mcgroup in ("0.0.0.0", "255.255.255.255"):
            self.assertEqual(group, "<broadcast>")
            self.assertEqual(socket.getsockopt(SOL_SOCKET, SO_BROADCAST), 1)
        else:
            self.assertEqual(group, mcgroup)
            self.assertEqual(socket.getsockopt(SOL_SOCKET, SO_BROADCAST), 0)

        socket.close()

        mcgroup = "0.0.0.0"
        socket, group = bbmcast.mcast_sender(mcgroup)
        self.assertEqual(group, "<broadcast>")
        self.assertEqual(socket.getsockopt(SOL_SOCKET, SO_BROADCAST), 1)
        socket.close()

        mcgroup = "255.255.255.255"
        socket, group = bbmcast.mcast_sender(mcgroup)
        self.assertEqual(group, "<broadcast>")
        self.assertEqual(socket.getsockopt(SOL_SOCKET, SO_BROADCAST), 1)
        socket.close()

        mcgroup = (str(random.randint(0, 223)) + "." +
                   str(random.randint(0, 255)) + "." +
                   str(random.randint(0, 255)) + "." +
                   str(random.randint(0, 255)))
        self.assertRaises(IOError, bbmcast.mcast_sender, mcgroup)

        mcgroup = (str(random.randint(240, 255)) + "." +
                   str(random.randint(0, 255)) + "." +
                   str(random.randint(0, 255)) + "." +
                   str(random.randint(0, 255)))
        self.assertRaises(IOError, bbmcast.mcast_sender, mcgroup)