File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ class Native
1818 new tests. TestNativeEnum (),
1919
2020 #if (haxe_ver>=5)
21+ new tests. TestScratch (),
22+
2123 new tests.marshalling.classes. TestLocalValueType (),
2224 new tests.marshalling.classes. TestClassValueType (),
2325 new tests.marshalling.classes. TestInterfaceValueType (),
Original file line number Diff line number Diff line change 1+ package tests ;
2+
3+ import cpp .Scratch ;
4+ import utest .Test ;
5+ import utest .Assert ;
6+
7+ using haxe .Int64 ;
8+
9+ class TestScratch extends Test {
10+ function test_zeroed_small_alloc () {
11+ final size = 16 ;
12+ final alloc = Scratch .alloc (size );
13+
14+ Assert .equals (size , alloc .view .length .toInt ());
15+
16+ for (i in 0 ... size .toInt ()) {
17+ Assert .equals (0 , alloc .view [i ]);
18+ }
19+ }
20+
21+ function test_zeroed_large_alloc () {
22+ final size = 100_000 ;
23+ final alloc = Scratch .alloc (size );
24+
25+ Assert .equals (size , alloc .view .length .toInt ());
26+
27+ for (i in 0 ... size .toInt ()) {
28+ Assert .equals (0 , alloc .view [i ]);
29+ }
30+ }
31+
32+ function test_contents_wiped () {
33+ {
34+ final size = 16 ;
35+ final alloc = Scratch .alloc (size );
36+
37+ Assert .equals (size , alloc .view .length .toInt ());
38+
39+ alloc .view .fill (7 );
40+ }
41+
42+ {
43+ final size = 16 ;
44+ final alloc = Scratch .alloc (size );
45+
46+ Assert .equals (size , alloc .view .length .toInt ());
47+
48+ for (i in 0 ... size .toInt ()) {
49+ Assert .equals (0 , alloc .view [i ]);
50+ }
51+ }
52+ }
53+ }
You can’t perform that action at this time.
0 commit comments