'Test that integers below the maximum C{INT} token size cutoff are
serialized as C{INT} or C{NEG} and that larger integers are
serialized as C{LONGINT} or C{LONGNEG}.'

def test_sizedIntegerTypes(self):

    baseIntIn = (+ 2147483647)
    baseNegIn = (-2147483648)
    baseIntOut = '\x7f\x7f\x7f\x07\x81'
    self.assertEqual(self.encode((baseIntIn - 2)), ('}' + baseIntOut))
    self.assertEqual(self.encode((baseIntIn - 1)), ('~' + baseIntOut))
    self.assertEqual(self.encode((baseIntIn - 0)), ('\x7f' + baseIntOut))
    baseLongIntOut = '\x00\x00\x00\x08\x85'
    self.assertEqual(self.encode((baseIntIn + 1)), ('\x00' + baseLongIntOut))
    self.assertEqual(self.encode((baseIntIn + 2)), ('\x01' + baseLongIntOut))
    self.assertEqual(self.encode((baseIntIn + 3)), ('\x02' + baseLongIntOut))
    baseNegOut = '\x7f\x7f\x7f\x07\x83'
    self.assertEqual(self.encode((baseNegIn + 2)), ('~' + baseNegOut))
    self.assertEqual(self.encode((baseNegIn + 1)), ('\x7f' + baseNegOut))
    self.assertEqual(self.encode((baseNegIn + 0)), '\x00\x00\x00\x00\x08\x83')
    baseLongNegOut = '\x00\x00\x00\x08\x86'
    self.assertEqual(self.encode((baseNegIn - 1)), ('\x01' + baseLongNegOut))
    self.assertEqual(self.encode((baseNegIn - 2)), ('\x02' + baseLongNegOut))
    self.assertEqual(self.encode((baseNegIn - 3)), ('\x03' + baseLongNegOut))
