changeset 54:94d73d5e528e

extended and fixed sort tests
author thomask
date Fri, 22 Oct 2004 05:40:53 +0000
parents 5f0e612a804b
children 75472ba72120
files run/sort_02.d run/sort_03.d run/sort_04.d run/sort_05.d run/sort_06.d run/sort_07.d run/sort_08.d run/sort_09.d run/sort_10.d run/sort_11.d run/sort_12.d
diffstat 11 files changed, 312 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/run/sort_02.d	Fri Oct 22 05:40:17 2004 +0000
+++ b/run/sort_02.d	Fri Oct 22 05:40:53 2004 +0000
@@ -1,27 +1,33 @@
 int main(){
 	byte a[];
-	a.length=5;
+	a.length=7;
 	a[0]=byte.max;
-	a[1]=3;
-	a[2]=0;
-	a[3]=2;
-	a[4]=byte.max;
+	a[1]=byte.max-1;
+	a[2]=1;
+	a[3]=0;
+	a[4]=-1;
+	a[5]=byte.min;
+	a[6]=byte.min+1;
 
 	byte[] b=a.sort;
 
-	assert(a.length==5);
+	assert(a.length==7);
 	assert(a[0]==byte.min);
-	assert(a[1]==0);
-	assert(a[2]==2);
-	assert(a[3]==3);
-	assert(a[4]==byte.max);
+	assert(a[1]==byte.min+1);
+	assert(a[2]==-1);
+	assert(a[3]==0);
+	assert(a[4]==1);
+	assert(a[5]==byte.max-1);
+	assert(a[6]==byte.max);
 
-	assert(b.length==5);
+	assert(b.length==7);
 	assert(b[0]==byte.min);
-	assert(b[1]==0);
-	assert(b[2]==2);
-	assert(b[3]==3);
-	assert(b[4]==byte.max);
+	assert(b[1]==byte.min+1);
+	assert(b[2]==-1);
+	assert(b[3]==0);
+	assert(b[4]==1);
+	assert(b[5]==byte.max-1);
+	assert(b[6]==byte.max);
 
 	return 0;
 }
--- a/run/sort_03.d	Fri Oct 22 05:40:17 2004 +0000
+++ b/run/sort_03.d	Fri Oct 22 05:40:53 2004 +0000
@@ -21,16 +21,26 @@
 	sorted_copy.sort;
 
 	assert(sorted_copy.length==10);
-	assert(sorted_copy[0]==real.min);
-	assert(sorted_copy[1]==0.0);
-	assert(sorted_copy[2]==0.125);
-	assert(sorted_copy[3]==0.25);
-	assert(sorted_copy[4]==0.375);
-	assert(sorted_copy[5]==0.5);
-	assert(sorted_copy[6]==0.625);
-	assert(sorted_copy[7]==0.75);
-	assert(sorted_copy[8]==0.875);
-	assert(sorted_copy[9]==real.max);
+	real test = 0.0;
+	assert(sorted_copy[0]==test);
+	test = real.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 = real.max;
+	assert(sorted_copy[9]==test);
 
 	return 0;
 }
--- a/run/sort_04.d	Fri Oct 22 05:40:17 2004 +0000
+++ b/run/sort_04.d	Fri Oct 22 05:40:53 2004 +0000
@@ -21,16 +21,26 @@
 	sorted_copy.sort;
 
 	assert(sorted_copy.length==10);
-	assert(sorted_copy[0]==float.min);
-	assert(sorted_copy[1]==0.0);
-	assert(sorted_copy[2]==0.125);
-	assert(sorted_copy[3]==0.25);
-	assert(sorted_copy[4]==0.375);
-	assert(sorted_copy[5]==0.5);
-	assert(sorted_copy[6]==0.625);
-	assert(sorted_copy[7]==0.75);
-	assert(sorted_copy[8]==0.875);
-	assert(sorted_copy[9]==float.max);
+	float test = 0;
+	assert(sorted_copy[0]==test);
+	test = float.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 = float.max;
+	assert(sorted_copy[9]==test);
 
 	return 0;
 }
