view run/sort_05.d @ 54:94d73d5e528e

extended and fixed sort tests
author thomask
date Fri, 22 Oct 2004 05:40:53 +0000
parents 1a7241967792
children ff32878c78da
line wrap: on
line source

// based on a report by:
// @author@	Russ Lewis <spamhole-2001-07-16@deming-os.org>
// @date@	2004-10-11
// @url@	nttp://digitalmars.com/digitalmars.D.bugs:2068
// @uri@	<ckdc4r$re2$1@digitaldaemon.com>

int main(){
	double[10] array;
	array[0]=double.max;
	array[1]=0.875;
	array[2]=0.75;
	array[3]=0.625;
	array[4]=0.5;
	array[5]=0.375;
	array[6]=0.25;
	array[7]=0.125;
	array[8]=0.0;
	array[9]=double.min;

	double[] sorted_copy = array.dup;
	sorted_copy.sort;

	assert(sorted_copy.length==10);
	double test = 0;
	assert(sorted_copy[0]==test);
	test = double.min;
	assert(sorted_copy[1]==test);
	test = 0.125;
	assert(sorted_copy[2]==test);
	test = 0.25;
	assert(sorted_copy[3]==test);
	test = 0.375;
	assert(sorted_copy[4]==test);
	test = 0.5;
	assert(sorted_copy[5]==test);
	test = 0.625;
	assert(sorted_copy[6]==test);
	test = 0.75;
	assert(sorted_copy[7]==test);
	test = 0.875;
	assert(sorted_copy[8]==test);
	test = double.max;
	assert(sorted_copy[9]==test);

	return 0;
}