+/*
+ * SPDX-FileCopyrightText: 2021 Jiri Vlasak <jiri.vlasak.2@cvut.cz>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
#include <cmath>
#include "wvtest.h"
-#include "pslot.h"
+#include "pslot.hh"
+
+using namespace bcar;
WVTEST_MAIN("pslot basic geometry")
{
- ParkingSlot *ps = new ParkingSlot();
- ps->border(1, 1, 3, 3, 2, 4, 0, 2);
-
- // slot info
- WVPASS(ps->right());
- WVPASS(!ps->parallel());
- WVPASSEQ_DOUBLE(ps->heading(), M_PI * 3 / 4, 0.00001);
+ ParkingSlot ps(Point(1.0, 1.0), 3.0 * M_PI / 4.0, sqrt(8.0), sqrt(2.0));
+ WVPASSEQ_DOUBLE(ps.lrx(), 1.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.lry(), 1.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.rrx(), 3.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.rry(), 3.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.rfx(), 2.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.rfy(), 4.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.lfx(), 0.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.lfy(), 2.0, 0.00001);
+ WVPASS(ps.right());
+ WVPASS(!ps.parallel());
+ WVPASSEQ_DOUBLE(ps.h(), M_PI * 3.0 / 4.0, 0.00001);
+ Point p(ps.lfx(), ps.lfy());
+ ps = ParkingSlot(p, 7.0 * M_PI / 4.0, sqrt(8.0), sqrt(2.0));
+ ps.swap_side();
+ WVPASSEQ_DOUBLE(ps.lrx(), 0.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.lry(), 2.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.rrx(), 2.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.rry(), 4.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.rfx(), 3.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.rfy(), 3.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.lfx(), 1.0, 0.00001);
+ WVPASSEQ_DOUBLE(ps.lfy(), 1.0, 0.00001);
+ WVPASS(!ps.right());
+ WVPASS(!ps.parallel());
+ WVPASSEQ_DOUBLE(ps.h(), -M_PI / 4.0, 0.00001);
}