Explorar o código

esp_netif: Added test for failing to set hostname

David Cermak %!s(int64=5) %!d(string=hai) anos
pai
achega
916d2f6f4c
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      components/esp_netif/test/test_esp_netif.c

+ 8 - 0
components/esp_netif/test/test_esp_netif.c

@@ -275,5 +275,13 @@ TEST_CASE("esp_netif: get/set hostname", "[esp_netif]")
     TEST_ASSERT_EQUAL(ESP_OK, esp_netif_get_hostname(esp_netif, &hostname));
     TEST_ASSERT_EQUAL_STRING(hostname, "new_name");
 
+    // test that setting the long name is refused and the previously set value retained
+    #define ESP_NETIF_HOSTNAME_MAX_SIZE    32
+    char long_name[ESP_NETIF_HOSTNAME_MAX_SIZE + 2] = { 0 };
+    memset(long_name, 'A', ESP_NETIF_HOSTNAME_MAX_SIZE+1); // construct the long name
+    TEST_ASSERT_NOT_EQUAL(ESP_OK, esp_netif_set_hostname(esp_netif, long_name));
+    TEST_ASSERT_EQUAL(ESP_OK, esp_netif_get_hostname(esp_netif, &hostname));
+    TEST_ASSERT_EQUAL_STRING(hostname, "new_name");
+
     esp_netif_destroy(esp_netif);
 }