33 lines
493 B
C
33 lines
493 B
C
#include <assert.h>
|
|
|
|
int main() {
|
|
int foo;
|
|
|
|
foo = 42;
|
|
|
|
/* Delete bit 5 */
|
|
foo &= ~(1 << 5);
|
|
assert(foo == 10);
|
|
foo &= ~(1 << 5);
|
|
assert(foo == 10);
|
|
|
|
/* Set bit 5 again */
|
|
foo |= (1 << 5);
|
|
assert(foo == 42);
|
|
foo |= (1 << 5);
|
|
assert(foo == 42);
|
|
|
|
/* Set bit 0 */
|
|
foo |= (1 << 0);
|
|
assert(foo == 43);
|
|
|
|
/* Delete bit 0 */
|
|
foo &= ~(1 << 0);
|
|
assert(foo == 42);
|
|
|
|
/* Toggle bit 5 */
|
|
foo ^= (1 << 5);
|
|
assert(foo == 10);
|
|
foo ^= (1 << 5);
|
|
assert(foo == 42);
|
|
}
|