Przeglądaj źródła

add bytes test to make sure that bytesdata has call-by-reference semantics

frabbit 10 lat temu
rodzic
commit
f280bbb06f
1 zmienionych plików z 11 dodań i 0 usunięć
  1. 11 0
      tests/unit/src/unit/TestBytes.hx

+ 11 - 0
tests/unit/src/unit/TestBytes.hx

@@ -126,4 +126,15 @@ class TestBytes extends Test {
 		eq(fget(bd3, 0), 0xC3);
 		eq(fget(bd3, 1), 0xA9);
 	}
+
+	function testBytesDataEquality () {
+		var b1 = haxe.io.Bytes.ofString("AB");
+		var x = b1.getData();
+		var b2 = haxe.io.Bytes.ofData(x);
+
+		b2.set(0, "C".code);
+
+		eq(b1.getString(0,2), b2.getString(0,2));
+
+	}
 }