@@ -37,6 +37,8 @@ def func_returnnull():
3737 return None
3838def func_returnblob ():
3939 return b"blob"
40+ def func_returnlonglong ():
41+ return 1 << 31
4042def func_raiseexception ():
4143 5 / 0
4244
@@ -50,6 +52,8 @@ def func_isnone(v):
5052 return type (v ) is type (None )
5153def func_isblob (v ):
5254 return isinstance (v , (bytes , memoryview ))
55+ def func_islonglong (v ):
56+ return isinstance (v , int ) and v >= 1 << 31
5357
5458class AggrNoStep :
5559 def __init__ (self ):
@@ -127,13 +131,15 @@ def setUp(self):
127131 self .con .create_function ("returnfloat" , 0 , func_returnfloat )
128132 self .con .create_function ("returnnull" , 0 , func_returnnull )
129133 self .con .create_function ("returnblob" , 0 , func_returnblob )
134+ self .con .create_function ("returnlonglong" , 0 , func_returnlonglong )
130135 self .con .create_function ("raiseexception" , 0 , func_raiseexception )
131136
132137 self .con .create_function ("isstring" , 1 , func_isstring )
133138 self .con .create_function ("isint" , 1 , func_isint )
134139 self .con .create_function ("isfloat" , 1 , func_isfloat )
135140 self .con .create_function ("isnone" , 1 , func_isnone )
136141 self .con .create_function ("isblob" , 1 , func_isblob )
142+ self .con .create_function ("islonglong" , 1 , func_islonglong )
137143
138144 def tearDown (self ):
139145 self .con .close ()
@@ -200,6 +206,12 @@ def CheckFuncReturnBlob(self):
200206 self .assertEqual (type (val ), bytes )
201207 self .assertEqual (val , b"blob" )
202208
209+ def CheckFuncReturnLongLong (self ):
210+ cur = self .con .cursor ()
211+ cur .execute ("select returnlonglong()" )
212+ val = cur .fetchone ()[0 ]
213+ self .assertEqual (val , 1 << 31 )
214+
203215 def CheckFuncException (self ):
204216 cur = self .con .cursor ()
205217 try :
@@ -239,6 +251,12 @@ def CheckParamBlob(self):
239251 val = cur .fetchone ()[0 ]
240252 self .assertEqual (val , 1 )
241253
254+ def CheckParamLongLong (self ):
255+ cur = self .con .cursor ()
256+ cur .execute ("select islonglong(?)" , (1 << 42 ,))
257+ val = cur .fetchone ()[0 ]
258+ self .assertEqual (val , 1 )
259+
242260class AggregateTests (unittest .TestCase ):
243261 def setUp (self ):
244262 self .con = sqlite .connect (":memory:" )
0 commit comments