BitMaskTest.java revision 6d8d20617e742e68d9dc53380664a85dbaa3f927
1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.server.wifi.util; 18 19import org.junit.Assert; 20import org.junit.Test; 21 22/** 23 * Unit tests for {@link com.android.server.wifi.util.BitMask}. 24 */ 25public class BitMaskTest { 26 /** 27 * Test that checkoff.testAndClear works as advertised 28 */ 29 @Test 30 public void testBitMask() throws Exception { 31 32 BitMask checkoff = new BitMask(0x53); 33 34 Assert.assertTrue(checkoff.testAndClear(0x10)); // First time, bit should be there 35 Assert.assertFalse(checkoff.testAndClear(0x10)); // Second time, should be gone 36 Assert.assertFalse(checkoff.testAndClear(0x100)); // This bit was not set 37 Assert.assertEquals(0x43, checkoff.value); // These should be left 38 } 39} 40