Browse Source

[tests] manually create res2.bin

closes #11139
Simon Krajewski 2 years ago
parent
commit
b9ccde21cb
2 changed files with 24 additions and 22 deletions
  1. BIN
      tests/unit/res2.bin
  2. 24 22
      tests/unit/src/unit/TestResource.hx

BIN
tests/unit/res2.bin


+ 24 - 22
tests/unit/src/unit/TestResource.hx

@@ -1,36 +1,39 @@
 package unit;
 package unit;
 
 
 class TestResource extends Test {
 class TestResource extends Test {
-
 	static var STR = "Héllo World !";
 	static var STR = "Héllo World !";
 
 
 	function testResources() {
 	function testResources() {
 		var names = haxe.Resource.listNames().filter(function(name) return name != "serializedValues.txt");
 		var names = haxe.Resource.listNames().filter(function(name) return name != "serializedValues.txt");
-		eq( names.length, 2 );
-		if( names[0] == "re/s?!%[]))(\"'1.txt" ) {
-			 // redundant, but let's avoid different test numbers
-			eq( names[0], "re/s?!%[]))(\"'1.txt" );
-			eq( names[1], "re/s?!%[]))(\"'1.bin" );
+		eq(names.length, 2);
+		if (names[0] == "re/s?!%[]))(\"'1.txt") {
+			// redundant, but let's avoid different test numbers
+			eq(names[0], "re/s?!%[]))(\"'1.txt");
+			eq(names[1], "re/s?!%[]))(\"'1.bin");
 		} else {
 		} else {
-			eq( names[0], "re/s?!%[]))(\"'1.bin" );
-			eq( names[1], "re/s?!%[]))(\"'1.txt" );
+			eq(names[0], "re/s?!%[]))(\"'1.bin");
+			eq(names[1], "re/s?!%[]))(\"'1.txt");
 		}
 		}
-		eq( haxe.Resource.getString("re/s?!%[]))(\"'1.txt"), STR );
-		#if (neko || php ||  eval)
+		eq(haxe.Resource.getString("re/s?!%[]))(\"'1.txt"), STR);
+		#if (neko || php || eval)
 		// allow binary strings
 		// allow binary strings
-		eq( haxe.Resource.getBytes("re/s?!%[]))(\"'1.bin").sub(0,9).toHex(), "4d5a90000300000004" );
+		eq(haxe.Resource.getBytes("re/s?!%[]))(\"'1.bin").sub(0, 9).toHex(), "48656c6c6f2c204927");
 		#else
 		#else
 		// cut until first \0
 		// cut until first \0
-		eq( haxe.Resource.getString("re/s?!%[]))(\"'1.bin").substr(0,2), "MZ" );
+		eq(haxe.Resource.getString("re/s?!%[]))(\"'1.bin").substr(0, 2), "He");
 		#end
 		#end
-		eq( haxe.Resource.getBytes("re/s?!%[]))(\"'1.txt").compare(haxe.io.Bytes.ofString(STR)), 0 );
+		eq(haxe.Resource.getBytes("re/s?!%[]))(\"'1.txt").compare(haxe.io.Bytes.ofString(STR)), 0);
 		var b = haxe.Resource.getBytes("re/s?!%[]))(\"'1.bin");
 		var b = haxe.Resource.getBytes("re/s?!%[]))(\"'1.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] );
+		var firsts = [
+			0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x2C, 0x20, 0x49, 0x27, 0x6D, 0x20, 0x61, 0x20, 0x62, 0x69, 0x6E, 0x61
+		];
+		var lasts = [
+			0x65, 0x20, 0x79, 0x6F, 0x75, 0x20, 0x6E, 0x65, 0x78, 0x74, 0x20, 0x74, 0x69, 0x6D, 0x65, 0x21, 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]);
 
 
 		eq(haxe.Resource.getString("nope"), null);
 		eq(haxe.Resource.getString("nope"), null);
 		eq(haxe.Resource.getBytes("nope"), null);
 		eq(haxe.Resource.getBytes("nope"), null);
@@ -38,10 +41,10 @@ class TestResource extends Test {
 
 
 	#if neko
 	#if neko
 	static function main() {
 	static function main() {
-		var ch = sys.io.File.write("re/s?!%[]))(\"'1.txt",true);
+		var ch = sys.io.File.write("re/s?!%[]))(\"'1.txt", true);
 		ch.writeString(STR);
 		ch.writeString(STR);
 		ch.close();
 		ch.close();
-		var ch = sys.io.File.write("re/s?!%[]))(\"'1.bin",true);
+		var ch = sys.io.File.write("re/s?!%[]))(\"'1.bin", true);
 		ch.writeString("Héllo");
 		ch.writeString("Héllo");
 		ch.writeByte(0);
 		ch.writeByte(0);
 		ch.writeString("World");
 		ch.writeString("World");
@@ -50,5 +53,4 @@ class TestResource extends Test {
 		ch.close();
 		ch.close();
 	}
 	}
 	#end
 	#end
-
 }
 }