Skip to content
Snippets Groups Projects
Commit 651c7394 authored by pfdietz's avatar pfdietz
Browse files

Added tests for MAKE-STRING

parent 652d6b50
No related branches found
No related tags found
No related merge requests found
......@@ -128,4 +128,5 @@
;;; Tests of string comparison functions
(compile-and-load "string-aux.lsp")
(load "string-comparisons.lsp")
(load "make-string.lsp")
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Oct 5 12:32:20 2002
;;;; Contains: Tests for MAKE-STRING
(in-package :cl-test)
(deftest make-string.1
(let ((s (make-string 10)))
(and (stringp s)
(eql (length s) 10)
(string-all-the-same s)))
t)
(deftest make-string.2
(let ((s (make-string 10 :initial-element #\a)))
(and (stringp s)
(eql (length s) 10)
s))
"aaaaaaaaaa")
(deftest make-string.3
(let ((s (make-string 10 :initial-element #\a
:element-type 'character)))
(and (stringp s)
(eql (length s) 10)
s))
"aaaaaaaaaa")
(deftest make-string.4
(let ((s (make-string 10 :initial-element #\a
:element-type 'standard-char)))
(and (stringp s)
(eql (length s) 10)
s))
"aaaaaaaaaa")
(deftest make-string.5
(let ((s (make-string 10 :initial-element #\a
:element-type 'base-char)))
(and (stringp s)
(eql (length s) 10)
s))
"aaaaaaaaaa")
(deftest make-string.6
(make-string 0)
"")
(deftest make-string.7
(let ((s (make-string 10 :element-type 'character)))
(and (stringp s)
(eql (length s) 10)
(string-all-the-same s)))
t)
(deftest make-string.8
(let ((s (make-string 10 :element-type 'standard-char)))
(and (stringp s)
(eql (length s) 10)
(string-all-the-same s)))
t)
(deftest make-string.9
(let ((s (make-string 10 :element-type 'base-char)))
(and (stringp s)
(eql (length s) 10)
(string-all-the-same s)))
t)
......@@ -139,7 +139,14 @@
(and x y (eq comparison '=))))))))
(defun make-random-string (n)
(let ((s (make-string n)))
(let ((s (random-case
(make-string n)
(make-array n :element-type 'character
:initial-element #\a)
(make-array n :element-type 'standard-char
:initial-element #\a)
(make-array n :element-type 'base-char
:initial-element #\a))))
(if (coin)
(dotimes (i n)
(setf (char s i) (elt #(#\a #\b #\A #\B) (random 4))))
......@@ -151,12 +158,8 @@
(random 62)))))))
s))
\ No newline at end of file
(defun string-all-the-same (s)
(let ((len (length s)))
(or (= len 0)
(let ((c (char s 0)))
(loop for d across s always (eql c d))))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment