-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4a559e
commit e1226db
Showing
4 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ logs | |
.DS_Store | ||
|
||
#test | ||
test/ | ||
#test/ | ||
|
||
# 字节码文件 | ||
*.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
redis/src/test/java/io/walkers/planes/pandora/redis/sign/util/BitmapUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package io.walkers.planes.pandora.redis.sign.util; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
/** | ||
* @author planeswalker23 | ||
* @date 2022/3/2 | ||
*/ | ||
@SpringBootTest | ||
public class BitmapUtilTest { | ||
|
||
@Autowired | ||
private BitmapUtil bitmapUtil; | ||
|
||
private final String key = "key"; | ||
|
||
@Test | ||
public void coreMethod() { | ||
// 01100001 | ||
String a = "a"; | ||
bitmapUtil.set(key, a); | ||
String result = bitmapUtil.get(key); | ||
Assertions.assertEquals(a, result); | ||
|
||
// SETBIT 0 0 : 0 | ||
Boolean setBitResult = bitmapUtil.setBit(key, 0L, false); | ||
Assertions.assertEquals(Boolean.FALSE, setBitResult); | ||
|
||
// GETBIT 0 2 : 1 | ||
Boolean getBitResult = bitmapUtil.getBit(key, 2L); | ||
Assertions.assertEquals(Boolean.TRUE, getBitResult); | ||
|
||
// BITCOUNT key : 3 | ||
Long countResult1 = bitmapUtil.bitCountTrue(key); | ||
Assertions.assertEquals(3L, countResult1); | ||
// BITCOUNT key 0 1 : 3 | ||
Long countResult2 = bitmapUtil.bitCountTrue(key, 0L, 1L); | ||
Assertions.assertEquals(3L, countResult2); | ||
// BITCOUNT key 1 2 : 0 | ||
Long countResult3 = bitmapUtil.bitCountTrue(key, 1L, 2L); | ||
Assertions.assertEquals(0L, countResult3); | ||
|
||
// BITPOS key 1 : 1 | ||
Long countPos1Result = bitmapUtil.bitPos(key, true); | ||
Assertions.assertEquals(1L, countPos1Result); | ||
|
||
// BITPOS key 1 0 1: 1 | ||
Long countPos0Result = bitmapUtil.bitPos(key, true, 0L, 1L); | ||
Assertions.assertEquals(1L, countPos0Result); | ||
|
||
// BITPOS key 1 1 2: -1 | ||
Long countPos0Result2 = bitmapUtil.bitPos(key, true, 1L, 2L); | ||
Assertions.assertEquals(-1L, countPos0Result2); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#Redis | ||
spring.redis.host=127.0.0.1 | ||
spring.redis.port=6379 | ||
|
||
spring.datasource.driver-class-name=org.h2.Driver | ||
spring.datasource.url=jdbc:h2:mem:db | ||
spring.h2.console.enabled=true | ||
|
||
spring.jpa.show-sql=true |