;+ ; This test fails because the assertion is wrong. ;- function findgentest::test1 a = findgen(5) assert, n_elements(a) eq 6, 'Wrong number of elements' return, 1 end ;+ ; This test should pass the assertion and return 1 (i.e. success). Tests can ; also return 0 or generate an error to indicate failure. ;- function findgentest::test2 a = findgen(5) assert, array_equal(a, [0.0, 1.0, 2.0, 3.0, 4.0]), 'Correct elements' return, 1 end ;+ ; This is a test that will pass because the code of the test is supposed to ; cause an error. To do this kind of test, use the "error_is_pass" batch file. ;- function findgentest::test3 @error_is_pass a = findgen('string') return, 0 end ;+ ; This is a test that will fail on an io error because of the use of the ; "error_is_fail" batch file. IO errors don't normally cause a test to fail. ;- function findgentest::test4 @error_is_fail a = findgen('another_string') return, 1 end ;+ ; Inherit from MGtestCase. ; ; @file_comments To create a test case just inherit from MGtestCase and create ; method with names that start with "test". This test can be run ; with the command: mgunit, cases='findgentest' ;- pro findgentest__define define = { findgentest, inherits MGtestCase } end