pw_kvs: Add fix and test for Fake Flash

Add fix for FakeFlashMemory not able to be directly constructed due to
no_errors_ being an Undefined symbol. Add test to catch/verify the
problem/fix.

Change-Id: I5807274b705e4078221f9c55e45b15f6666d2933
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13462
Commit-Queue: David Rogers <davidrogers@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
diff --git a/pw_kvs/entry_test.cc b/pw_kvs/entry_test.cc
index d250039..69f5a90 100644
--- a/pw_kvs/entry_test.cc
+++ b/pw_kvs/entry_test.cc
@@ -35,7 +35,10 @@
 constexpr EntryFormat kFormat{0xbeef, nullptr};
 
 TEST(Entry, Size_RoundsUpToAlignment) {
-  FakeFlashMemoryBuffer<64, 2> flash(16);
+  // Use FakeFlashMemory, rather than FakeFlashMemoryBuffer, so the class gets
+  // tested/used directly.
+  std::array<std::byte, 64 * 2> buffer;
+  FakeFlashMemory flash(buffer, 64, 2, 16);
 
   for (size_t alignment_bytes = 1; alignment_bytes <= 4096; ++alignment_bytes) {
     FlashPartition partition(&flash, 0, flash.sector_count(), alignment_bytes);
diff --git a/pw_kvs/public/pw_kvs/fake_flash_memory.h b/pw_kvs/public/pw_kvs/fake_flash_memory.h
index a2f9bbb..c1b0bbe 100644
--- a/pw_kvs/public/pw_kvs/fake_flash_memory.h
+++ b/pw_kvs/public/pw_kvs/fake_flash_memory.h
@@ -79,9 +79,6 @@
 // write, checks alignments, and is addressed in sectors). The underlying buffer
 // is not initialized.
 class FakeFlashMemory : public FlashMemory {
- private:
-  static Vector<FlashError, 0> no_errors_;
-
  public:
   // Default to 8-bit alignment.
   static constexpr size_t kDefaultAlignmentBytes = 1;
@@ -141,6 +138,8 @@
   }
 
  private:
+  static inline Vector<FlashError, 0> no_errors_;
+
   const std::span<std::byte> buffer_;
   Vector<FlashError>& read_errors_;
   Vector<FlashError>& write_errors_;