diff --git a/Redis/testsuite/src/RedisTest.cpp b/Redis/testsuite/src/RedisTest.cpp index 6a90c29f1..08e8a5a82 100644 --- a/Redis/testsuite/src/RedisTest.cpp +++ b/Redis/testsuite/src/RedisTest.cpp @@ -378,6 +378,79 @@ void RedisTest::testPing() } +void RedisTest::testLPop() +{ + if (!_connected) + { + std::cout << "Not connected, test skipped." << std::endl; + return; + } + + // Make sure the list is not there yet ... + Command delCommand = Command::del("mylist"); + try + { + _redis.execute(delCommand); + } + catch(RedisException& e) + { + fail(e.message()); + } + catch(Poco::BadCastException& e) + { + fail(e.message()); + } + + try + { + Command rpush = Command::rpush("mylist", "one"); + Poco::Int64 result = _redis.execute(rpush); + assert(result == 1); + + rpush = Command::rpush("mylist", "two"); + result = _redis.execute(rpush); + assert(result == 2); + + rpush = Command::rpush("mylist", "three"); + result = _redis.execute(rpush); + assert(result == 3); + } + catch(RedisException &e) + { + fail(e.message()); + } + + Command lpop = Command::lpop("mylist"); + try + { + BulkString result = _redis.execute(lpop); + assert(result.value().compare("one") == 0); + } + catch(RedisException &e) + { + fail(e.message()); + } + + Command lrange = Command::lrange("mylist"); + try + { + Array result = _redis.execute(lrange); + + assert(result.size() == 2); + assert(result.get(0).value().compare("two") == 0); + assert(result.get(1).value().compare("three") == 0); + } + catch(RedisException &e) + { + fail(e.message()); + } + catch(Poco::NullValueException &e) + { + fail(e.message()); + } + +} + void RedisTest::testMSet() { if (!_connected) @@ -1043,6 +1116,7 @@ CppUnit::Test* RedisTest::suite() CppUnit_addTest(pSuite, RedisTest, testLIndex); CppUnit_addTest(pSuite, RedisTest, testLInsert); CppUnit_addTest(pSuite, RedisTest, testLRem); + CppUnit_addTest(pSuite, RedisTest, testLPop); CppUnit_addTest(pSuite, RedisTest, testMulti); CppUnit_addTest(pSuite, RedisTest, testPubSub); diff --git a/Redis/testsuite/src/RedisTest.h b/Redis/testsuite/src/RedisTest.h index 092c16b9c..19ab9decf 100644 --- a/Redis/testsuite/src/RedisTest.h +++ b/Redis/testsuite/src/RedisTest.h @@ -44,6 +44,7 @@ public: void testRPush(); void testLIndex(); void testLInsert(); + void testLPop(); void testLRem(); void testMulti();