Browse Source

larger binary resource

Nicolas Cannasse 17 years ago
parent
commit
490fe2c06b
2 changed files with 9 additions and 7 deletions
  1. 9 7
      tests/unit/TestResource.hx
  2. BIN
      tests/unit/res2.bin

+ 9 - 7
tests/unit/TestResource.hx

@@ -5,10 +5,6 @@ class TestResource extends Test {
 	static var STR = "Héllo World !";
 
 	function testResources() {
-		var b = haxe.io.Bytes.ofString("Héllo World    !");
-		for( i in 0...b.length )
-			if( b.get(i) == " ".charCodeAt(0) )
-				b.set(i,0);
 		var names = haxe.Resource.listNames();
 		eq( names.length, 2 );
 		if( names[0] == "res1.txt" )
@@ -20,13 +16,19 @@ class TestResource extends Test {
 		eq( haxe.Resource.getString("res1.txt"), STR );
 		#if (neko || php)
 		// allow binary strings
-		eq( haxe.Resource.getString("res2.bin"), "Héllo\000World\000\000\000\000!" );
+		eq( haxe.Resource.getBytes("res2.bin").sub(0,9).toString(), "MZ\x90\x00\x03\x00\x00\x00\x04" );
 		#else
 		// cut until first \0
-		eq( haxe.Resource.getString("res2.bin"), "Héllo" );
+		eq( haxe.Resource.getString("res2.bin").substr(0,2), "MZ" );
 		#end
 		eq( haxe.Resource.getBytes("res1.txt").compare(haxe.io.Bytes.ofString(STR)), 0 );
-		eq( haxe.Resource.getBytes("res2.bin").compare(b), 0 );
+		var b = haxe.Resource.getBytes("res2.bin");
+		var firsts = [0x4D,0x5A,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xB8];
+		var lasts = [0xD6,0x52,0x03,0x1A,0x2C,0x4E,0x45,0x4B,0x4F,0x00,0x1C,0x00,0x00];
+		for( i in 0...firsts.length )
+			eq( b.get(i), firsts[i]);
+		for( i in 0...lasts.length )
+			eq( b.get(b.length - lasts.length + i), lasts[i] );
 	}
 
 	#if neko

BIN
tests/unit/res2.bin