# Path: tests/pfgtest.py
# class TestCase(unittest.TestCase):
#     def assertFormatMatches(self, format_str, data_type, native, memory_le, memory_be):
#         fd = pfg.describe(format_str)
#         self.assertEqual(data_type, fd.data_type)
#         self.assertEqual(native, fd.native)
#         self.assertEqual(memory_le, fd.memory_le)
#         self.assertEqual(memory_be, fd.memory_be)
# 
#     def assertFormatMatchesUnorm(self, format_str, native, memory_le, memory_be):
#         self.assertFormatMatches(format_str, "UNORM", native, memory_le, memory_be)
# 
#     def assertFormatIsUnknown(self, format_str):
#         self.assertIsNone(pfg.describe(format_str))
# 
#     def assertFindCompatibleMatches(self, format_str, family_str,
#                                     everywhere, little_endian, big_endian,
#                                     treat_x_as_a=False,
#                                     treat_srgb_as_unorm=False,
#                                     ignore_data_types=False):
#         compatibility = pfg.find_compatible(
#             format_str, family_str,
#             treat_x_as_a=treat_x_as_a,
#             treat_srgb_as_unorm=treat_srgb_as_unorm,
#             ignore_data_types=ignore_data_types)
#         # assertCountEqual checks for the existence of items regardless
#         # of order (and has a misleading name...)
#         self.assertCountEqual(everywhere, compatibility.everywhere)
#         self.assertCountEqual(little_endian, compatibility.little_endian)
#         self.assertCountEqual(big_endian, compatibility.big_endian)
# 
#     def assertHasDocumentationFor(self, family):
#         documentation = pfg.document(family)
#         self.assertEqual(util.read_documentation(family + ".md"), documentation)
# 
# def R(m,l): return util.component_bits("R", m, l)
# 
# def G(m,l): return util.component_bits("G", m, l)
# 
# def B(m,l): return util.component_bits("B", m, l)
# 
# def A(m,l): return util.component_bits("A", m, l)
# 
# def X(m,l): return util.component_bits("X", m, l)
# 
# def Rn(n,m,l): return util.component_bits("(R+%d)" % n, m, l)
# 
# def Gn(n,m,l): return util.component_bits("(G+%d)" % n, m, l)
# 
# def Bn(n,m,l): return util.component_bits("(B+%d)" % n, m, l)
# 
# def An(n,m,l): return util.component_bits("(A+%d)" % n, m, l)


from .pfgtest import TestCase, R, G, B, A, X, Rn, Gn, Bn, An
# along with pfg. If not, see <http://www.gnu.org/licenses/>.
#
# Authors:
#   Alexandros Frantzis <alexandros.frantzis@collabora.com>


class CairoTest(TestCase):
    def test_32bpp_formats(self):
        self.assertFormatMatchesUnorm(
            format_str = "CAIRO_FORMAT_ARGB32",
            native = A(7, 0) + R(7, 0) + G(7, 0) + B(7, 0),
            memory_le = [B(7, 0), G(7, 0), R(7, 0), A(7, 0)],
            memory_be = [A(7, 0), R(7, 0), G(7, 0), B(7, 0)])

        self.assertFormatMatchesUnorm(
            format_str = "CAIRO_FORMAT_RGB30",
            native = X(1, 0) + R(9, 0) + G(9, 0) + B(9, 0),
            memory_le = [
                B(7, 0),
                G(5, 0) + B(9, 8),
                R(3, 0) + G(9, 6),
                X(1, 0) + R(9, 4)],
            memory_be = [
                X(1, 0) + R(9, 4),
                R(3, 0) + G(9, 6),
                G(5, 0) + B(9, 8),
                B(7, 0)])

        self.assertFormatMatchesUnorm(
            format_str = "CAIRO_FORMAT_RGB24",

# Path: tests/pfgtest.py
# class TestCase(unittest.TestCase):
#     def assertFormatMatches(self, format_str, data_type, native, memory_le, memory_be):
#         fd = pfg.describe(format_str)
#         self.assertEqual(data_type, fd.data_type)
#         self.assertEqual(native, fd.native)
#         self.assertEqual(memory_le, fd.memory_le)
#         self.assertEqual(memory_be, fd.memory_be)
# 
#     def assertFormatMatchesUnorm(self, format_str, native, memory_le, memory_be):
#         self.assertFormatMatches(format_str, "UNORM", native, memory_le, memory_be)
# 
#     def assertFormatIsUnknown(self, format_str):
#         self.assertIsNone(pfg.describe(format_str))
# 
#     def assertFindCompatibleMatches(self, format_str, family_str,
#                                     everywhere, little_endian, big_endian,
#                                     treat_x_as_a=False,
#                                     treat_srgb_as_unorm=False,
#                                     ignore_data_types=False):
#         compatibility = pfg.find_compatible(
#             format_str, family_str,
#             treat_x_as_a=treat_x_as_a,
#             treat_srgb_as_unorm=treat_srgb_as_unorm,
#             ignore_data_types=ignore_data_types)
#         # assertCountEqual checks for the existence of items regardless
#         # of order (and has a misleading name...)
#         self.assertCountEqual(everywhere, compatibility.everywhere)
#         self.assertCountEqual(little_endian, compatibility.little_endian)
#         self.assertCountEqual(big_endian, compatibility.big_endian)
# 
#     def assertHasDocumentationFor(self, family):
#         documentation = pfg.document(family)
#         self.assertEqual(util.read_documentation(family + ".md"), documentation)
# 
# def R(m,l): return util.component_bits("R", m, l)
# 
# def G(m,l): return util.component_bits("G", m, l)
# 
# def B(m,l): return util.component_bits("B", m, l)
# 
# def A(m,l): return util.component_bits("A", m, l)
# 
# def X(m,l): return util.component_bits("X", m, l)
# 
# def Rn(n,m,l): return util.component_bits("(R+%d)" % n, m, l)
# 
# def Gn(n,m,l): return util.component_bits("(G+%d)" % n, m, l)
# 
# def Bn(n,m,l): return util.component_bits("(B+%d)" % n, m, l)
# 
# def An(n,m,l): return util.component_bits("(A+%d)" % n, m, l)


# Path: tests/test_cairo.py
from .pfgtest import TestCase, R, G, B, A, X, Rn, Gn, Bn, An

# along with pfg. If not, see <http://www.gnu.org/licenses/>.
#
# Authors:
#   Alexandros Frantzis <alexandros.frantzis@collabora.com>


class CairoTest(TestCase):
    def test_32bpp_formats(self):
        self.assertFormatMatchesUnorm(
            format_str = "CAIRO_FORMAT_ARGB32",
            native = A(7, 0) + R(7, 0) + G(7, 0) + B(7, 0),
            memory_le = [B(7, 0), G(7, 0), R(7, 0), A(7, 0)],
            memory_be = [A(7, 0), R(7, 0), G(7, 0), B(7, 0)])

        self.assertFormatMatchesUnorm(
            format_str = "CAIRO_FORMAT_RGB30",
            native = X(1, 0) + R(9, 0) + G(9, 0) + B(9, 0),
            memory_le = [
                B(7, 0),
                G(5, 0) + B(9, 8),
                R(3, 0) + G(9, 6),
                X(1, 0) + R(9, 4)],
            memory_be = [
                X(1, 0) + R(9, 4),
                R(3, 0) + G(9, 6),
                G(5, 0) + B(9, 8),
                B(7, 0)])

        self.assertFormatMatchesUnorm(
            format_str = "CAIRO_FORMAT_RGB24",

            native = X(7, 0) + R(7, 0) + G(7, 0) + B(7, 0),