aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/csharp/li_std_vector_runme.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/csharp/li_std_vector_runme.cs')
-rw-r--r--Examples/test-suite/csharp/li_std_vector_runme.cs62
1 files changed, 61 insertions, 1 deletions
diff --git a/Examples/test-suite/csharp/li_std_vector_runme.cs b/Examples/test-suite/csharp/li_std_vector_runme.cs
index fa8700d89..0c6211ca5 100644
--- a/Examples/test-suite/csharp/li_std_vector_runme.cs
+++ b/Examples/test-suite/csharp/li_std_vector_runme.cs
@@ -121,7 +121,7 @@ public class li_std_vector_runme {
throw new Exception("Contains test 4 failed");
{
- // ICollection constructor
+ // IEnumerable constructor
double[] doubleArray = new double[] { 0.0, 11.1, 22.2, 33.3, 44.4, 55.5, 33.3 };
DoubleVector dv = new DoubleVector(doubleArray);
if (doubleArray.Length != dv.Count)
@@ -177,6 +177,17 @@ public class li_std_vector_runme {
if (doubleArray[i] != dvCopy[i])
throw new Exception("Copy constructor failed, index:" + i);
}
+ if (dvCopy.Count != doubleArray.Length)
+ throw new Exception("Copy constructor lengths mismatch");
+
+ // ToArray test
+ double[] dvArray = dv.ToArray();
+ for (int i=0; i<doubleArray.Length; i++) {
+ if (doubleArray[i] != dvArray[i])
+ throw new Exception("ToArray failed, index:" + i);
+ }
+ if (dvArray.Length != doubleArray.Length)
+ throw new Exception("ToArray lengths mismatch");
}
{
// Repeat() test
@@ -619,6 +630,55 @@ public class li_std_vector_runme {
}
}
+ // Test construction
+ {
+ string[] one_two_three = new string[] { "one", "two", "three" };
+
+ // Test construction from array
+ {
+ string[] collection = one_two_three;
+ check123(new StringVector(collection));
+ }
+
+ // Test construction from IEnumerable
+ {
+ global::System.Collections.IEnumerable collection = one_two_three;
+ check123(new StringVector(collection));
+ }
+
+ // Test construction from IEnumerable<>
+ {
+ global::System.Collections.Generic.IEnumerable<string> collection = one_two_three;
+ check123(new StringVector(collection));
+ }
+
+ // Test construction from IList<>
+ {
+ global::System.Collections.Generic.IList<string> collection = one_two_three;
+ check123(new StringVector(collection));
+ }
+
+ // Test construction from ICollection
+ {
+ global::System.Collections.ICollection collection = one_two_three;
+ check123(new StringVector(collection));
+ }
+
+ // Test construction from ICollection<>
+ {
+ global::System.Collections.Generic.ICollection<string> collection = new global::System.Collections.Generic.List<string>(one_two_three);
+ check123(new StringVector(collection));
+ }
+ }
+
+ }
+
+ private static void check123(StringVector stringv) {
+ string concatenated = "";
+ foreach (string s in stringv)
+ concatenated = concatenated + s;
+ if (concatenated != "onetwothree")
+ throw new Exception("concatenated string failed: " + concatenated);
}
}