--- a/run/sort_05.d	Fri Oct 22 05:40:17 2004 +0000
+++ b/run/sort_05.d	Fri Oct 22 05:40:53 2004 +0000
@@ -21,16 +21,26 @@
 	sorted_copy.sort;
 
 	assert(sorted_copy.length==10);
-	assert(sorted_copy[0]==double.min);
-	assert(sorted_copy[1]==0.0);
-	assert(sorted_copy[2]==0.125);
-	assert(sorted_copy[3]==0.25);
-	assert(sorted_copy[4]==0.375);
-	assert(sorted_copy[5]==0.5);
-	assert(sorted_copy[6]==0.625);
-	assert(sorted_copy[7]==0.75);
-	assert(sorted_copy[8]==0.875);
-	assert(sorted_copy[9]==double.max);
+	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;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/sort_06.d	Fri Oct 22 05:40:53 2004 +0000
@@ -0,0 +1,33 @@
+int main(){
+	ubyte a[];
+	a.length=7;
+	a[0]=ubyte.max;
+	a[1]=ubyte.max-1;
+	a[2]=2;
+	a[3]=0;
+	a[4]=1;
+	a[5]=ubyte.min;
+	a[6]=ubyte.min+1;
+
+	ubyte[] b=a.sort;
+
+	assert(a.length==7);
+	assert(a[0]==0);
+	assert(a[1]==ubyte.min);
+	assert(a[2]==ubyte.min+1);
+	assert(a[3]==1);
+	assert(a[4]==2);
+	assert(a[5]==ubyte.max-1);
+	assert(a[6]==ubyte.max);
+
+	assert(b.length==7);
+	assert(b[0]==0);
+	assert(b[1]==ubyte.min);
+	assert(b[2]==ubyte.min+1);
+	assert(b[3]==1);
+	assert(b[4]==2);
+	assert(b[5]==ubyte.max-1);
+	assert(b[6]==ubyte.max);
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/sort_07.d	Fri Oct 22 05:40:53 2004 +0000
@@ -0,0 +1,33 @@
+int main(){
+	short a[];
+	a.length=7;
+	a[0]=short.max;
+	a[1]=short.max-1;
+	a[2]=1;
+	a[3]=0;
+	a[4]=-1;
+	a[5]=short.min;
+	a[6]=short.min+1;
+
+	short[] b=a.sort;
+
+	assert(a.length==7);
+	assert(a[0]==short.min);
+	assert(a[1]==short.min+1);
+	assert(a[2]==-1);
+	assert(a[3]==0);
+	assert(a[4]==1);
+	assert(a[5]==short.max-1);
+	assert(a[6]==short.max);
+
+	assert(b.length==7);
+	assert(b[0]==short.min);
+	assert(b[1]==short.min+1);
+	assert(b[2]==-1);
+	assert(b[3]==0);
+	assert(b[4]==1);
+	assert(b[5]==short.max-1);
+	assert(b[6]==short.max);
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/sort_08.d	Fri Oct 22 05:40:53 2004 +0000
@@ -0,0 +1,33 @@
+int main(){
+	int a[];
+	a.length=7;
+	a[0]=int.max;
+	a[1]=int.max-1;
+	a[2]=1;
+	a[3]=0;
+	a[4]=-1;
+	a[5]=int.min;
+	a[6]=int.min+1;
+
+	int[] b=a.sort;
+
+	assert(a.length==7);
+	assert(a[0]==int.min);
+	assert(a[1]==int.min+1);
+	assert(a[2]==-1);
+	assert(a[3]==0);
+	assert(a[4]==1);
+	assert(a[5]==int.max-1);
+	assert(a[6]==int.max);
+
+	assert(b.length==7);
+	assert(b[0]==int.min);
+	assert(b[1]==int.min+1);
+	assert(b[2]==-1);
+	assert(b[3]==0);
+	assert(b[4]==1);
+	assert(b[5]==int.max-1);
+	assert(b[6]==int.max);
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/sort_09.d	Fri Oct 22 05:40:53 2004 +0000
@@ -0,0 +1,33 @@
+int main(){
+	long a[];
+	a.length=7;
+	a[0]=long.max;
+	a[1]=long.max-1;
+	a[2]=1;
+	a[3]=0;
+	a[4]=-1;
+	a[5]=long.min;
+	a[6]=long.min+1;
+
+	long[] b=a.sort;
+
+	assert(a.length==7);
+	assert(a[0]==long.min);
+	assert(a[1]==long.min+1);
+	assert(a[2]==-1);
+	assert(a[3]==0);
+	assert(a[4]==1);
+	assert(a[5]==long.max-1);
+	assert(a[6]==long.max);
+
+	assert(b.length==7);
+	assert(b[0]==long.min);
+	assert(b[1]==long.min+1);
+	assert(b[2]==-1);
+	assert(b[3]==0);
+	assert(b[4]==1);
+	assert(b[5]==long.max-1);
+	assert(b[6]==long.max);
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/sort_10.d	Fri Oct 22 05:40:53 2004 +0000
@@ -0,0 +1,33 @@
+int main(){
+	ushort a[];
+	a.length=7;
+	a[0]=ushort.max;
+	a[1]=ushort.max-1;
+	a[2]=2;
+	a[3]=0;
+	a[4]=1;
+	a[5]=ushort.min;
+	a[6]=ushort.min+1;
+
+	ushort[] b=a.sort;
+
+	assert(a.length==7);
+	assert(a[0]==0);
+	assert(a[1]==ushort.min);
+	assert(a[2]==ushort.min+1);
+	assert(a[3]==1);
+	assert(a[4]==2);
+	assert(a[5]==ushort.max-1);
+	assert(a[6]==ushort.max);
+
+	assert(b.length==7);
+	assert(b[0]==0);
+	assert(b[1]==ushort.min);
+	assert(b[2]==ushort.min+1);
+	assert(b[3]==1);
+	assert(b[4]==2);
+	assert(b[5]==ushort.max-1);
+	assert(b[6]==ushort.max);
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/sort_11.d	Fri Oct 22 05:40:53 2004 +0000
@@ -0,0 +1,33 @@
+int main(){
+	uint a[];
+	a.length=7;
+	a[0]=uint.max;
+	a[1]=uint.max-1;
+	a[2]=2;
+	a[3]=0;
+	a[4]=1;
+	a[5]=uint.min;
+	a[6]=uint.min+1;
+
+	uint[] b=a.sort;
+
+	assert(a.length==7);
+	assert(a[0]==0);
+	assert(a[1]==uint.min);
+	assert(a[2]==uint.min+1);
+	assert(a[3]==1);
+	assert(a[4]==2);
+	assert(a[5]==uint.max-1);
+	assert(a[6]==uint.max);
+
+	assert(b.length==7);
+	assert(b[0]==0);
+	assert(b[1]==uint.min);
+	assert(b[2]==uint.min+1);
+	assert(b[3]==1);
+	assert(b[4]==2);
+	assert(b[5]==uint.max-1);
+	assert(b[6]==uint.max);
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/sort_12.d	Fri Oct 22 05:40:53 2004 +0000
@@ -0,0 +1,33 @@
+int main(){
+	ulong a[];
+	a.length=7;
+	a[0]=ulong.max;
+	a[1]=ulong.max-1;
+	a[2]=2;
+	a[3]=0;
+	a[4]=1;
+	a[5]=ulong.min;
+	a[6]=ulong.min+1;
+
+	ulong[] b=a.sort;
+
+	assert(a.length==7);
+	assert(a[0]==0);
+	assert(a[1]==ulong.min);
+	assert(a[2]==ulong.min+1);
+	assert(a[3]==1);
+	assert(a[4]==2);
+	assert(a[5]==ulong.max-1);
+	assert(a[6]==ulong.max);
+
+	assert(b.length==7);
+	assert(b[0]==0);
+	assert(b[1]==ulong.min);
+	assert(b[2]==ulong.min+1);
+	assert(b[3]==1);
+	assert(b[4]==2);
+	assert(b[5]==ulong.max-1);
+	assert(b[6]==ulong.max);
+
+	return 0;
+}