Skip to content

Commit a4907e8

Browse files
LDong-ArmSeppo Takalo
andcommitted
Bring in TDBStore UNITTESTS improvements from PR #13731
Co-authored-by: Seppo Takalo <[email protected]>
1 parent fd5b2c5 commit a4907e8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

storage/kvstore/tests/UNITTESTS/TDBStore/moduletest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
#include "kvstore/TDBStore.h"
2121
#include <stdlib.h>
2222

23-
#define BLOCK_SIZE (512)
23+
#define BLOCK_SIZE (256)
2424
#define DEVICE_SIZE (BLOCK_SIZE*200)
2525

2626
using namespace mbed;
2727

2828
class TDBStoreModuleTest : public testing::Test {
2929
protected:
30-
HeapBlockDevice heap{DEVICE_SIZE};
30+
HeapBlockDevice heap{DEVICE_SIZE, BLOCK_SIZE};
3131
FlashSimBlockDevice flash{&heap};
3232
TDBStore tdb{&flash};
3333

@@ -77,15 +77,17 @@ TEST_F(TDBStoreModuleTest, erased_set_get)
7777

7878
TEST_F(TDBStoreModuleTest, set_deinit_init_get)
7979
{
80-
char buf[100];
8180
size_t size;
8281
for (int i = 0; i < 100; ++i) {
83-
EXPECT_EQ(tdb.set("key", "data", 5, 0), MBED_SUCCESS);
82+
char str[11] = {0};
83+
char buf[100] = {0};
84+
int len = snprintf(str, 11, "data%d", i) + 1;
85+
EXPECT_EQ(tdb.set("key", str, len, 0), MBED_SUCCESS);
8486
EXPECT_EQ(tdb.deinit(), MBED_SUCCESS);
8587
EXPECT_EQ(tdb.init(), MBED_SUCCESS);
8688
EXPECT_EQ(tdb.get("key", buf, 100, &size), MBED_SUCCESS);
87-
EXPECT_EQ(size, 5);
88-
EXPECT_STREQ("data", buf);
89+
EXPECT_EQ(size, len);
90+
EXPECT_STREQ(str, buf);
8991
EXPECT_EQ(tdb.remove("key"), MBED_SUCCESS);
9092
}
9193
}

0 commit comments

Comments
 (0)