RegressionTests__SortTests.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 1447 2351db93aa5b
child 1500 d406a10b2965
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding

"{ Package: 'stx:goodies/regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#SortTests
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression-Collections'
!

!SortTests class methodsFor:'documentation'!

documentation
"
    documentation to be added.

    [author:]
	mb (mb@sixtyfour)

    [instance variables:]

    [class variables:]

    [see also:]

"
! !

!SortTests methodsFor:'helpers'!

checkSort:data
     |mergeSorted quickSorted definitivelySorted|

     definitivelySorted := self goodSort:(data copy).

     mergeSorted := data copy mergeSort.
     self assert:(mergeSorted isSorted).
     self assert:(mergeSorted = definitivelySorted).

     quickSorted := data copy quickSort.
     self assert:(quickSorted isSorted).
     self assert:(quickSorted = definitivelySorted).
!

goodSort:data
     |tree|

     tree := BinaryTree withAll:data.
     ^ tree asArray
! !

!SortTests methodsFor:'tests'!

test01_smallArrays
     self checkSort: #(1 16 7 98 3 19 4 0).
     self checkSort: #(1 16 7 98 9 3 19 4 0).

     self checkSort: #(1 16 7 98 7 1 3 19 4 0).
     self checkSort: #(1 16 7 98 7 1 3 19 4 0).
!

test02_largeArrays
     |data|

     data := (1 to:22581) collect:[:i | Random nextInteger] as:Array.

     self checkSort: data.
! !

!SortTests class methodsFor:'documentation'!

version_CVS
    ^ '$Header$'
! !