From 69d9ad9ab7bb5f7963ca41bdef04d1dbc0246ae8 Mon Sep 17 00:00:00 2001 From: Spencer Walden Date: Thu, 30 Mar 2023 23:51:43 -0700 Subject: [PATCH] Adds a few more tests to the BitwiseOp to test some XOR functionality --- tests/operations/tests/BitwiseOp.mjs | 46 ++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/tests/operations/tests/BitwiseOp.mjs b/tests/operations/tests/BitwiseOp.mjs index 50303677..b8716aeb 100644 --- a/tests/operations/tests/BitwiseOp.mjs +++ b/tests/operations/tests/BitwiseOp.mjs @@ -10,7 +10,7 @@ import TestRegister from "../../lib/TestRegister.mjs"; TestRegister.addTests([ { name: "Bit shift left", - input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100", + input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100", expectedOutput: "10101010 01010100 11111110 00000000 11100000 00011110 01100110 10011000", recipeConfig: [ { "op": "From Binary", @@ -23,7 +23,7 @@ TestRegister.addTests([ }, { name: "Bit shift right: Logical shift", - input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100", + input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100", expectedOutput: "00101010 01010101 01111111 00000000 01111000 00000111 00011001 01100110", recipeConfig: [ { "op": "From Binary", @@ -36,7 +36,7 @@ TestRegister.addTests([ }, { name: "Bit shift right: Arithmetic shift", - input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100", + input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100", expectedOutput: "00101010 11010101 11111111 00000000 11111000 00000111 00011001 11100110", recipeConfig: [ { "op": "From Binary", @@ -47,4 +47,44 @@ TestRegister.addTests([ "args": ["Space"] } ] }, + { + name: "XOR: empty", + input: "", + expectedOutput: "", + recipeConfig: [ + { "op": "From Binary", + "args": ["Space"] }, + { "op": "XOR", + "args": ["binary", "11111111", "Standard", false] }, + { "op": "To Binary", + "args": ["Space"] } + ] + }, + { + name: "XOR: 1111111, standard, no preserve nulls", + input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100", + expectedOutput: "10101010 01010101 00000000 11111111 00001111 11110000 11001100 00110011", + recipeConfig: [ + { "op": "From Binary", + "args": ["Space"] }, + { "op": "XOR", + "args": ["binary", "11111111", "Standard", false] }, + { "op": "To Binary", + "args": ["Space"] } + ] + }, + { + name: "XOR: 1111111, standard, preserve nulls", + input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100", + // Should the ones be kept as ones? Seems like it's not a null that we're preserving... + expectedOutput: "10101010 01010101 11111111 00000000 00001111 11110000 11001100 00110011", + recipeConfig: [ + { "op": "From Binary", + "args": ["Space"] }, + { "op": "XOR", + "args": ["binary", "11111111", "Standard", true] }, + { "op": "To Binary", + "args": ["Space"] } + ] + }, ]);