#94 Unit test has been written for src/libbu/bitv.c

closed-accepted
5
2012-05-25
2012-05-16
anuragmurty
No

Unit test for testing of src/libbu/bitv.c has been written with appropriate changes to CMakelists.txt and Makefile.am

Discussion

1 2 > >> (Page 1 of 2)
  • Your patch needs some work. Here are some hints what's missing:
    - missing indentation inside main()
    - main() parameters (argn/argv) are missing, even if they won't be unused
    - you should return an error code other than 0 if the test failed

     
  • anuragmurty
    anuragmurty
    2012-05-21

    thanks for your comment d_rossberg. i have made the changes yyou suggested and re-submitted a new patch.

     
  • Next you have to follow the
    - "1) Indentation whitespace" and
    - "4) Names"
    section in HACKING (see e.g. your PASS variable).

    Furthermore, you should look for consistent newlines. E.g. you have sometimes 1 and sometimes 2 newlines between the functions. Sometimes no newline and then 1 or 2 inside a function. Look at the other BRL-CAD sources. Use 1 newline inside the functions to structure and 2 newlines between functions.

     
  • anuragmurty
    anuragmurty
    2012-05-24

    Thanks again d_rossberg. I have changed the variable names, the indentation and have made the newlines more consistent(2 b/w functions and 1 inside).

     
  • - You should structure your code with empty lines. Many functions are monolithic blocks. Look at the other test_~ programs in libbu to get an idea what I mean.
    - There is a similar empty-line issue in your Makefile.
    - Every 8 blanks at the beginning of a line should be replaced by 1 tab.
    And
    - The test fails at bu_hex_to_bitv: "ERROR: bitv length is not a multiple of two. Illegal hex bitv: [303]"

     
  • anuragmurty
    anuragmurty
    2012-05-24

    thanks for your comments once again!
    no more monolithic blocks now. 8 spaces have been replaced by tabs.
    i have changed the Makefile too.

    just one query:
    when the input is "303" an error output is the RIGHT output since we cannot give in an odd number of digits for a hex input to bu_hex_to_bitv.. It SHOULD return a null pointer which is part of the code.
    error output printed is from bu_hex_to_bitv. so probably i should make changes in the bu_hex_to_bitv command suppressing the error message when it is called from a test.
    or is there a better method to do the same?

     
  • bu_hex_to_bitv() should stay as it is. You could give a short message in your test, something like: "Intentionally evoking an error here, a message about it is normal".

     
  • anuragmurty
    anuragmurty
    2012-05-25

    thanks! uploaded the new patch with the modified makefile, and the error message and the newlines. (test_bitv3.patch)

     
  • Almost.
    Please consider "3) Braces" from HACKING as well.

     
  • anuragmurty
    anuragmurty
    2012-05-25

    braces.

     
    Attachments
1 2 > >> (Page 1 of 2)