Skip to content

Commit c1ee88a

Browse files
committed
puerts.gen_iterator测试
1 parent 9ed1c5e commit c1ee88a

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#if !UNITY_WEBGL && !UNITY_IOS && !UNITY_ANDROID || FORCE_TEST_PYTHON
2+
using System;
3+
using System.Collections.Generic;
4+
using NUnit.Framework;
5+
6+
namespace Puerts.UnitTest
7+
{
8+
[TestFixture]
9+
public class GenIteratorTestPython
10+
{
11+
[Test]
12+
public void GenIteratorTest()
13+
{
14+
var pythonEnv = new ScriptEnv(new BackendPython());
15+
16+
pythonEnv.Eval(@"
17+
exec('''
18+
from System.Collections.Generic import List__T1
19+
from System import Int32
20+
List__Int32 = List__T1[Int32]
21+
myList = List__Int32()
22+
myList.Add(1)
23+
myList.Add(2)
24+
myList.Add(3)
25+
iter = puerts.gen_iterator(myList)
26+
result = []
27+
for i in iter:
28+
result.append(i)
29+
assert result == [1, 2, 3]
30+
''')
31+
");
32+
33+
pythonEnv.Dispose();
34+
}
35+
}
36+
}
37+
38+
#endif

unity/test/Src/Cases/Python/GenIteratorTest.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)