RegressionTests__SortTests.st
author Claus Gittinger <cg@exept.de>
Thu, 14 Apr 2016 19:08:20 +0200
changeset 1393 50384f233a0f
parent 1076 46d4448d98e0
child 1447 2351db93aa5b
child 1499 26a16a04219b
permissions -rw-r--r--
#DOCUMENTATION by cg class: RegressionTests::Win32OLETests changed: #test00_loadOLE

"{ Package: 'exept: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$'
! !