Browse Source

Altered tests to account for additional container argument in love.data.hash

EngineerSmith 1 year ago
parent
commit
666fd88631
1 changed files with 26 additions and 12 deletions
  1. 26 12
      testing/tests/data.lua

+ 26 - 12
testing/tests/data.lua

@@ -196,19 +196,33 @@ end
 -- love.data.hash
 love.test.data.hash = function(test)
   -- setup all the different hashing types
-  local str1 = love.data.hash('md5', 'helloworld')
-  local str2 = love.data.hash('sha1', 'helloworld')
-  local str3 = love.data.hash('sha224', 'helloworld')
-  local str4 = love.data.hash('sha256', 'helloworld')
-  local str5 = love.data.hash('sha384', 'helloworld')
-  local str6 = love.data.hash('sha512', 'helloworld')
+  local str1 = love.data.hash('string', 'md5', 'helloworld')
+  local str2 = love.data.hash('string', 'sha1', 'helloworld')
+  local str3 = love.data.hash('string', 'sha224', 'helloworld')
+  local str4 = love.data.hash('string', 'sha256', 'helloworld')
+  local str5 = love.data.hash('string', 'sha384', 'helloworld')
+  local str6 = love.data.hash('string', 'sha512', 'helloworld')
+  local data1 = love.data.hash('data', 'md5', 'helloworld')
+  local data2 = love.data.hash('data', 'sha1', 'helloworld')
+  local data3 = love.data.hash('data', 'sha224', 'helloworld')
+  local data4 = love.data.hash('data', 'sha256', 'helloworld')
+  local data5 = love.data.hash('data', 'sha384', 'helloworld')
+  local data6 = love.data.hash('data', 'sha512', 'helloworld')
   -- check encoded hash value matches what's expected for that algo
-  test:assertEquals('fc5e038d38a57032085441e7fe7010b0', love.data.encode("string", "hex", str1), 'check md5 encode')
-  test:assertEquals('6adfb183a4a2c94a2f92dab5ade762a47889a5a1', love.data.encode("string", "hex", str2), 'check sha1 encode')
-  test:assertEquals('b033d770602994efa135c5248af300d81567ad5b59cec4bccbf15bcc', love.data.encode("string", "hex", str3), 'check sha224 encode')
-  test:assertEquals('936a185caaa266bb9cbe981e9e05cb78cd732b0b3280eb944412bb6f8f8f07af', love.data.encode("string", "hex", str4), 'check sha256 encode')
-  test:assertEquals('97982a5b1414b9078103a1c008c4e3526c27b41cdbcf80790560a40f2a9bf2ed4427ab1428789915ed4b3dc07c454bd9', love.data.encode("string", "hex", str5), 'check sha384 encode')
-  test:assertEquals('1594244d52f2d8c12b142bb61f47bc2eaf503d6d9ca8480cae9fcf112f66e4967dc5e8fa98285e36db8af1b8ffa8b84cb15e0fbcf836c3deb803c13f37659a60', love.data.encode("string", "hex", str6), 'check sha512 encode')
+    -- test container string
+  test:assertEquals('fc5e038d38a57032085441e7fe7010b0', love.data.encode("string", "hex", str1), 'check md5 encode container string')
+  test:assertEquals('6adfb183a4a2c94a2f92dab5ade762a47889a5a1', love.data.encode("string", "hex", str2), 'check sha1 encode  container string')
+  test:assertEquals('b033d770602994efa135c5248af300d81567ad5b59cec4bccbf15bcc', love.data.encode("string", "hex", str3), 'check sha224 encode container string')
+  test:assertEquals('936a185caaa266bb9cbe981e9e05cb78cd732b0b3280eb944412bb6f8f8f07af', love.data.encode("string", "hex", str4), 'check sha256 encode container string')
+  test:assertEquals('97982a5b1414b9078103a1c008c4e3526c27b41cdbcf80790560a40f2a9bf2ed4427ab1428789915ed4b3dc07c454bd9', love.data.encode("string", "hex", str5), 'check sha384 encode container string')
+  test:assertEquals('1594244d52f2d8c12b142bb61f47bc2eaf503d6d9ca8480cae9fcf112f66e4967dc5e8fa98285e36db8af1b8ffa8b84cb15e0fbcf836c3deb803c13f37659a60', love.data.encode("string", "hex", str6), 'check sha512 encode container string')
+    -- test container data
+  test:assertEquals('fc5e038d38a57032085441e7fe7010b0', love.data.encode("string", "hex", data1), 'check md5 encode container data')
+  test:assertEquals('6adfb183a4a2c94a2f92dab5ade762a47889a5a1', love.data.encode("string", "hex", data2), 'check sha1 encode container data')
+  test:assertEquals('b033d770602994efa135c5248af300d81567ad5b59cec4bccbf15bcc', love.data.encode("string", "hex", data3), 'check sha224 encode container data')
+  test:assertEquals('936a185caaa266bb9cbe981e9e05cb78cd732b0b3280eb944412bb6f8f8f07af', love.data.encode("string", "hex", data4), 'check sha256 encode container data')
+  test:assertEquals('97982a5b1414b9078103a1c008c4e3526c27b41cdbcf80790560a40f2a9bf2ed4427ab1428789915ed4b3dc07c454bd9', love.data.encode("string", "hex", data5), 'check sha384 encode container data')
+  test:assertEquals('1594244d52f2d8c12b142bb61f47bc2eaf503d6d9ca8480cae9fcf112f66e4967dc5e8fa98285e36db8af1b8ffa8b84cb15e0fbcf836c3deb803c13f37659a60', love.data.encode("string", "hex", data6), 'check sha512 encode container data')
 end