changeset 226:7b556b911877

extended associative array tests
author thomask
date Mon, 03 Jan 2005 17:53:33 +0000
parents a17c5241fa96
children e1af2a603ff4
files nocompile/associative_array_06.d run/associative_array_07.d run/rehash_01.d
diffstat 3 files changed, 60 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nocompile/associative_array_06.d	Mon Jan 03 17:53:33 2005 +0000
@@ -0,0 +1,9 @@
+// void is an illegal KeyType
+
+module dstress.nocompile.associative_array_06;
+
+int main(){
+	int[void] array;
+	return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/associative_array_07.d	Mon Jan 03 17:53:33 2005 +0000
@@ -0,0 +1,7 @@
+module dstress.nocompile.associative_array_07;
+
+int main(){
+	int[void[]] array;
+	return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/rehash_01.d	Mon Jan 03 17:53:33 2005 +0000
@@ -0,0 +1,44 @@
+module dstress.run.rehash_01;
+
+int main(){
+	int[char[]] array;
+	array["eins"]=1;
+	array["zwei"]=2;
+	array["drei"]=3;
+
+	assert(array.length==3);
+	
+	array.rehash;
+
+	char[][] key = array.keys;
+	assert(key.length==3);
+	
+	bool have[3];
+
+	assert(!have[0]);
+	assert(!have[1]);
+	assert(!have[2]);
+
+	foreach(char[] value; key){
+		switch(value){
+			case "eins":{
+				have[0]=true;
+				break;
+			}case "zwei":{
+				have[1]=true;
+				break;
+			}case "drei":{
+				have[2]=true;
+				break;
+			}default:{
+				assert(0);
+			}
+		}
+	}	
+
+	assert(have[0]);
+	assert(have[1]);
+	assert(have[2]);
+
+	return 0;
+}