-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcj-cmp-test.scm
44 lines (36 loc) · 1.09 KB
/
cj-cmp-test.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
;;; Copyright 2019 by Christian Jaeger <ch@christianjaeger.ch>
;;; This file is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License (GPL) as published
;;; by the Free Software Foundation, either version 2 of the License, or
;;; (at your option) any later version.
(require easy
cj-cmp
test-logic
test-random)
(include "cj-standarddeclares.scm")
(define (old-@string-cmp v1 v2)
(cond ((string<? v1 v2)
'lt)
((string<? v2 v1)
'gt)
(else
'eq)))
(define (old-char-cmp a b)
(if (char=? a b)
'eq
(if (char>? a b)
'gt
'lt)))
(TEST
> (repeat 10000
init: (short-random-string)
(let ((s0 res)
(s1 (short-random-string)))
(assert (eq? (string-cmp s0 s1)
(old-@string-cmp s0 s1)))
s1))
> (repeat 1000
(let ((v0 (random-char))
(v1 (random-char)))
(assert (eq? (char-cmp v0 v1)
(old-char-cmp v0 v1))))))