@@ -36,6 +36,8 @@ void StringCmdTest<RedisInstance>::run() {
3636
3737    _test_getset ();
3838
39+     _test_set_with_get_option ();
40+ 
3941    _test_mgetset ();
4042}
4143
@@ -204,6 +206,34 @@ void StringCmdTest<RedisInstance>::_test_getset() {
204206    REDIS_ASSERT (_redis.pttl (key) <= pttl.count (), " failed to test psetex" 
205207}
206208
209+ template  <typename  RedisInstance>
210+ void  StringCmdTest<RedisInstance>::_test_set_with_get_option() {
211+     auto  key = test_key (" set_with_get_option" 
212+     auto  non_exist_key = test_key (" non-existent" 
213+ 
214+     KeyDeleter<RedisInstance> deleter (_redis, {key, non_exist_key});
215+ 
216+     std::string val (" value" 
217+     REDIS_ASSERT (!_redis.set_with_get_option (key, val), " failed to test set_with_get_option" 
218+ 
219+     auto  v = _redis.set_with_get_option (key, val + val, std::chrono::milliseconds (0 ), UpdateType::NOT_EXIST);
220+     REDIS_ASSERT (v && *v == val, " failed to test set_with_get_option (GET)" 
221+     v = _redis.get (key);
222+     REDIS_ASSERT (v && *v == val, " failed to test set_with_get_option (NOT_EXIST)" 
223+ 
224+     auto  ttl = std::chrono::seconds (10 );
225+     _redis.set_with_get_option (non_exist_key, val, ttl, UpdateType::EXIST);
226+     REDIS_ASSERT (!_redis.get (non_exist_key), " failed to test set_with_get_option (EXIST)" 
227+ 
228+     _redis.set_with_get_option (key, val, ttl);
229+     auto  ttl_v = _redis.ttl (key);
230+     REDIS_ASSERT (ttl_v >= 0  && ttl_v <= ttl.count (), " failed to test set_with_get_option (TTL)" 
231+ 
232+     _redis.set_with_get_option (key, val, true );
233+     ttl_v = _redis.ttl (key);
234+     REDIS_ASSERT (ttl_v >= 0  && ttl_v <= ttl.count (), " failed to test set_with_get_option (KEEPTTL)" 
235+ }
236+ 
207237template  <typename  RedisInstance>
208238void  StringCmdTest<RedisInstance>::_test_mgetset() {
209239    auto  kvs = {std::make_pair (test_key (" k1" " v1" 
0 commit comments