diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | test_volume_flow_rate.c | 15 | ||||
| -rw-r--r-- | unit.c | 37 |
3 files changed, 47 insertions, 7 deletions
@@ -5,7 +5,7 @@ SRC = main.c microui.c renderer.c widget.c ui.c unit.c engine.c OBJ = ${SRC:.c=.o} HDR = microui.h renderer.h widget.h ui.h unit.h engine.h -TEST_SRC = test.c test_angular_speed.c test_pressure.c test_volume.c unit.c +TEST_SRC = test.c test_angular_speed.c test_pressure.c test_volume.c test_volume_flow_rate.c unit.c TEST_OBJ = ${TEST_SRC:.c=.o} volute: ${OBJ} diff --git a/test_volume_flow_rate.c b/test_volume_flow_rate.c index 148d58f..4c4d3c7 100644 --- a/test_volume_flow_rate.c +++ b/test_volume_flow_rate.c @@ -1,32 +1,35 @@ +#include <assert.h> +#include <stdio.h> + #include "test.h" #include "unit.h" void test_cubic_metre_per_sec(void) { - assert(0); + test(cubic_metre_per_sec(123.456), 123.456); } void test_cubic_metre_per_min(void) { - assert(0); + test(cubic_metre_per_min(123.456), 2.0576); } void test_cubic_foot_per_min(void) { - assert(0); + test(cubic_foot_per_min(123.456), 0.0582647436); } void test_as_cubic_metre_per_sec(void) { - assert(0); + test(as_cubic_metre_per_sec(cubic_metre_per_sec(123.456)), 123.456); } void test_as_cubic_metre_per_min(void) { - assert(0); + test(as_cubic_metre_per_min(cubic_metre_per_min(123.456)), 123.456); } void test_as_cubic_foot_per_min(void) { - assert(0); + test(as_cubic_foot_per_min(cubic_foot_per_min(123.456)), 123.456); } @@ -12,6 +12,12 @@ /* Metres per inch. */ #define M_PER_IN 0.0254 +/* Metres per foot. */ +#define M_PER_FT 0.3048 + +/* Seconds per minute. */ +#define SEC_PER_MIN 60.0 + AngularSpeed rad_per_sec(double x) { @@ -133,3 +139,34 @@ double as_cubic_inch(double x) { return x / 1.6387064e-5; } + + +VolumeFlowRate +cubic_metre_per_sec(double x) { + return x; +} + +VolumeFlowRate +cubic_metre_per_min(double x) { + return x / SEC_PER_MIN; +} + +VolumeFlowRate +cubic_foot_per_min(double x) { + return x * pow(M_PER_FT, 3) / SEC_PER_MIN; +} + +double +as_cubic_metre_per_sec(VolumeFlowRate x) { + return x; +} + +double +as_cubic_metre_per_min(VolumeFlowRate x) { + return x * SEC_PER_MIN; +} + +double +as_cubic_foot_per_min(VolumeFlowRate x) { + return x * SEC_PER_MIN / pow(M_PER_FT, 3); +} |