-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.h
42 lines (32 loc) · 1.54 KB
/
tests.h
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
#include "ShroomGroom.h"
#include <Arduino.h>
bool test(String name, ShroomGroom* shroom, float minHumidity, float maxHumidity, float currentHumidity1, float currentHumidity2, bool fanExpected, bool diffusorExpected){
Serial.begin(9600);
shroom->setMinHumidity(minHumidity);
shroom->setMaxHumidity(maxHumidity);
shroom->setCurrent(20, 23, currentHumidity1, currentHumidity2);
Serial.println("TEST: " + name);
Serial.println("minHumidity: " + String(minHumidity));
Serial.println("maxHumidity: " + String(maxHumidity));
Serial.println("currentHumidity1: " + String(currentHumidity1));
Serial.println("currentHumidity2: " + String(currentHumidity2));
bool fan = shroom->shouldFan();
bool diffuse = shroom->shouldDiffuse();
Serial.println("Fan Expected: " + String(fanExpected) + " / fan: " + String(fan));
Serial.println("Diffusior Expected: " + String(diffusorExpected) + " / diffusor: " + String(diffuse));
if (fan == fanExpected && diffuse == diffusorExpected){
return true;
}
return false;
}
void runTests(ShroomGroom* shroom){
test ("everything in range", shroom, 80, 90, 85, 85, false, false);
delay(1000);
test ("humidity1 too low", shroom, 80, 90, 79.02, 82, false, true);
delay(1000);
test ("humidity1 and humidity2 too low", shroom, 80, 90, 79.02, 60.987, false, true);
delay(1000);
test ("humidity2 too high, humidity1 too low", shroom, 80, 90, 75.9, 93, true, true);
delay(1000);
test ("humidity too high on both sensors", shroom, 80, 90, 98, 92, true, false);
}