]> rtime.felk.cvut.cz Git - hubacji1/psp.git/commitdiff
Use refernces instead of pointers
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 22 Jul 2019 08:23:06 +0000 (10:23 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 22 Jul 2019 08:23:06 +0000 (10:23 +0200)
api/psp.h
ut/psp.t.cc

index 3b5f860f8d530ba8059e6ad32d4ed502f8449ab3..38b4d49eb959e565754757465309cac159656741 100644 (file)
--- a/api/psp.h
+++ b/api/psp.h
@@ -12,9 +12,9 @@
 */
 class PSPlanner {
         private:
-                BicycleCar *cc_ = nullptr;
-                BicycleCar *gc_ = new BicycleCar();
-                ParkingSlot *ps_ = new ParkingSlot();
+                BicycleCar cc_;
+                BicycleCar gc_;
+                ParkingSlot ps_;
         public:
                 // find entry
                 /*! \brief Find entry to the parking slot.
@@ -27,9 +27,9 @@ class PSPlanner {
                 void fer();
 
                 // getters, setters
-                BicycleCar *cc() { return this->cc_; }
-                BicycleCar *gc() { return this->gc_; }
-                ParkingSlot *ps() { return this->ps_; }
+                BicycleCar &cc() { return this->cc_; }
+                BicycleCar &gc() { return this->gc_; }
+                ParkingSlot &ps() { return this->ps_; }
 
                 PSPlanner();
 };
index 1b350b736ec19c3e4b17edb4dba37ce906c0cfa6..7c82b110f283d215004cb750256a755a6393d7c5 100644 (file)
@@ -5,20 +5,19 @@
 
 WVTEST_MAIN("parking slot planner basic test")
 {
-        PSPlanner *psp = new PSPlanner();
-        psp->ps()->border(3, 3, 5, 3, 5, 8, 3, 8);
-        psp->gc()->x(4);
-        psp->gc()->y(4);
-        psp->gc()->h(M_PI / 2);
-        psp->gc()->mtr(10);
-        psp->gc()->wb(2);
-        psp->gc()->w(1);
-        psp->gc()->l(3);
-        psp->gc()->he(1.5);
-        psp->gc()->df(2 + 0.5);
-        psp->gc()->dr(0.5);
+        PSPlanner psp;
+        psp.ps().border(3, 3, 5, 3, 5, 8, 3, 8);
+        psp.gc().x(4);
+        psp.gc().y(4);
+        psp.gc().h(M_PI / 2);
+        psp.gc().mtr(10);
+        psp.gc().wb(2);
+        psp.gc().w(1);
+        psp.gc().l(3);
+        psp.gc().he(1.5);
+        psp.gc().df(2 + 0.5);
+        psp.gc().dr(0.5);
 
         // init orientation
-        WVPASS(psp->gc() != nullptr);
-        WVPASSEQ_DOUBLE(psp->ps()->heading(), psp->gc()->h(), 0.00001);
+        WVPASSEQ_DOUBLE(psp.ps().heading(), psp.gc().h(), 0.00001);
 }