Add sandbox_c cmake project + ccache workflow for pool testing
This commit is contained in:
1 parent
fb253f9b27
commit
ba41deb9ec
9 files changed
+160
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#include "temperature.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
assert(fabs(to_fahrenheit(0.0) - 32.0) < 1e-9);
|
||||
assert(fabs(to_fahrenheit(100.0) - 212.0) < 1e-9);
|
||||
|
||||
Reading r;
|
||||
assert(parse_reading("{\"sensor\":\"attic\",\"celsius\":21.50}", &r) == 0);
|
||||
assert(strcmp(r.sensor, "attic") == 0);
|
||||
assert(fabs(r.celsius - 21.5) < 1e-9);
|
||||
assert(parse_reading("{\"celsius\":-300.0}", &r) == 0);
|
||||
assert(fabs(clamp_to_absolute_zero(r.celsius) + 273.15) < 1e-9);
|
||||
assert(parse_reading("nonsense", &r) != 0);
|
||||
|
||||
char buf[128];
|
||||
Reading in = { "boiler", 65.25 };
|
||||
assert(format_reading(&in, buf, sizeof buf) == 0);
|
||||
assert(strstr(buf, "\"sensor\":\"boiler\"") != NULL);
|
||||
|
||||
puts("all tempsense assertions passed");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user