-
Notifications
You must be signed in to change notification settings - Fork 279
/
Copy pathtestUrlDecode.ino
64 lines (42 loc) · 1.14 KB
/
testUrlDecode.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <ESP8266WiFi.h>
#include "aREST.h"
aREST arest;
int initialMemory;
void setup() {
Serial.begin(115200);
Serial.println("\n\nBegin test");
}
bool output = true;
bool test(String test, String expected) {
arest.urldecode(test);
if(output) {
Serial.print("|");
Serial.print(test);
Serial.print("| ");
Serial.println(test == expected ? "Pass" : "Fail");
}
return test == expected;
}
int iters = 0;
void loop() {
bool passed =
test("Hello+World", "Hello World") &&
test("I+love+%25%25%25percents%25%25%25", "I love %%%percents%%%") &&
test("", "") &&
/* Malformed */
test("%", "%") &&
test("%1", "%1") &&
test("I hate percents%", "I hate percents%") &&
test("I hate percents%2", "I hate percents%2");
if(!passed) {
Serial.print("TESTS FAILED!");
}
if(iters == 0)
initialMemory = ESP.getFreeHeap();
int memEnd = ESP.getFreeHeap();
iters++;
Serial.printf("%d iterations; Memory loss [[[ %d ]]]\n", iters, memEnd - initialMemory);
if(output)
delay(1500);
output = false;
}