1. add Test

This commit is contained in:
wenlianggong 2024-08-21 22:17:05 +08:00
parent c93d4785d9
commit 1000185307

View File

@ -0,0 +1,24 @@
package org.dromara.hutool.core.math;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* @author 温良恭
* @Date 2024/8/21 22:04
*/
public class BitStatusUtilTest {
@Test
public void test() {
int states = 0;
states = BitStatusUtil.add(states, 2); // 添加已读状态
states = BitStatusUtil.add(states, 4); // 添加已写状态
// 此时states 的值为 6二进制为 110这表示同时具有已读已写状态
boolean hasRead = BitStatusUtil.has(states, 2); // 检查已读状态
boolean hasWrite = BitStatusUtil.has(states, 4); // 检查已写状态
Assertions.assertEquals(true, hasRead);
Assertions.assertEquals(true, hasWrite);
}
}