aboutsummaryrefslogtreecommitdiff
path: root/src/systemcmds
diff options
context:
space:
mode:
authorDaniel Agar <daniel@agar.ca>2015-01-03 18:48:43 -0500
committerDaniel Agar <daniel@agar.ca>2015-01-03 18:55:55 -0500
commita62baf2cb210535e1e7682a860adb5156233f5f0 (patch)
tree9a6aa2054f9bc98921d57c5d373ef259d9b3b317 /src/systemcmds
parent470d35aca18104b54e26c37b97c86788e91cee67 (diff)
downloadpx4-firmware-a62baf2cb210535e1e7682a860adb5156233f5f0.tar.gz
px4-firmware-a62baf2cb210535e1e7682a860adb5156233f5f0.tar.bz2
px4-firmware-a62baf2cb210535e1e7682a860adb5156233f5f0.zip
add simple nonsymmetric Matrix testing to test_mathlib
Diffstat (limited to 'src/systemcmds')
-rw-r--r--src/systemcmds/tests/module.mk2
-rw-r--r--src/systemcmds/tests/test_mathlib.cpp51
2 files changed, 51 insertions, 2 deletions
diff --git a/src/systemcmds/tests/module.mk b/src/systemcmds/tests/module.mk
index 6eed3922c..0dc333f0a 100644
--- a/src/systemcmds/tests/module.mk
+++ b/src/systemcmds/tests/module.mk
@@ -35,5 +35,5 @@ SRCS = test_adc.c \
test_mount.c \
test_mtd.c
-EXTRACXXFLAGS = -Wframe-larger-than=2500
+EXTRACXXFLAGS = -Wframe-larger-than=2500 -Wno-float-equal -Wno-double-promotion
diff --git a/src/systemcmds/tests/test_mathlib.cpp b/src/systemcmds/tests/test_mathlib.cpp
index 70d173fc9..9fa52aaaa 100644
--- a/src/systemcmds/tests/test_mathlib.cpp
+++ b/src/systemcmds/tests/test_mathlib.cpp
@@ -54,6 +54,7 @@ using namespace math;
int test_mathlib(int argc, char *argv[])
{
+ int rc = 0;
warnx("testing mathlib");
{
@@ -156,5 +157,53 @@ int test_mathlib(int argc, char *argv[])
TEST_OP("Matrix<10, 10> * Matrix<10, 10>", m1 * m2);
}
- return 0;
+ {
+ // test nonsymmetric +, -, +=, -=
+
+ float data1[2][3] = {{1,2,3},{4,5,6}};
+ float data2[2][3] = {{2,4,6},{8,10,12}};
+ float data3[2][3] = {{3,6,9},{12,15,18}};
+
+ Matrix<2, 3> m1(data1);
+ Matrix<2, 3> m2(data2);
+ Matrix<2, 3> m3(data3);
+
+ if (m1 + m2 != m3) {
+ warnx("Matrix<2, 3> + Matrix<2, 3> failed!");
+ (m1 + m2).print();
+ printf("!=\n");
+ m3.print();
+ rc = 1;
+ }
+
+ if (m3 - m2 != m1) {
+ warnx("Matrix<2, 3> - Matrix<2, 3> failed!");
+ (m3 - m2).print();
+ printf("!=\n");
+ m1.print();
+ rc = 1;
+ }
+
+ m1 += m2;
+ if (m1 != m3) {
+ warnx("Matrix<2, 3> += Matrix<2, 3> failed!");
+ m1.print();
+ printf("!=\n");
+ m3.print();
+ rc = 1;
+ }
+
+ m1 -= m2;
+ Matrix<2, 3> m1_orig(data1);
+ if (m1 != m1_orig) {
+ warnx("Matrix<2, 3> -= Matrix<2, 3> failed!");
+ m1.print();
+ printf("!=\n");
+ m1_orig.print();
+ rc = 1;
+ }
+
+ }
+
+ return rc;
}