diff options
Diffstat (limited to 'tests/src/JIT/Generics/Arrays/TypeParameters/Jagged/struct01.cs')
-rw-r--r-- | tests/src/JIT/Generics/Arrays/TypeParameters/Jagged/struct01.cs | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/tests/src/JIT/Generics/Arrays/TypeParameters/Jagged/struct01.cs b/tests/src/JIT/Generics/Arrays/TypeParameters/Jagged/struct01.cs new file mode 100644 index 0000000000..bbbe5ee402 --- /dev/null +++ b/tests/src/JIT/Generics/Arrays/TypeParameters/Jagged/struct01.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + + +public struct ValX1<T> +{ + public T t; + public ValX1(T t) + { + this.t = t; + } + +} +public class RefX1<T> +{ + public T t; + public RefX1(T t) + { + this.t = t; + } +} + + +public struct Gen<T> +{ + public static int size = 10; + + + + public T[][] TArray; + + public void StoreTArray(T[] arr) + { + TArray = new T[size][]; + int i, j; + + for (i = 0; (i < size); i++) + { + TArray[i] = new T[size]; + for (j = 0; (j < size); j++) + { + TArray[i][j] = arr[(i * 10) + j]; + } + } + } + + public void LoadTArray(out T[] arr) + { + arr = new T[size * size]; + int i, j; + for (i = 0; (i < size); i++) + { + for (j = 0; (j < size); j++) + { + arr[(i * 10) + j] = TArray[i][j]; + } + } + } + + public bool VerifyTArray(T[] arr) + { + int i, j; + for (i = 0; (i < size); i++) + { + for (j = 0; (j < size); j++) + { + if (!(arr[(i * 10) + j].Equals(TArray[i][j]))) + { + Console.WriteLine("Failed Verification of Element TArray[{0}][{1}]", i, j); + return false; + } + } + } + return true; + } + +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + int i = 0; + + int[] IntArr_in = new int[100]; + for (i = 0; (i < (10 * 10)); i++) + { + IntArr_in[i] = i; + } + + int[] IntArr_out; + Gen<int> GenInt = new Gen<int>(); + GenInt.StoreTArray(IntArr_in); + GenInt.LoadTArray(out IntArr_out); + Eval(GenInt.VerifyTArray(IntArr_out)); + + double[] DoubleArr_in = new double[100]; + for (i = 0; (i < 10 * 10); i++) + { + DoubleArr_in[i] = i; + } + + double[] DoubleArr_out; + Gen<double> GenDouble = new Gen<double>(); + GenDouble.StoreTArray(DoubleArr_in); + GenDouble.LoadTArray(out DoubleArr_out); + Eval(GenDouble.VerifyTArray(DoubleArr_out)); + + + string[] StringArr_in = new String[100]; + for (i = 0; (i < 10 * 10); i++) + { + StringArr_in[i] = i.ToString(); + } + + String[] StringArr_out; + Gen<String> GenString = new Gen<String>(); + GenString.StoreTArray(StringArr_in); + GenString.LoadTArray(out StringArr_out); + Eval(GenString.VerifyTArray(StringArr_out)); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} + |