@@ -7577,6 +7577,116 @@ func (suite *GlideTestSuite) TestBitCountWithOptions_StartEndBit() {
75777577 })
75787578}
75797579
7580+ func (suite * GlideTestSuite ) TestBitOp_AND () {
7581+ suite .runWithDefaultClients (func (client api.BaseClient ) {
7582+ bitopkey1 := "{bitop_test}" + uuid .New ().String ()
7583+ bitopkey2 := "{bitop_test}" + uuid .New ().String ()
7584+ destKey := "{bitop_test}" + uuid .New ().String ()
7585+
7586+ _ , err := client .Set (bitopkey1 , "foobar" )
7587+ assert .NoError (suite .T (), err )
7588+
7589+ _ , err = client .Set (bitopkey2 , "abcdef" )
7590+ assert .NoError (suite .T (), err )
7591+
7592+ result , err := client .BitOp (options .AND , destKey , []string {bitopkey1 , bitopkey2 })
7593+ assert .NoError (suite .T (), err )
7594+ assert .GreaterOrEqual (suite .T (), result , int64 (0 ))
7595+
7596+ bitResult , err := client .Get (destKey )
7597+ assert .NoError (suite .T (), err )
7598+ assert .NotEmpty (suite .T (), bitResult .Value ())
7599+ })
7600+ }
7601+
7602+ func (suite * GlideTestSuite ) TestBitOp_OR () {
7603+ suite .runWithDefaultClients (func (client api.BaseClient ) {
7604+ key1 := "{bitop_test}" + uuid .New ().String ()
7605+ key2 := "{bitop_test}" + uuid .New ().String ()
7606+ destKey := "{bitop_test}" + uuid .New ().String ()
7607+
7608+ _ , err := client .Set (key1 , "foo" )
7609+ assert .NoError (suite .T (), err )
7610+
7611+ _ , err = client .Set (key2 , "bar" )
7612+ assert .NoError (suite .T (), err )
7613+
7614+ result , err := client .BitOp (options .OR , destKey , []string {key1 , key2 })
7615+ assert .NoError (suite .T (), err )
7616+ assert .GreaterOrEqual (suite .T (), result , int64 (0 ))
7617+
7618+ bitResult , err := client .Get (destKey )
7619+ assert .NoError (suite .T (), err )
7620+ assert .NotEmpty (suite .T (), bitResult .Value ())
7621+ })
7622+ }
7623+
7624+ func (suite * GlideTestSuite ) TestBitOp_XOR () {
7625+ suite .runWithDefaultClients (func (client api.BaseClient ) {
7626+ key1 := "{bitop_test}" + uuid .New ().String ()
7627+ key2 := "{bitop_test}" + uuid .New ().String ()
7628+ destKey := "{bitop_test}" + uuid .New ().String ()
7629+
7630+ _ , err := client .Set (key1 , "foo" )
7631+ assert .NoError (suite .T (), err )
7632+
7633+ _ , err = client .Set (key2 , "bar" )
7634+ assert .NoError (suite .T (), err )
7635+
7636+ result , err := client .BitOp (options .XOR , destKey , []string {key1 , key2 })
7637+ assert .NoError (suite .T (), err )
7638+ assert .GreaterOrEqual (suite .T (), result , int64 (0 ))
7639+
7640+ bitResult , err := client .Get (destKey )
7641+ assert .NoError (suite .T (), err )
7642+ assert .NotEmpty (suite .T (), bitResult .Value ())
7643+ })
7644+ }
7645+
7646+ func (suite * GlideTestSuite ) TestBitOp_NOT () {
7647+ suite .runWithDefaultClients (func (client api.BaseClient ) {
7648+ srcKey := "{bitop_test}" + uuid .New ().String ()
7649+ destKey := "{bitop_test}" + uuid .New ().String ()
7650+
7651+ _ , err := client .Set (srcKey , "foobar" )
7652+ assert .NoError (suite .T (), err )
7653+
7654+ result , err := client .BitOp (options .NOT , destKey , []string {srcKey })
7655+ assert .NoError (suite .T (), err )
7656+ assert .GreaterOrEqual (suite .T (), result , int64 (0 ))
7657+
7658+ bitResult , err := client .Get (destKey )
7659+ assert .NoError (suite .T (), err )
7660+ assert .NotEmpty (suite .T (), bitResult .Value ())
7661+ })
7662+ }
7663+
7664+ func (suite * GlideTestSuite ) TestBitOp_InvalidArguments () {
7665+ suite .runWithDefaultClients (func (client api.BaseClient ) {
7666+ destKey := "{bitop_test}" + uuid .New ().String ()
7667+ key1 := "{bitop_test}" + uuid .New ().String ()
7668+ key2 := "{bitop_test}" + uuid .New ().String ()
7669+
7670+ _ , err := client .Set (key1 , "foo" )
7671+ assert .NoError (suite .T (), err )
7672+
7673+ _ , err = client .Set (key2 , "bar" )
7674+ assert .NoError (suite .T (), err )
7675+
7676+ _ , err = client .BitOp (options .AND , destKey , []string {key1 })
7677+ assert .NotNil (suite .T (), err )
7678+
7679+ _ , err = client .BitOp (options .OR , destKey , []string {key1 })
7680+ assert .NotNil (suite .T (), err )
7681+
7682+ _ , err = client .BitOp (options .XOR , destKey , []string {key1 })
7683+ assert .NotNil (suite .T (), err )
7684+
7685+ _ , err = client .BitOp (options .NOT , destKey , []string {key1 , key2 })
7686+ assert .NotNil (suite .T (), err )
7687+ })
7688+ }
7689+
75807690func (suite * GlideTestSuite ) TestXPendingAndXClaim () {
75817691 suite .runWithDefaultClients (func (client api.BaseClient ) {
75827692 // 1. Arrange the data
0 commit comments