Skip to content

Commit 2566127

Browse files
authored
Merge pull request #523 from alrun3/memoryextensions-contains
feat: add `MemoryExtensions.Contains`
2 parents d35693d + ce6c2c6 commit 2566127

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

CSharp.lua/CoreSystem.Lua/CoreSystem/MemoryExtensions.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616

1717
local System = System
1818
local Span = System.Span
19+
local Array = System.Array
1920

2021
System.MemoryExtensions = {
2122
AsSpan = function (array)
@@ -25,5 +26,8 @@ System.MemoryExtensions = {
2526
AsBoundedSpan = function (array, start, length)
2627
local SpanT = Span(array.__genericT__)
2728
return SpanT(array, start, length)
29+
end,
30+
Contains = function (span, value)
31+
return Array.Contains(span._array, value)
2832
end
2933
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Bridge.Test.NUnit;
2+
using System;
3+
4+
namespace Bridge.ClientTest
5+
{
6+
[Category(Constants.MODULE_ARRAY)]
7+
[TestFixture(TestNameFormat = "MemoryExtensions - {0}")]
8+
public class MemoryExtensionsTests
9+
{
10+
[Test]
11+
public void ContainsWorks()
12+
{
13+
var arr = new string[] { "x", "y" };
14+
Assert.True(MemoryExtensions.Contains(arr, "x"));
15+
Assert.False(MemoryExtensions.Contains(arr, "z"));
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)