message: Fix BitField (https://github.com/enso-org/ide/pull/422)
  Original commit:
diff: @@ -49,7 +49,7 @@ impl BitField for BitField256 {
  fn get_bit(&self, bit: usize) -> bool {
  assert!(bit < Self::BIT_LENGTH);
  if bit > 127 { (self.chunks[1] & (1 << (bit - 128))) != 0 }
  - else { (self.chunks[1] & (1 << bit)) != 0 }
  + else { (self.chunks[0] & (1 << bit)) != 0 }
  }
  #[inline]
  @@ -72,3 +72,38 @@ impl Debug for BitField256 {
  write!(f,"BitField256({:0128b}{:0128b})",self.chunks[1],self.chunks[0])
  }
  }
  +
  +
  +
  +#[cfg(test)]
  +mod test {
  + use super::*;
  +
  + #[test]
  + fn getting_and_setting_bits() {
  + let tested_bits = &[0, 10, 127, 128, 255];
  +
  + let mut bit_field = BitField256::default();
  + for bit in tested_bits {
  + assert_eq!(bit_field.get_bit(*bit), false);
  + }
  +
  + // Set bits one by one
  + for (i,bit) in tested_bits.iter().enumerate() {
  + bit_field.set_bit(*bit, true);
  + for (j,bit) in tested_bits.iter().enumerate() {
  + let should_be_set = j <= i;
  + assert_eq!(bit_field.get_bit(*bit), should_be_set);
  + }
  + }
  +
  + // Unsetting bits one by one
  + for (i,bit) in tested_bits.iter().enumerate() {
  + bit_field.set_bit(*bit, false);
  + for (j,bit) in tested_bits.iter().enumerate() {
  + let should_be_set = j > i;
  + assert_eq!(bit_field.get_bit(*bit), should_be_set);
  + }
  + }
  + }
  +}
  