#include "testlib.h" int main(int argc, char *argv[]) { setName("Checker for 'Single Copter'"); registerTestlibCmd(argc, argv); int n = inf.readInt(); for (int i = 0; i < n; ++i) { double p = inf.readDouble(); double r = inf.readDouble(); double y = inf.readDouble(); double maxAns = 0; for (int o = 0; o < 4; ++o) { double ansOutput = ans.readDouble(); maxAns = std::max(maxAns, std::abs(ansOutput)); } double cont[4]; double maxCont = 0; for (int o = 0; o < 4; ++o) { cont[o] = ouf.readDouble(); maxCont = std::max(maxCont, std::abs(cont[o])); } double contPitch = cont[1] - cont[3]; double contRoll = cont[0] - cont[2]; double contYaw = cont[0] + cont[1] + cont[2] + cont[3]; if (std::abs(p - contPitch) > 1e-6) { quitf(_wa, "Line %d: pitch expected %lf, found %lf", i + 1, p, contPitch); } if (std::abs(r - contRoll) > 1e-6) { quitf(_wa, "Line %d: roll expected %lf, found %lf", i + 1, r, contRoll); } if (std::abs(y - contYaw) > 1e-6) { quitf(_wa, "Line %d: yaw expected %lf, found %lf", i + 1, y, contYaw); } if (maxCont > maxAns + 1e-6) { quitf(_wa, "Line %d: maximum too large, expected %lf, found %lf", i + 1, maxAns, maxCont); } } quitf(_ok, "All lines good enough"); }