more Int tests

This commit is contained in:
Paul Bailey 2020-08-27 16:50:06 -05:00
parent 56614630e7
commit 26adbf8be1

View File

@ -1,4 +1,5 @@
from ..scalars import Scalar, Int, BigInt from ..scalars import Scalar, Int, BigInt
from graphql.language.ast import IntValueNode
def test_scalar(): def test_scalar():
@ -11,10 +12,18 @@ def test_scalar():
def test_ints(): def test_ints():
assert Int.parse_value(2 ** 31 - 1) is not None assert Int.parse_value(2 ** 31 - 1) is not None
assert Int.parse_value("2.0") is not None
assert Int.parse_value(2 ** 31) is None assert Int.parse_value(2 ** 31) is None
assert Int.parse_literal(IntValueNode(value=str(2 ** 31 - 1))) == 2 ** 31 - 1
assert Int.parse_literal(IntValueNode(value=str(2 ** 31))) is None
assert Int.parse_value(-(2 ** 31)) is not None assert Int.parse_value(-(2 ** 31)) is not None
assert Int.parse_value(-(2 ** 31) - 1) is None assert Int.parse_value(-(2 ** 31) - 1) is None
assert BigInt.parse_value(2 ** 31) is not None assert BigInt.parse_value(2 ** 31) is not None
assert BigInt.parse_value("2.0") is not None
assert BigInt.parse_value(-(2 ** 31) - 1) is not None assert BigInt.parse_value(-(2 ** 31) - 1) is not None
assert BigInt.parse_literal(IntValueNode(value=str(2 ** 31 - 1))) == 2 ** 31 - 1
assert BigInt.parse_literal(IntValueNode(value=str(2 ** 31))) == 2 ** 31