From: Ivan Grokhotkov Date: Tue, 27 Jun 2017 03:28:37 +0000 (+0800) Subject: nvs: add test for ESP_ERR_NVS_INVALID_LENGTH X-Git-Tag: v3.1-dev~510^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f04512369113a857d213d644d5dc8cfbe46c8690;p=esp-idf nvs: add test for ESP_ERR_NVS_INVALID_LENGTH --- diff --git a/components/nvs_flash/test_nvs_host/test_nvs.cpp b/components/nvs_flash/test_nvs_host/test_nvs.cpp index ce5c864303..22d4c3b70b 100644 --- a/components/nvs_flash/test_nvs_host/test_nvs.cpp +++ b/components/nvs_flash/test_nvs_host/test_nvs.cpp @@ -522,6 +522,14 @@ TEST_CASE("nvs api tests", "[nvs]") char buf[strlen(str) + 1]; size_t buf_len = sizeof(buf); + size_t buf_len_needed; + TEST_ESP_OK(nvs_get_str(handle_2, "key", NULL, &buf_len_needed)); + CHECK(buf_len_needed == buf_len); + + size_t buf_len_short = buf_len - 1; + TEST_ESP_ERR(ESP_ERR_NVS_INVALID_LENGTH, nvs_get_str(handle_2, "key", buf, &buf_len_short)); + CHECK(buf_len_short == buf_len); + TEST_ESP_OK(nvs_get_str(handle_2, "key", buf, &buf_len)); CHECK(0 == strcmp(buf, str));