|
20 | 20 | #include "kvstore/TDBStore.h" |
21 | 21 | #include <stdlib.h> |
22 | 22 |
|
23 | | -#define BLOCK_SIZE (512) |
| 23 | +#define BLOCK_SIZE (256) |
24 | 24 | #define DEVICE_SIZE (BLOCK_SIZE*200) |
25 | 25 |
|
26 | 26 | using namespace mbed; |
27 | 27 |
|
28 | 28 | class TDBStoreModuleTest : public testing::Test { |
29 | 29 | protected: |
30 | | - HeapBlockDevice heap{DEVICE_SIZE}; |
| 30 | + HeapBlockDevice heap{DEVICE_SIZE, BLOCK_SIZE}; |
31 | 31 | FlashSimBlockDevice flash{&heap}; |
32 | 32 | TDBStore tdb{&flash}; |
33 | 33 |
|
@@ -77,15 +77,17 @@ TEST_F(TDBStoreModuleTest, erased_set_get) |
77 | 77 |
|
78 | 78 | TEST_F(TDBStoreModuleTest, set_deinit_init_get) |
79 | 79 | { |
80 | | - char buf[100]; |
81 | 80 | size_t size; |
82 | 81 | 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); |
84 | 86 | EXPECT_EQ(tdb.deinit(), MBED_SUCCESS); |
85 | 87 | EXPECT_EQ(tdb.init(), MBED_SUCCESS); |
86 | 88 | 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); |
89 | 91 | EXPECT_EQ(tdb.remove("key"), MBED_SUCCESS); |
90 | 92 | } |
91 | 93 | } |
|
0 commit comments