MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_basic_bit_checks

Function test_basic_bit_checks

plugins/lsps-plugin/src/core/features.rs:100–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

98
99 #[test]
100 fn test_basic_bit_checks() {
101 // Example bitmap:
102 // Byte 0: 0b10100101 (165) -> Bits 0, 2, 5, 7 set
103 // Byte 1: 0b01101010 (106) -> Bits 1, 3, 5, 6 set (indices 9, 11, 13, 14)
104 let bitmap: &[u8] = &[0b10100101, 0b01101010];
105
106 // Check bits in byte 0 (indices 0-7)
107 assert_eq!(is_feature_bit_set(bitmap, 0), true); // Bit 0
108 assert_eq!(is_feature_bit_set(bitmap, 1), false); // Bit 1
109 assert_eq!(is_feature_bit_set(bitmap, 2), true); // Bit 2
110 assert_eq!(is_feature_bit_set(bitmap, 3), false); // Bit 3
111 assert_eq!(is_feature_bit_set(bitmap, 4), false); // Bit 4
112 assert_eq!(is_feature_bit_set(bitmap, 5), true); // Bit 5
113 assert_eq!(is_feature_bit_set(bitmap, 6), false); // Bit 6
114 assert_eq!(is_feature_bit_set(bitmap, 7), true); // Bit 7
115
116 // Check bits in byte 1 (indices 8-15)
117 assert_eq!(is_feature_bit_set(bitmap, 8), false); // Bit 8 (Byte 1, bit 0)
118 assert_eq!(is_feature_bit_set(bitmap, 9), true); // Bit 9 (Byte 1, bit 1)
119 assert_eq!(is_feature_bit_set(bitmap, 10), false); // Bit 10 (Byte 1, bit 2)
120 assert_eq!(is_feature_bit_set(bitmap, 11), true); // Bit 11 (Byte 1, bit 3)
121 assert_eq!(is_feature_bit_set(bitmap, 12), false); // Bit 12 (Byte 1, bit 4)
122 assert_eq!(is_feature_bit_set(bitmap, 13), true); // Bit 13 (Byte 1, bit 5)
123 assert_eq!(is_feature_bit_set(bitmap, 14), true); // Bit 14 (Byte 1, bit 6)
124 assert_eq!(is_feature_bit_set(bitmap, 15), false); // Bit 15 (Byte 1, bit 7)
125 }
126
127 #[test]
128 fn test_out_of_bounds() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected