MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / TestBitpos

Function TestBitpos

IceFireDB-Redis-Proxy/test/cmd_string_test.go:1288–1464  ·  view source on GitHub ↗

* func TestBitop(t *testing.T) { server.Clear() c, err := proto.Dial(server.Addr()) ok(t, err) defer c.Close() s := server.Direct() { and := func(a, b byte) byte { return a & b } equals(t, []byte("`"), sliceBinOp(and, []byte("a"), []byte("b"))) equals(t, []byte("`\000\000"), s

(t *testing.T)

Source from the content-addressed store, hash-verified

1286 }
1287*/
1288func TestBitpos(t *testing.T) {
1289 server.Clear()
1290 c, err := proto.Dial(server.Addr())
1291 ok(t, err)
1292 defer c.Close()
1293 s := server.Direct()
1294
1295 t.Run("basic", func(t *testing.T) {
1296 s.Set("findme", "\xff\xf0\x00")
1297 mustDo(t, c,
1298 "BITPOS", "findme", "0",
1299 proto.Int(12),
1300 )
1301 mustDo(t, c,
1302 "BITPOS", "findme", "0", "1",
1303 proto.Int(12),
1304 )
1305 mustDo(t, c,
1306 "BITPOS", "findme", "0", "1", "1",
1307 proto.Int(12),
1308 )
1309
1310 must0(t, c,
1311 "BITPOS", "findme", "1",
1312 )
1313 mustDo(t, c,
1314 "BITPOS", "findme", "1", "1",
1315 proto.Int(8),
1316 )
1317 mustDo(t, c,
1318 "BITPOS", "findme", "1", "1", "2",
1319 proto.Int(8),
1320 )
1321
1322 mustDo(t, c,
1323 "BITPOS", "findme", "1", "10000",
1324 proto.Int(-1),
1325 )
1326 })
1327
1328 t.Run("substrings", func(t *testing.T) {
1329 s.Set("bin", string([]rune{rune(0b0000_0000), rune(0b0010_0000), rune(0b0001_0000)}))
1330 mustDo(t, c, "BITPOS", "bin", "1",
1331 proto.Int(10))
1332 mustDo(t, c, "BITPOS", "bin", "1", "1",
1333 proto.Int(10))
1334 mustDo(t, c, "BITPOS", "bin", "1", "1", "2",
1335 proto.Int(10))
1336 mustDo(t, c, "BITPOS", "bin", "1", "2", "2",
1337 proto.Int(19))
1338 mustDo(t, c, "BITPOS", "bin", "1", "0", "0",
1339 proto.Int(-1))
1340 mustDo(t, c, "BITPOS", "bin", "1", "0", "-1",
1341 proto.Int(10))
1342 mustDo(t, c, "BITPOS", "bin", "1", "0", "-2",
1343 proto.Int(10))
1344 mustDo(t, c, "BITPOS", "bin", "1", "0", "-3",
1345 proto.Int(-1))

Callers

nothing calls this directly

Calls 13

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
IntFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustDoFunction · 0.70
must0Function · 0.70
errWrongNumberFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected