1 use super::*; 2 3 #[test] 4 fn test_fixed_big_int_set_bit() { 5 let mut bi = FixedBigInt::new(224); 6 7 bi.set_bit(0); 8 assert_eq!( 9 bi.to_string(), 10 "0000000000000000000000000000000000000000000000000000000000000001" 11 ); 12 13 bi.lsh(1); 14 assert_eq!( 15 bi.to_string(), 16 "0000000000000000000000000000000000000000000000000000000000000002" 17 ); 18 19 bi.lsh(0); 20 assert_eq!( 21 bi.to_string(), 22 "0000000000000000000000000000000000000000000000000000000000000002" 23 ); 24 25 bi.set_bit(10); 26 assert_eq!( 27 bi.to_string(), 28 "0000000000000000000000000000000000000000000000000000000000000402" 29 ); 30 bi.lsh(20); 31 assert_eq!( 32 bi.to_string(), 33 "0000000000000000000000000000000000000000000000000000000040200000" 34 ); 35 36 bi.set_bit(80); 37 assert_eq!( 38 bi.to_string(), 39 "0000000000000000000000000000000000000000000100000000000040200000" 40 ); 41 bi.lsh(4); 42 assert_eq!( 43 bi.to_string(), 44 "0000000000000000000000000000000000000000001000000000000402000000" 45 ); 46 47 bi.set_bit(130); 48 assert_eq!( 49 bi.to_string(), 50 "0000000000000000000000000000000400000000001000000000000402000000" 51 ); 52 bi.lsh(64); 53 assert_eq!( 54 bi.to_string(), 55 "0000000000000004000000000010000000000004020000000000000000000000" 56 ); 57 58 bi.set_bit(7); 59 assert_eq!( 60 bi.to_string(), 61 "0000000000000004000000000010000000000004020000000000000000000080" 62 ); 63 64 bi.lsh(129); 65 assert_eq!( 66 bi.to_string(), 67 "0000000004000000000000000000010000000000000000000000000000000000" 68 ); 69 70 for _ in 0..256 { 71 bi.lsh(1); 72 bi.set_bit(0); 73 } 74 assert_eq!( 75 bi.to_string(), 76 "00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" 77 ); 78 } 79