Create unit tests for plane.c point functionsBRL-CAD
Status: ClosedTime to complete: 72 hrs Mentors: SeanTags:

There are more than 300 library functions in our core LIBBN library. As a core library used by nearly every one of BRL-CAD's tools, testing those functions for correct behavior is important.

References:

  • include/bn.h
  • include/plot3.h
  • include/vmath.h
  • src/libbn/qmath.c
  • src/libbu/tests/*.c (note libbu, not libbn for examples)
  • src/libbn/tests/*.c

Code:

  • src/libbn/tests/qmath.c
  • src/libbn/tests/CMakeLists.txt

This task involves implementing a new unit test for any of LIBBN's plane.c public point functions:

grep -E '^bn' plane.c  | sort | cut -f1 -d\( | sort | grep pt | grep -v _dist_ | grep -v _isect_

Uploaded Work
File name/URLFile sizeDate submitted
plane_pt.diff12.7 KBNovember 26 2013 18:57 UTC
plane_pt_rev2.diff12.6 KBNovember 26 2013 23:37 UTC
plane_pt_rev3.diff12.6 KBNovember 26 2013 23:53 UTC
plane_pt_rev4.diff12.4 KBNovember 28 2013 15:38 UTC
plane_pt_rev5.diff12.4 KBNovember 29 2013 15:21 UTC
Comments
Peter Amidonon November 20 2013 03:08 UTCTask Claimed

I would like to work on this task.

Sean on November 20 2013 03:09 UTCTask Assigned

This task has been assigned to Andromeda Galaxy. You have 72 hours to complete this task, good luck!

Melange on November 23 2013 03:09 UTCInitial Deadline passed

Melange has detected that the initial deadline has passed and it has set the task status to ActionNeeded. The student has 24 hours to submit the work before the task is reopened and sent back to the pool for other students to claim.

Melange on November 24 2013 03:09 UTCTask Reopened

Melange has detected that the final deadline has passed and it has reopened the task.

Peter Amidonon November 26 2013 18:13 UTCTask Claimed

I would like to work on this task.

Daniel Rossberg on November 26 2013 18:40 UTCTask Assigned

This task has been assigned to Andromeda Galaxy. You have 72 hours to complete this task, good luck!

Peter Amidonon November 26 2013 18:57 UTCReady for review

The work on this task is ready to be reviewed.

erikg on November 26 2013 21:42 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.

erikg on November 26 2013 23:28 UTCA couple minor issues

First, I'd like to say great work, this is a very good patch, but it's not quite perfect yet.


 


Typically, a patch is generated from the projects top source directory, otherwise we don't know where to apply it (there was no instruction to cd to src/libbn/tests/ before applying).


 


The CHECK_RESULT macro damages readability, I think. When a function ends with that macro, my first feeling is that the function is wrong because it doesn't actually return a value, it takes digging to find it. One could reduce the macro into a substitution so it could be returned, and at that point, the macro doesn't feel like it adds anything at all.


The POINT_SCANF_GEN macro seems a bit off to me. Instead of a macro to scan to floats (that are not macro local) and shoving them into doubles, why not just scan into doubles (using %lf)?


I'd argue that neither macro makes the code more readable, so both should be removed...


Otherwise, excellent work!


 -Erik

Peter Amidonon November 26 2013 23:37 UTCReady for review

The work on this task is ready to be reviewed.

Sean on November 28 2013 07:48 UTCfew minor corrections

Andromeda, this is looking fantastic but I did notice a few issues that need to be corrected in order to apply the patch.  Still overall, this looks really good.  Hope you tackle some more test cases!


The issues I saw on quick review were:



  • file name in comment header is wrong

  • functions not marked static

  • not using V3ARGS()

  • using capitals for non-constant non-global variables is frowned upon (e.g., A, PT, DIR)

  • you use EQUAL() for integer comparisons, just use != and ==


Also, not as critical an issue, but init_tol() involves a function call and a struct copy when a simple #define TOL_INIT {BN_TOL_MAGIC, BN_TOL_DIST, BN_TOL_DIST * BN_TOL_DIST, ...} would  have sufficed so you could do: struct bn_tol tol = TOL_INIT;

 

Sean on November 28 2013 07:49 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.

Peter Amidonon November 28 2013 15:38 UTCReady for review

The work on this task is ready to be reviewed.

Sean on November 29 2013 05:04 UTCcommas

One issue remaining that I didn't catch the first time: commas.  See our HACKING file for several examples, but basically a space is expected after all of the C-syntactic commas (i.e., not those related to scanf parsing).  Here are a couple examples where you compress them:


bn_mk_plane_3pts(plane,a,b,c,tol);


return test_bn_3pts_collinear(argc,argv);


Since you are relying on compressed form for scanf parsing, that means we cannot auto-format this file so you'll need to manually review all of your commas to ensure there's a space after all of them except for those related to input scanning.


The rest fo the changes look spot-on.  Nice work.  I also realize now that I'd suggested V3ARGS but you cannot (presently) use that with sccanf-style arguments.  If you like, I can create a follow-on task to fix that. ;)


 

Sean on November 29 2013 05:04 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 November 29 2013 05:04 UTCDeadline extended

The deadline of the task has been extended with 1 days and 0 hours.

Peter Amidonon November 29 2013 15:23 UTCReady for review

The work on this task is ready to be reviewed.

Sean on November 30 2013 04:57 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on November 30 2013 05:14 UTCnot in sync

Andromeda, now that looks pretty good.  Only found two issues.  I ran into a conflict patching src/libbn/tests/CMakeLists.txt so make sure that you do run "svn up" and resolve any conflicts prior to creating your patches with "svn diff".  Also, the test binary segfaults/crashes if you run it without any arguments (make src/libbn/tests/tester_bn_plane_pt).  I applied fixes to both starting with r58716, you're encouraged to review them for future reference.


What's next? :)