srfi-95-check.scm 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Marcus Crestani
  3. ;;; Test suite for SRFI-95
  4. (define-test-suite srfi-95-tests)
  5. (define list-unsorted (list 2 32 42 23 1 2 74 3 65))
  6. (define list-sorted (list 1 2 2 3 23 32 42 65 74))
  7. (define list-sorted-1 (list 32 42 65 74))
  8. (define list-sorted-2 (list 1 2 2 3 23))
  9. (define list-< <)
  10. (define vector-unsorted (list->vector list-unsorted))
  11. (define vector-sorted (list->vector list-sorted))
  12. (define vector-sorted-1 (list->vector list-sorted-1))
  13. (define vector-sorted-2 (list->vector list-sorted-2))
  14. (define vector-< <)
  15. (define array-unsorted (list->array 1 '#() list-unsorted))
  16. (define array-sorted (list->array 1 '#() list-sorted))
  17. (define array-< <)
  18. (define-test-case sorted? srfi-95-tests
  19. (check (sorted? list-sorted list-<))
  20. (check (not (sorted? list-unsorted list-<)))
  21. (check (sorted? vector-sorted vector-<))
  22. (check (not (sorted? vector-unsorted vector-<)))
  23. (check (sorted? array-sorted array-<))
  24. (check (not (sorted? array-unsorted array-<))))
  25. (define-test-case sort srfi-95-tests
  26. (check (sort list-sorted list-<) => list-sorted)
  27. (check (sort list-unsorted list-<) => list-sorted)
  28. (check (sort vector-sorted vector-<) => vector-sorted)
  29. (check (sort vector-unsorted vector-<) => vector-sorted)
  30. (check (array->vector (sort array-sorted array-<))
  31. => (array->vector array-sorted))
  32. (check (array->vector (sort array-unsorted array-<))
  33. => (array->vector array-sorted)))
  34. (define-test-case sort! srfi-95-tests
  35. (check (sort! list-sorted list-<) => list-sorted)
  36. (check (sort! list-unsorted list-<) => list-sorted)
  37. (check (sort! vector-sorted vector-<) => vector-sorted)
  38. (check (sort! vector-unsorted vector-<) => vector-sorted)
  39. (check (array->vector (sort! array-sorted array-<))
  40. => (array->vector array-sorted))
  41. (check (array->vector (sort! array-unsorted array-<))
  42. => (array->vector array-sorted)))
  43. (define-test-case merge srfi-95-tests
  44. (check (merge list-sorted-1 list-sorted-2 list-<) => list-sorted)
  45. (check (merge list-sorted-2 list-sorted-1 list-<) => list-sorted)
  46. (check (merge vector-sorted-1 vector-sorted-2 vector-<) => vector-sorted)
  47. (check (merge vector-sorted-2 vector-sorted-1 vector-<) => vector-sorted))
  48. (define-test-case merge! srfi-95-tests
  49. (check (merge! list-sorted-1 list-sorted-2 list-<) => list-sorted)
  50. (check (merge! vector-sorted-1 vector-sorted-2 vector-<) => vector-sorted))