mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
More tests
This commit is contained in:
parent
0cbe2376ec
commit
455a0d0b46
1 changed files with 26 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
|
@ -120,5 +121,30 @@ namespace Tests
|
|||
float totals = GetSum(fVals);
|
||||
Test.Assert(totals == 10+20+30+40+50);
|
||||
}
|
||||
|
||||
public static mixin TransformArray<Input, Output, InputSize>(Input[InputSize] array, delegate void(Input, ref Output) predicate) where InputSize : const int where Output : new
|
||||
{
|
||||
Output[2] output = default;
|
||||
for (int i = 0; i < array.Count; i++)
|
||||
{
|
||||
output[i] = scope:mixin Output();
|
||||
predicate(array[i], ref output[i]);
|
||||
}
|
||||
output
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestSizedArrays()
|
||||
{
|
||||
int[2] arr = .(2, 4);
|
||||
|
||||
delegate void(int, ref String) toString = scope (i, str) => { i.ToString(str); };
|
||||
|
||||
List<String[2]> l2 = scope .();
|
||||
l2.Add(TransformArray!(arr, toString));
|
||||
|
||||
Test.Assert(l2.Front[0] == "2");
|
||||
Test.Assert(l2.Front[1] == "4");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue