octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to do thorough testing


From: John Swensen
Subject: How to do thorough testing
Date: Thu, 23 Sep 2010 23:49:02 -0400

I know that most (if not all) of the m files that ship with octave have tests 
at the end.  However, a quick glance through showed that most of the tests are 
just a couple of lines long. For the work I am doing on imread and imwrite, I 
want to perform so pretty thorough testing to see if things are working right 
and this has brought up a few questions:

1) is there a place I can put tests that really don't need to ship with Octave 
in the m files (it seems these don't get stripped out as part of the install 
step)?  I can imagine that my exhaustive testing will probably end up being on 
the order of a hundred(s) lines of code.
2) I see there is a toplevel 'test' directory, but this seems to be for very 
highlevel testing of Octave and the interpreter.
3) If there is an alternate location to put tests that aren't going to be 
distributed, does it really need to have the "%!" in front of every single 
line?  I noticed that in the toplevel 'test' directory that every line is 
preceded by "%!".  Now, maybe I am just being lazy as I could easily write a 
little script to process a file and prepend this to every line, but if there is 
a non-"at the end of m files" method of testing then it might be nice to not 
have to prepend every single line.
4) Also, for the image tests, I would like to put a set of images that I know 
have certain properties into the repository to use for testing purposes. A 
dedicated location for long tests would also provide a reasonable place for 
these images.

John Swensen

FYI, this is the kind of testing I am planning (some of this is pseudo-code). 
As you can see, between supporting function and the tests themselves, it will 
be pretty long, and IMO not appropriate for the end of an m-file.

im_double = rand (480,640); 
im_logical = (im_double > 0.5);
im_u8 = uint8 (im_double*256);
im_u16 = uint8 (im_double*65536);
im_float = single (im_double).

accepted_formats = __magick_format_list__ ();
for I = 1:length (accepted_formats)

### Test imwrite
  # (1)
  # Test each of logical, u8, u16, float, and double against each of the 
  filename = [ "test." accepted_formats(I)];
  imwrite (im_logical, filename);
  output = system ( ['gm identify ' filename]);
  <do some regexp stuff here to pull out file information>
  <compare actual file information to expected file information> 

  # repeat above for u8, 16, float, and double

  # (2)
  # Test each of the possible parameters (this will be format specific)
  

### Test imread
  # (3)
  # 
  <read in all the test images and verify sizes, datatypes, and channels are 
correct>

endfor







reply via email to

[Prev in Thread] Current Thread [Next in Thread]