Write CoreInterface unit testBRL-CAD
Status: ClosedTime to complete: 100 hrs Mentors: Popescu Andrei, Daniel_RTags: unit test, library, oop, testing, C++

The C++ Object-oriented API, called CoreInterface aims to provide an easier-to-use, object-oriented interface over the already very powerful set of BRL-CAD tools some of the primitives(classes representing objects have already been written)

You can check out the core interface code from our subversion repository: svn checkout https://svn.code.sf.net/p/brlcad/code/rt^3/trunk rt^3

Your task is to write a unit test for the sphere primitive. It should be put in rt^3/tests/

Code:

  • rt^3/src/coreInterface/Sphere.cpp
  • rt^3/include/brlcad/Sphere.h

Please upload your work in a svn patch(diff) format: svn diff rt^3 my_changes.patch

References:
  • rt^3/tests/halfspace.cpp
  • rt^3/tests/primitives.cpp
  • rt^3/tests/PrintTitle.cpp
Modify:
  • rt^3/tests/sphere.cpp -- you create this
  • rt^3/tests/CMakeLists.txt -- add your new file in here
Uploaded Work
File name/URLFile sizeDate submitted
Sphere.cpp3.4 KBDecember 18 2014 20:12 UTC
MarcSphere.patch6.6 KBDecember 19 2014 08:26 UTC
MarcSphere2.patch6.8 KBDecember 19 2014 09:13 UTC
MarcSphere3.patch6.6 KBDecember 19 2014 09:26 UTC
MarcSphere3.patch7.0 KBDecember 19 2014 09:33 UTC
MarcSphereFixed.patch6.9 KBDecember 19 2014 09:40 UTC
Comments
Marc Tannouson December 18 2014 10:10 UTCTask Claimed

I would like to work on this task.

Popescu Andrei on December 18 2014 10:11 UTCTask Assigned

This task has been assigned to Marc Tannous. You have 100 hours to complete this task, good luck!

Marc Tannouson December 18 2014 20:17 UTCSome quick review please?

I still have a few functions to test, but these were the ones approachable for a guy's first try on Object-Oriented-Programming. I literally have never worked with constructors before in C/C++ and hope that my syntax is not too bad, but there surely are some issues. I coded a bit of an unit test and would like to get some feedback on it before proceeding with the other functions, to make sure I am not failing something elementary.


Also, some stuff might be dumb ( like me creating a Vector3D center just to set the Sphere's center to that, but I honestly had no other approach, hope that's the correct one ) but please tell me where I'm making mistakes.


Obviously, I could compile it but I'm on a new distro and being a Linux newbie some things inevitably went wrong, but after a good night's sleep I should be able to fix them first thing tomorrow morning.


Thanks a lot for the quick reviews and helpful insights,


Marc

Marc Tannouson December 18 2014 20:17 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 19 2014 04:05 UTCTask Needs More Work

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

Sean on December 19 2014 04:10 UTCdefinitely on the right track

This is looking good and you're on the right track, but you're testing a few things that probably don't make sense to test and aren't testing a few others.  Plus (and Daniel or Andrei or someone else may correct me), I don't think the intention is for this unit test to be a stand-alone program.  Instead, it's meant to be added to the primitives.cpp file similar to how test_halfspace() from halfspace.cpp is added.


Instead of suggesting that you restructure or remove anything, I suggest changing main() to a test_sphere() function and adding that function to primitives.cpp ; and you'll consequently also want to make that function run all of the available tests instead of relying on an argv[4] test number or make the place calling your function invoke it many times to run all tests.


 

Marc Tannouson December 19 2014 08:27 UTCIRC

Andrei and D_Rossberg provided great help via IRC, submitted a patch according to what we discussed and Sean's comment here on my task.


No cascading if's, the Sphere is only added to the database if it passes all tests ( aka ok = 0 in the end ) to keep the function void just like halfspace.


Regards,


Marc

Marc Tannouson December 19 2014 08:27 UTCReady for review

The work on this task is ready to be reviewed.

Daniel_R on December 19 2014 08:57 UTCSome issues

Coding style: I know that the core interface itself follows a slightly different coding convention than the brlcad main trunk.  But the test program is following the conventions in the HACKING file (can be found in the brlcad/trunk).  Please take them into consideration, especially the brace style.


You should test the sphere created by the standard constructor for validness too.


Class name and type don't have to be "Sphere", but sph.Type() has to be Sphere::ClassName() (this is a static function).


Your local functions should be static (i.e. invisible by other files).

Daniel_R on December 19 2014 08:57 UTCTask Needs More Work

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

Marc Tannouson December 19 2014 09:15 UTCFixed

Coding style: Fixed, if braces are now on the same line, function braces on a new line.


Constructor created sphere : Tested for validness.


Sph.Type() : Verified if equal to Sph.ClassName().


Local Functions : Are now static int instead of int.

Marc Tannouson December 19 2014 09:15 UTCReady for review

The work on this task is ready to be reviewed.

Popescu Andrei on December 19 2014 09:18 UTCTask Needs More Work

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

Popescu Andrei on December 19 2014 09:18 UTC

You ve got two lines spanning at ~ 230 characters, that's way too much, try keeping them around 100 please

Marc Tannouson December 19 2014 09:26 UTCReady for review

The work on this task is ready to be reviewed.

Popescu Andrei on December 19 2014 09:35 UTCTask Needs More Work

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

Marc Tannouson December 19 2014 09:41 UTCSpacing

Fixed the spacing indenting issues, sorry for those, was in a hurry.


Regards,


Marc

Marc Tannouson December 19 2014 09:41 UTCReady for review

The work on this task is ready to be reviewed.

Popescu Andrei on December 19 2014 09:42 UTCTask Closed

Congratulations, this task has been completed successfully.