@@ -331,13 +331,37 @@ TEST(DBConnector, RedisClient)
331331 cout << endl;
332332 }
333333
334- cout << " - Step 4. DEL" << endl;
334+ cout << " - Step 4. HDEL single field" << endl;
335+ cout << " Delete field_2 under key [a]" << endl;
336+ int64_t rval = redic.hdel (key_1, " field_2" );
337+ EXPECT_EQ (rval, 1 );
338+
339+ auto fvs = redic.hgetall (key_1);
340+ EXPECT_EQ (fvs.size (), 2 );
341+ for (auto fv: fvs)
342+ {
343+ string value_1 = " 1" , value_3 = " 3" ;
344+ cout << " " << fvField (fv) << " :" << fvValue (fv) << flush;
345+ if (fvField (fv) == " field_1" )
346+ {
347+ EXPECT_EQ (fvValue (fv), value_1);
348+ }
349+ if (fvField (fv) == " field_3" )
350+ {
351+ EXPECT_EQ (fvValue (fv), value_3);
352+ }
353+
354+ ASSERT_FALSE (fvField (fv) == " 2" );
355+ }
356+ cout << endl;
357+
358+ cout << " - Step 5. DEL" << endl;
335359 cout << " Delete key [a]" << endl;
336360 redic.del (key_1);
337361
338- cout << " - Step 5 . GET" << endl;
362+ cout << " - Step 6 . GET" << endl;
339363 cout << " Get key [a] and key [b]" << endl;
340- auto fvs = redic.hgetall (key_1);
364+ fvs = redic.hgetall (key_1);
341365 EXPECT_TRUE (fvs.empty ());
342366 fvs = redic.hgetall (key_2);
343367
@@ -357,7 +381,28 @@ TEST(DBConnector, RedisClient)
357381 }
358382 cout << endl;
359383
360- cout << " - Step 6. DEL and GET_TABLE_CONTENT" << endl;
384+ cout << " - Step 7. HDEL multiple fields" << endl;
385+ cout << " Delete field_2, field_3 under key [b]" << endl;
386+ rval = redic.hdel (key_2, vector<string>({" field_2" , " field_3" }));
387+ EXPECT_EQ (rval, 2 );
388+
389+ fvs = redic.hgetall (key_2);
390+ EXPECT_EQ (fvs.size (), 1 );
391+ for (auto fv: fvs)
392+ {
393+ string value_1 = " 1" ;
394+ cout << " " << fvField (fv) << " :" << fvValue (fv) << flush;
395+ if (fvField (fv) == " field_1" )
396+ {
397+ EXPECT_EQ (fvValue (fv), value_1);
398+ }
399+
400+ ASSERT_FALSE (fvField (fv) == " field_2" );
401+ ASSERT_FALSE (fvField (fv) == " field_3" );
402+ }
403+ cout << endl;
404+
405+ cout << " - Step 8. DEL and GET_TABLE_CONTENT" << endl;
361406 cout << " Delete key [b]" << endl;
362407 redic.del (key_2);
363408 fvs = redic.hgetall (key_2);
0 commit comments