Skip to content

Commit 96d0957

Browse files
pdgendtjhedberg
authored andcommitted
tests: nvmem: Test _OR for missing cells
Add a test case where missing cells result in empty structs. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
1 parent 71a5f1d commit 96d0957

File tree

1 file changed

+9
-0
lines changed
  • tests/subsys/nvmem/api/src

1 file changed

+9
-0
lines changed

tests/subsys/nvmem/api/src/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,13 @@ ZTEST(nvmem_api, test_nvmem_api)
4747
zassert_equal(ret, -EROFS, "Expected read-only NVMEM");
4848
}
4949

50+
ZTEST(nvmem_api, test_nvmem_missing)
51+
{
52+
const struct nvmem_cell missing_idx = NVMEM_CELL_GET_BY_IDX_OR(consumer0, 10, {});
53+
const struct nvmem_cell missing_name = NVMEM_CELL_GET_BY_NAME_OR(consumer0, missing, {});
54+
55+
zassert_is_null(missing_idx.dev);
56+
zassert_is_null(missing_name.dev);
57+
}
58+
5059
ZTEST_SUITE(nvmem_api, NULL, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)