Add bitwise operator tests
@@ -32,3 +32,46 @@ fn test_sequences_comparison() {
let b = PublicByteSeq::from_native_slice(&[1, 2, 3]);
assert_eq!(a, b);
}
+
+#[test]
+fn test_public_not() {
+ let seq = PublicByteSeq::from_hex("c59380b20ba8fcd203e447fd1c5c7b87");
+
+ let not_output = !seq; // output of NOT to be checked for correctness
+ let expected = PublicByteSeq::from_hex("3a6c7f4df457032dfc1bb802e3a38478");
+
+ assert_eq!(expected, not_output);
+}
+
+#[test]
+fn test_public_or() {
+ let seq1 = PublicByteSeq::from_hex("c59380b20ba8fcd203e447fd1c5c7b87");
+ let seq2 = PublicByteSeq::from_hex("3a6c7f4df457032dfc1bb802e3a38478");
+
+ let or_output = seq1 | seq2; // output of OR to be checked for correctness
+ let expected = PublicByteSeq::from_hex("ffffffffffffffffffffffffffffffff");
+
+ assert_eq!(expected, or_output);
+}
+
+#[test]
+fn test_public_xor() {
+ let seq1 = PublicByteSeq::from_hex("3544de28f9d7d48ee7b318f6c541ff35");
+ let seq2 = PublicByteSeq::from_hex("a4b13aa347b72f6c22870170fcb0cda3");
+
+ let xor_output = seq1 ^ seq2; // output of XOR to be checked for correctness
+ let expected = PublicByteSeq::from_hex("91f5e48bbe60fbe2c534198639f13296");
+
+ assert_eq!(expected, xor_output);
+}
+
+#[test]
+fn test_public_and() {
+ let seq1 = PublicByteSeq::from_hex("c59380b20ba8fcd203e447fd1c5c7b87");
+ let seq2 = PublicByteSeq::from_hex("3a6c7f4df457032dfc1bb802e3a38478");
+
+ let and_output = seq1 & seq2; // output of AND to be checked for correctness
+ let expected = PublicByteSeq::from_hex("00000000000000000000000000000000");
+
+ assert_eq!(expected, and_output);
+}
