Browse Source

bigint: make sure bigand is normalized

Josh Stone 7 years ago
parent
commit
3c1c84307c
2 changed files with 3 additions and 0 deletions
  1. 1 0
      bigint/src/biguint.rs
  2. 2 0
      bigint/src/tests/biguint.rs

+ 1 - 0
bigint/src/biguint.rs

@@ -288,6 +288,7 @@ impl<'a> BitAndAssign<&'a BigUint> for BigUint {
             *ai &= bi;
         }
         self.data.truncate(other.data.len());
+        self.normalize();
     }
 }
 

+ 2 - 0
bigint/src/tests/biguint.rs

@@ -203,6 +203,8 @@ const BIT_TESTS: &'static [(&'static [BigDigit],
            &'static [BigDigit],
            &'static [BigDigit])] = &[// LEFT              RIGHT        AND          OR                XOR
                                      (&[], &[], &[], &[], &[]),
+                                     (&[1, 0, 1], &[1, 1], &[1], &[1, 1, 1], &[0, 1, 1]),
+                                     (&[1, 0, 1], &[0, 1, 1], &[0, 0, 1], &[1, 1, 1], &[1, 1]),
                                      (&[268, 482, 17],
                                       &[964, 54],
                                       &[260, 34],