pw_kvs: Fix sectors test
Add sectors_ reset as part of the fixture, since reset is required
before using sectors_. This prevents using uninitialized members, which
sometimes passes tests.
Change-Id: I293b3fe927eca1ec187f31b25087e8b2db3168d5
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13842
Commit-Queue: David Rogers <davidrogers@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
diff --git a/pw_kvs/sectors_test.cc b/pw_kvs/sectors_test.cc
index 50755a4..c1d295f 100644
--- a/pw_kvs/sectors_test.cc
+++ b/pw_kvs/sectors_test.cc
@@ -24,7 +24,10 @@
protected:
SectorsTest()
: partition_(&flash_),
- sectors_(sector_descriptors_, partition_, nullptr) {}
+ sectors_(sector_descriptors_, partition_, nullptr) {
+ EXPECT_EQ(0u, sectors_.size());
+ sectors_.Reset();
+ }
FakeFlashMemoryBuffer<128, 16> flash_;
FlashPartition partition_;
@@ -33,10 +36,7 @@
};
TEST_F(SectorsTest, Reset) {
- EXPECT_EQ(0u, sectors_.size());
-
- sectors_.Reset();
-
+ // Reset is done by the fixture.
EXPECT_EQ(partition_.sector_count(), sectors_.size());
EXPECT_EQ(32u, sectors_.max_size());
EXPECT_EQ(sectors_.begin(), sectors_.last_new());