diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-04 01:32:46 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-04 01:32:46 +0100 |
commit | c241fca8fe040cea341493e44a656b0cfd1bc8cb (patch) | |
tree | 96a8c5ab8eb7fdbff9aa02b3749cea329071196d /src | |
parent | 5f147f3a6f9c823d1835646739ecb49a5a64e34b (diff) | |
parent | a62baf2cb210535e1e7682a860adb5156233f5f0 (diff) | |
download | px4-firmware-c241fca8fe040cea341493e44a656b0cfd1bc8cb.tar.gz px4-firmware-c241fca8fe040cea341493e44a656b0cfd1bc8cb.tar.bz2 px4-firmware-c241fca8fe040cea341493e44a656b0cfd1bc8cb.zip |
Merge branch 'matrix_tests' of github.com:dagar/Firmware
Diffstat (limited to 'src')
-rw-r--r-- | src/systemcmds/tests/module.mk | 2 | ||||
-rw-r--r-- | src/systemcmds/tests/test_mathlib.cpp | 51 |
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; } |