Example #1
0
    def testGestaltCharOutputProvidesValidInformation(self):
        # This tests Section 2.1 of the Glk spec 0.7.0, ensuring the
        # integrity of the information provided by the CharOutput
        # gestalt.

        for char in range(0, 1000):
            numGlyphs = glk.glui32()
            result = self.glkLib.glk_gestalt_ext(
                glk.gestalt_CharOutput,
                char,
                ctypes.pointer(numGlyphs),
                1
                )

            # Ensure that the result is a valid value.
            if result == glk.gestalt_CharOutput_CannotPrint:
                pass
            elif result == glk.gestalt_CharOutput_ExactPrint:
                # Any character that can be printed exactly should
                # only be one glyph long.
                self.assertEquals(numGlyphs.value, 1)
            elif result == glk.gestalt_CharOutput_ApproxPrint:
                # Any character that can be printed approximately
                # should be at least one glyph long.
                assert numGlyphs.value >= 1
            else:
                raise AssertionError( "result is invalid." )
Example #2
0
    def testGestaltCharOutputProvidesValidInformation(self):
        # This tests Section 2.1 of the Glk spec 0.7.0, ensuring the
        # integrity of the information provided by the CharOutput
        # gestalt.

        for char in range(0, 1000):
            numGlyphs = glk.glui32()
            result = self.glkLib.glk_gestalt_ext(
                glk.gestalt_CharOutput,
                char,
                ctypes.pointer(numGlyphs),
                1
                )

            # Ensure that the result is a valid value.
            if result == glk.gestalt_CharOutput_CannotPrint:
                pass
            elif result == glk.gestalt_CharOutput_ExactPrint:
                # Any character that can be printed exactly should
                # only be one glyph long.
                self.assertEqual(numGlyphs.value, 1)
            elif result == glk.gestalt_CharOutput_ApproxPrint:
                # Any character that can be printed approximately
                # should be at least one glyph long.
                assert numGlyphs.value >= 1
            else:
                raise AssertionError( "result is invalid." )
Example #3
0
    def testGestaltCharOutputReportsProperCharsAreUnprintable(self):
        # This tests Section 2.1 of the Glk spec 0.7.0, ensuring that
        # certain characters are reported to be unprintable.

        unprintableCharacters = (range(0, 10) + range(11, 32) +
                                 range(127, 160) + range(256, 1000))

        for char in unprintableCharacters:
            numGlyphs = glk.glui32()
            result = self.glkLib.glk_gestalt_ext(glk.gestalt_CharOutput, char,
                                                 ctypes.pointer(numGlyphs), 1)

            self.assertEquals(result, glk.gestalt_CharOutput_CannotPrint)
Example #4
0
    def testGestaltCharOutputReportsProperCharsAreUnprintable(self):
        # This tests Section 2.1 of the Glk spec 0.7.0, ensuring that
        # certain characters are reported to be unprintable.

        unprintableCharacters = (range(0, 10) +
                                 range(11, 32) +
                                 range(127, 160) +
                                 range(256, 1000))

        for char in unprintableCharacters:
            numGlyphs = glk.glui32()
            result = self.glkLib.glk_gestalt_ext(
                glk.gestalt_CharOutput,
                char,
                ctypes.pointer(numGlyphs),
                1
                )

            self.assertEquals(result, glk.gestalt_CharOutput_CannotPrint)