Skip to content

Commit f52af1e

Browse files
committed
refactored tests
1 parent eed9175 commit f52af1e

File tree

1 file changed

+32
-12
lines changed
  • tests/unit-tests/Tests/ReadOnlySpan/Linq

1 file changed

+32
-12
lines changed
Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,46 @@
11
namespace SpanExtensions.Tests.UnitTests
22
{
3-
public static partial class ReadOnlySpanLinqTests
3+
public class LinqMaxTests
44
{
55
[Theory]
66
[MemberData(nameof(GetMaxData))]
7-
public static void Max(int[] source, int max)
7+
public void Max(int[] source, int max)
88
{
9-
Assert.Equal(max, source.AsSpan().Max());
9+
ReadOnlySpan<int> span = source.AsSpan();
10+
Assert.Equal(max, span.Max());
1011
}
1112

1213
public static TheoryData<int[], int> GetMaxData()
1314
{
14-
return new TheoryData<int[], int>()
15+
var data = new TheoryData<int[], int>();
16+
17+
var Samples10 = GetSampleSetInts(10);
18+
var Samples100 = GetSampleSetInts(100);
19+
var Samples1000 = GetSampleSetInts(1000);
20+
21+
int max10 = Samples10.Max();
22+
int max100 = Samples100.Max();
23+
int max1000 = Samples1000.Max();
24+
25+
data.Add(Samples10, max10);
26+
data.Add(Samples100, max100);
27+
data.Add(Samples1000, max1000);
28+
29+
return data;
30+
}
31+
32+
static int[] GetSampleSetInts(int count)
33+
{
34+
Random random = new Random(count);
35+
36+
int[] sample = new int[count];
37+
38+
for(int i = 0; i < count; i++)
1539
{
16-
{ new int[] { 2935, 6975, 8649, 1984, 5604, 1805, 2501, 9472, 3486, 3799 }, 9472 },
17-
{ new int[] { 7262, 8173, 7680, 5581, 2060, 5588, 9060, 4421, 9775, 2737, 2919, 4673, 6326, 4695, 9821, 303, 8623, 9953, 6771, 3145, 8169, 8480, 9919, 326,
18-
6999, 5262, 9340, 6876, 5468, 811, 1871, 4533, 2971, 9885, 6426, 7629, 303, 3810, 3431, 9574, 5051, 7159, 1189, 2734, 9070, 7947, 3371, 4572, 1468,
19-
2213, 4100, 7187, 6198, 4879, 1949, 8781, 8254, 7353, 8582, 6797, 6248, 2184, 8953, 8964, 865, 8385, 1701, 6441, 8268, 2191, 9999, 4813, 6522, 7197,
20-
8094, 1009, 7290, 7184, 1255, 9051, 1891, 4768, 5407, 3255, 6710, 4683, 8334, 8092, 7936, 7645, 9375, 2949, 5227, 6633, 3325, 2867, 8206, 2225, 1868,
21-
685 }, 9999 },
22-
{ new int[] { 3832, 8712, 6609, 522, 3664, 6761, 424, 9539, 8435, 8549, 4490, 9323, 4448, 1112, 8819, 4020, 8048, 3353, 8666, 250, 7470, 5654, 1749, 4780, 3859, 285, 9523, 248, 4803, 7186, 7713, 2971, 1120, 1640, 869, 663, 8288, 1514, 5419, 9320, 8790, 6607, 1239, 655, 5977, 9592, 7187, 5668, 8306, 1465, 2233, 8736, 7071, 9140, 5965, 8178, 6963, 1828, 6662, 3378, 7237, 175, 4736, 1249, 835, 1518, 8202, 2807, 243, 8156, 5731, 6533, 7934, 9345, 1460, 862, 4414, 1093, 8802, 4267, 3098, 3855, 1941, 3338, 4952, 8977, 5900, 1979, 5675, 2691, 3700, 6459, 4852, 2040, 2082, 8614, 1870, 9990, 9820, 4459, 1389, 4379, 5425, 150, 5733, 5699, 801, 7725, 7680, 5102, 3763, 5869, 3025, 2395, 280, 3382, 8233, 1398, 6296, 1858, 5618, 6222, 7132, 7552, 4456, 9272, 1681, 5894, 7263, 2845, 8991, 4423, 1273, 4343, 2877, 8719, 8429, 1791, 7604, 9253, 8175, 8175, 4299, 572, 8927, 7830, 3433, 2456, 1760, 8699, 380, 472, 3694, 7961, 8841, 5166, 7246, 7873, 5694, 6460, 4017, 4907, 462, 4834, 6110, 9340, 4596, 8682, 9517, 1560, 4953, 6442, 3793, 7042, 3683, 7442, 1923, 6560, 8624, 6625, 5838, 9224, 4133, 8563, 2464, 8519, 729, 3311, 5502, 7710, 1472, 556, 6096, 1143, 5235, 3267, 7712, 9464, 4461, 9587, 3233, 4751, 2938, 199, 3746, 3938, 6678, 6651, 4278, 1398, 3243, 686, 9248, 9068, 622, 4792, 774, 1898, 2369, 7591, 8610, 1284, 3179, 1806, 88, 4396, 345, 2649, 1806, 415, 9730, 2458, 2098, 9037, 3392, 1087, 6285, 3934, 4816, 8525, 1841, 4078, 9033, 4104, 4467, 785, 1308, 7028, 521, 443, 2493, 5813, 7095, 6870, 977, 1949, 1572, 1132, 111, 9350, 3593, 4028, 4844, 3862, 1667, 784, 8588, 211, 5676, 9534, 8506, 6839, 7082, 3843, 5749, 4531, 2251, 9074, 7339, 9302, 3087, 3316, 2128, 1363, 7922, 3916, 5363, 5227, 8060, 1442, 9514, 5153, 3823, 5465, 4932, 7812, 9234, 5170, 2436, 3682, 2197, 1097, 1351, 986, 1936, 5653, 8731, 3251, 1120, 6445, 9697, 2498, 3792, 808, 6262, 276, 1900, 3480, 5940, 7751, 5421, 3361, 2150, 4233, 20, 3352, 3016, 1616, 8911, 7937, 5297, 7080, 6637, 3656, 7105, 1990, 1965, 1141, 9427, 2268, 5184, 2112, 4106, 1614, 1745, 7016, 1360, 3014, 9203, 4655, 5912, 5753, 9229, 4685, 8261, 8836, 8946, 7118, 966, 8583, 2637, 7115, 4339, 3183, 1147, 2616, 5860, 136, 3703, 4272, 8311, 758, 4052, 3672, 2567, 3309, 9254, 535, 2488, 3003, 1991, 1, 2413, 4256, 2024, 9543, 7850, 1952, 5395, 8268, 3044, 4847, 175, 843, 9631, 8069, 7773, 922, 467, 9128, 1156, 1224, 9311, 4931, 6343, 5154, 1701, 5557, 2117, 4952, 9581, 8410, 4629, 7963, 6591, 2635, 4701, 82, 1159, 1604, 4766, 3908, 4741, 5434, 1227, 3464, 582, 3208, 4040, 4497, 5535, 8331, 68, 3360, 1846, 767, 690, 7481, 7912, 6870, 7842, 2293, 9834, 443, 8686, 4633, 217, 2211, 4252, 6995, 3367, 7690, 9763, 8862, 4362, 7247, 6483, 3876, 3703, 2878, 4571, 8492, 1517, 7620, 9416, 1250, 8341, 1268, 6116, 5824, 1945, 7220, 2170, 4289, 3762, 2472, 4074, 4297, 6747, 6594, 3247, 8371, 8956, 7044, 1130, 7845, 8567, 1206, 8998, 4599, 4283, 6813, 3778, 5033, 2298, 9350, 776, 2214, 1026, 7436, 6292, 8948, 6095, 8428, 5050, 6147, 5520, 5474, 5100, 1889, 3173, 2185, 7128, 7108, 9631, 6200, 9535, 4472, 6490, 1570, 2682, 7135, 2270, 1517, 1540, 5131, 3441, 7136, 1990, 4411, 1696, 1859, 3270, 9310, 302, 4298, 2275, 528, 1994, 4982, 2325, 3093, 6105, 7109, 1425, 2098, 9684, 6669, 5402, 6098, 9814, 6303, 5724, 9456, 4754, 9156, 6678, 4578, 6888, 9918, 2706, 8384, 3483, 688, 192, 1313, 8914, 7817, 6806, 5333, 3924, 9007, 2477, 1507, 9245, 9588, 1029, 5161, 91, 9442, 5447, 6771, 1733, 5892, 4597, 5392, 6135, 3814, 4556, 1145, 7620, 7697, 3640, 2075, 2276, 3941, 9609, 5417, 6916, 111, 3183, 1866, 9863, 68, 2173, 806, 3825, 4216, 211, 5165, 8127, 1517, 4486, 7445, 4471, 5934, 6650, 7591, 6090, 4799, 5177, 5100, 3261, 5661, 7713, 6227, 5367, 402, 9230, 5303, 9978, 5612, 8244, 9980, 6258, 3580, 6908, 1664, 3719, 3791, 1567, 1919, 3603, 9390, 3017, 6102, 3211, 6194, 7604, 6342, 7290, 2018, 9326, 2117, 4933, 8083, 8605, 4201, 2355, 5945, 5438, 3423, 4986, 4907, 5186, 2515, 3272, 4506, 1187, 890, 9025, 4985, 3871, 2299, 3232, 3258, 1497, 3870, 2643, 1610, 3016, 9173, 2797, 2888, 8012, 7960, 6285, 6127, 5046, 8175, 4975, 2706, 9309, 7773, 8352, 8143, 6933, 8695, 4203, 502, 2829, 8705, 5006, 6713, 7316, 2305, 8147, 7026, 8884, 1675, 6586, 4734, 1558, 745, 2929, 6265, 626, 2097, 6894, 7226, 6229, 7145, 9459, 3011, 5915, 6318, 5675, 6097, 3947, 5088, 6325, 2801, 9667, 2140, 8780, 4311, 4166, 6083, 5571, 5707, 9813, 9259, 7242, 3370, 1589, 241, 1148, 8564, 4844, 2087, 7517, 4835, 1800, 6977, 4273, 5684, 9245, 1995, 798, 998, 6629, 2049, 3079, 3796, 5349, 3784, 5067, 9417, 1964, 8618, 2098, 4542, 6526, 1187, 7413, 6970, 9902, 6088, 1422, 5673, 5169, 7111, 1253, 1860, 7570, 1489, 1001, 2690, 7867, 3096, 5066, 2171, 5284, 4573, 9077, 7763, 6179, 3446, 8020, 7805, 5174, 1731, 6599, 6226, 9988, 2975, 8309, 612, 9563, 7303, 5781, 3156, 572, 5125, 5828, 9518, 796, 1219, 6225, 3860, 2782, 2376, 1550, 8868, 3552, 9927, 9257, 1952, 2110, 9649, 790, 6456, 8067, 3617, 499, 3438, 511, 5027, 1871, 4595, 3180, 388, 3126, 564, 7314, 1909, 1598, 159, 8745, 9559, 6967, 4960, 7221, 4160, 5022, 2797, 181, 7731, 2673, 61, 3717, 6356, 8502, 9913, 6512, 9324, 5088, 6955, 4625, 2389, 9006, 5768, 9347, 1629, 679, 2393, 9250, 986, 1554, 1642, 8328, 9098, 3207, 2550, 2681, 5829, 9235, 3907, 8595, 7702, 3257, 2780, 2353, 1809, 878, 6824, 1886, 3212, 4051, 7989, 6821, 4643, 5534, 6355, 552, 1199, 5613, 5591, 3481, 2628, 3547, 9194, 6177, 1031, 1733, 4619, 3149, 5951, 7232, 683, 89, 1181, 8360, 6923, 9131, 6226, 3415, 7537, 751, 3855, 507, 6037, 6934, 3564, 4820, 3685, 3563, 6851, 1997, 1482, 216, 3643, 425, 5966, 4154, 4062, 6602, 1321, 76, 6258, 3674, 5934, 5980, 3368, 7899, 5640, 6283, 8611, 7224, 4326, 7783, 8075, 4840, 9625, 2121, 7509, 2260, 2612, 6210, 8048, 1055, 6297, 3954, 5749, 466, 6445, 755, 2393, 2768, 5069, 9623, 2093, 7460, 4492, 180, 4572, 57, 3566, 5664, 9179, 7402, 4952, 9627, 7671, 3699, 2140, 8803, 800, 3845, 6645 }, 9990 }
23-
};
40+
sample[i] = random.Next();
41+
}
42+
43+
return sample;
2444
}
2545
}
2646
}

0 commit comments

Comments
 (0)