mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-29 19:15:55 -05:00
60 lines
954 B
Haxe
60 lines
954 B
Haxe
|
package funkin.util.tools;
|
||
|
|
||
|
import massive.munit.util.Timer;
|
||
|
import massive.munit.Assert;
|
||
|
import massive.munit.async.AsyncFactory;
|
||
|
import funkin.util.tools.IteratorTools;
|
||
|
|
||
|
@:access(funkin.util.tools.IteratorTools)
|
||
|
class IteratorToolsTest extends FunkinTest
|
||
|
{
|
||
|
public function new()
|
||
|
{
|
||
|
super();
|
||
|
}
|
||
|
|
||
|
@BeforeClass
|
||
|
public function beforeClass() {}
|
||
|
|
||
|
@AfterClass
|
||
|
public function afterClass() {}
|
||
|
|
||
|
@Before
|
||
|
public function setup() {}
|
||
|
|
||
|
@After
|
||
|
public function tearDown() {}
|
||
|
|
||
|
@Test
|
||
|
public function testArray()
|
||
|
{
|
||
|
var iter = new MyStringIterator("HelloWorld");
|
||
|
|
||
|
var arr = IteratorTools.array(iter);
|
||
|
|
||
|
Assert.areEqual(["H", "e", "l", "l", "o", "W", "o", "r", "l", "d"], arr);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class MyStringIterator
|
||
|
{
|
||
|
var s:String;
|
||
|
var i:Int;
|
||
|
|
||
|
public function new(s:String)
|
||
|
{
|
||
|
this.s = s;
|
||
|
i = 0;
|
||
|
}
|
||
|
|
||
|
public function hasNext()
|
||
|
{
|
||
|
return i < s.length;
|
||
|
}
|
||
|
|
||
|
public function next()
|
||
|
{
|
||
|
return s.charAt(i++);
|
||
|
}
|
||
|
}
|