mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-29 05:21:37 +03:00
Device side test library and test runner
This commit is contained in:
committed by
Ivan Grokhotkov
parent
33723a9b52
commit
ab7af89002
35
tests/device/test_http_client/test_http_client.ino
Normal file
35
tests/device/test_http_client/test_http_client.ino
Normal file
@ -0,0 +1,35 @@
|
||||
#include <Arduino.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <BSTest.h>
|
||||
#include <test_config.h>
|
||||
|
||||
BS_ENV_DECLARE();
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
WiFi.persistent(false);
|
||||
WiFi.begin(STA_SSID, STA_PASS);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
}
|
||||
BS_RUN(Serial);
|
||||
}
|
||||
|
||||
TEST_CASE("HTTP client GET request", "[HTTPClient]")
|
||||
{
|
||||
HTTPClient http;
|
||||
http.begin("http://httpbin.org/get?a=1&b=asdadf");
|
||||
auto httpCode = http.GET();
|
||||
CHECK(httpCode == HTTP_CODE_OK);
|
||||
String payload = http.getString();
|
||||
CHECK(payload.indexOf("\"a\": \"1\"") != -1);
|
||||
CHECK(payload.indexOf("\"b\": \"asdad\"") != -1);
|
||||
http.end();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user