@@ -61,30 +61,30 @@ TEST_F(ObjectTest, embedded_string_with_key) {
6161 sds key = sdsnew (" k:123456789012345678901234567890" );
6262 ASSERT_EQ (sdslen (key), 32u );
6363
64- /* 32B key and 15B value should be embedded within 64B . Contents:
64+ /* 32B key and 79B value should be embedded within 128B . Contents:
6565 * - 8B robj (no ptr) + 1B key header size
6666 * - 3B key header + 32B key + 1B null terminator
67- * - 3B val header + 15B val + 1B null terminator
67+ * - 3B val header + 79B val + 1B null terminator
6868 * because no pointers are stored, there is no difference for 32 bit builds*/
69- const char *short_value = " 123456789012345 " ;
70- ASSERT_EQ (strlen (short_value), 15u );
69+ const char *short_value = " 1234567890123456789012345678901234567890123456789012345678901234567890123456789 " ;
70+ ASSERT_EQ (strlen (short_value), 79u );
7171 robj *short_val_obj = createStringObject (short_value, strlen (short_value));
7272 robj *embstr_obj = objectSetKeyAndExpire (short_val_obj, key, -1 );
7373 ASSERT_EQ (embstr_obj->encoding , (unsigned )OBJ_ENCODING_EMBSTR);
7474 ASSERT_EQ (sdslen (objectGetKey (embstr_obj)), 32u );
7575 ASSERT_EQ (sdscmp (objectGetKey (embstr_obj), key), 0 );
76- ASSERT_EQ (sdslen ((sds)objectGetVal (embstr_obj)), 15u );
76+ ASSERT_EQ (sdslen ((sds)objectGetVal (embstr_obj)), 79u );
7777 ASSERT_EQ (strcmp ((const char *)objectGetVal (embstr_obj), short_value), 0 );
7878
79- /* value of length 16 cannot be embedded with other contents within 64B */
80- const char *longer_value = " 1234567890123456 " ;
81- ASSERT_EQ (strlen (longer_value), 16u );
79+ /* value of length 80 cannot be embedded with other contents within 128B */
80+ const char *longer_value = " 12345678901234567890123456789012345678901234567890123456789012345678901234567890 " ;
81+ ASSERT_EQ (strlen (longer_value), 80u );
8282 robj *longer_val_obj = createStringObject (longer_value, strlen (longer_value));
8383 robj *raw_obj = objectSetKeyAndExpire (longer_val_obj, key, -1 );
8484 ASSERT_EQ (raw_obj->encoding , (unsigned )OBJ_ENCODING_RAW);
8585 ASSERT_EQ (sdslen (objectGetKey (raw_obj)), 32u );
8686 ASSERT_EQ (sdscmp (objectGetKey (raw_obj), key), 0 );
87- ASSERT_EQ (sdslen ((sds)objectGetVal (raw_obj)), 16u );
87+ ASSERT_EQ (sdslen ((sds)objectGetVal (raw_obj)), 80u );
8888 ASSERT_EQ (strcmp ((const char *)objectGetVal (raw_obj), longer_value), 0 );
8989
9090 sdsfree (key);
@@ -97,30 +97,30 @@ TEST_F(ObjectTest, embedded_string_with_key_and_expire) {
9797 sds key = sdsnew (" k:123456789012345678901234567890" );
9898 ASSERT_EQ (sdslen (key), 32u );
9999
100- /* 32B key and 7B value should be embedded within 64B . Contents:
100+ /* 32B key and 71B value should be embedded within 128B . Contents:
101101 * - 8B robj (no ptr) + 8B expire + 1B key header size
102102 * - 3B key header + 32B key + 1B null terminator
103- * - 3B val header + 7B val + 1B null terminator
103+ * - 3B val header + 71B val + 1B null terminator
104104 * because no pointers are stored, there is no difference for 32 bit builds*/
105- const char *short_value = " 1234567 " ;
106- ASSERT_EQ (strlen (short_value), 7u );
105+ const char *short_value = " 12345678901234567890123456789012345678901234567890123456789012345678901 " ;
106+ ASSERT_EQ (strlen (short_value), 71u );
107107 robj *short_val_obj = createStringObject (short_value, strlen (short_value));
108108 robj *embstr_obj = objectSetKeyAndExpire (short_val_obj, key, 128 );
109109 ASSERT_EQ (embstr_obj->encoding , (unsigned )OBJ_ENCODING_EMBSTR);
110110 ASSERT_EQ (sdslen (objectGetKey (embstr_obj)), 32u );
111111 ASSERT_EQ (sdscmp (objectGetKey (embstr_obj), key), 0 );
112- ASSERT_EQ (sdslen ((sds)objectGetVal (embstr_obj)), 7u );
112+ ASSERT_EQ (sdslen ((sds)objectGetVal (embstr_obj)), 71u );
113113 ASSERT_EQ (strcmp ((const char *)objectGetVal (embstr_obj), short_value), 0 );
114114
115- /* value of length 8 cannot be embedded with other contents within 64B */
116- const char *longer_value = " 12345678 " ;
117- ASSERT_EQ (strlen (longer_value), 8u );
115+ /* value of length 72 cannot be embedded with other contents within 128B */
116+ const char *longer_value = " 123456789012345678901234567890123456789012345678901234567890123456789012 " ;
117+ ASSERT_EQ (strlen (longer_value), 72u );
118118 robj *longer_val_obj = createStringObject (longer_value, strlen (longer_value));
119119 robj *raw_obj = objectSetKeyAndExpire (longer_val_obj, key, 128 );
120120 ASSERT_EQ (raw_obj->encoding , (unsigned )OBJ_ENCODING_RAW);
121121 ASSERT_EQ (sdslen (objectGetKey (raw_obj)), 32u );
122122 ASSERT_EQ (sdscmp (objectGetKey (raw_obj), key), 0 );
123- ASSERT_EQ (sdslen ((sds)objectGetVal (raw_obj)), 8u );
123+ ASSERT_EQ (sdslen ((sds)objectGetVal (raw_obj)), 72u );
124124 ASSERT_EQ (strcmp ((const char *)objectGetVal (raw_obj), longer_value), 0 );
125125
126126 sdsfree (key);
0 commit comments