aboutsummaryrefslogtreecommitdiff
path: root/biginttest.py
diff options
context:
space:
mode:
Diffstat (limited to 'biginttest.py')
-rwxr-xr-xbiginttest.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/biginttest.py b/biginttest.py
index f125953..71c5417 100755
--- a/biginttest.py
+++ b/biginttest.py
@@ -11,7 +11,7 @@ def check(desc,x,y):
def gendata():
for _ in range(ntimes):
- yield random.randint(0,maxn), random.randint(1,maxn)
+ yield random.randint(-maxn,maxn), random.randint(-maxn,maxn)
def proctest():
proc=subprocess.Popen(["./main"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=sys.stderr)
@@ -21,11 +21,12 @@ def proctest():
proc.stdin.write("mod {} {}\n".format(a,b).encode("ascii"))
proc.stdin.flush()
- ans=int(proc.stdout.readline())
- check("{}/{}".format(a,b),ans,a//b)
-
- ans=int(proc.stdout.readline())
- check("{}%{}".format(a,b),ans,a%b)
+ q=int(proc.stdout.readline())
+ r=int(proc.stdout.readline())
+ if r<0 or r>=abs(b) or a!=q*b+r:
+ print("Error: {} divmod {}".format(a,b))
+ print("Diff: {}".format(a-q*b-r))
+ sys.exit(1)
proc.kill()