Ver Fonte

[cpp] fixed Lib.stringReference (closes #8457)

Aleksandr Kuzmenko há 4 anos atrás
pai
commit
67ab67cfb8
2 ficheiros alterados com 13 adições e 1 exclusões
  1. 1 1
      std/cpp/Lib.hx
  2. 12 0
      tests/unit/src/unit/issues/Issue8457.hx

+ 1 - 1
std/cpp/Lib.hx

@@ -88,7 +88,7 @@ class Lib {
 
 	public static function stringReference(inBytes:haxe.io.Bytes):String {
 		var result:String = "";
-		untyped __global__.__hxcpp_string_of_bytes(inBytes.b, result, 0, 0, true);
+		untyped __global__.__hxcpp_string_of_bytes(inBytes.b, result, 0, inBytes.length, true);
 		return result;
 	}
 

+ 12 - 0
tests/unit/src/unit/issues/Issue8457.hx

@@ -0,0 +1,12 @@
+package unit.issues;
+
+class Issue8457 extends unit.Test {
+#if cpp
+	function test() {
+		var content = 'Hello world, testing, 1, 2, 3...';
+		var bytes = haxe.io.Bytes.ofString(content);
+		var s = cpp.Lib.stringReference(bytes);
+		eq(content, s);
+	}
+#end
+}