! infunit.inf - test the test harness infunit.h ! Version 1.0 (19-Sep-2001) ! ! by Matt Albrecht - groboclown@users.sourceforge.net ! ! (If you need to edit this file, note that indentations are 4 spaces ! and tabs are not used.) ! ! This has been donated to the Public Domain. Use, abuse, and don't blame me. ! Message "Compiling Inform-Unit unit tests"; Include "infunit"; ! Not optimized version Include "fixedpt"; !------------------------------------------------------------------------------ [Main; ! Note: do not follow this testing pattern for your unit tests. testAssertTrue(); testAssertEquals(); testAssertNotNothing(); testFail(); report(); ]; !------------------------------------------------------------------------------ [ testAssertTrue ; _testIURoutine( __testAssertTrue1, "assertTrue", false ); _testIURoutine( __testAssertTrue2, "assertTrue", true ); ]; [ __testAssertTrue1 ; assertTrue( true, "AssertTrue not correct." ); print "Should be reached.^"; ]; [ __testAssertTrue2 ; assertTrue( false, "Ignore: assertTrue Correctly working." ); print "** Should not be reached **^"; ]; !------------------------------------------------------------------------------ [ testAssertEquals ; _testIURoutine( __testAssertEquals1, "assertEquals", false ); _testIURoutine( __testAssertEquals2, "assertEquals", true ); ]; [ __testAssertEquals1 ; assertEquals( 0, 0, "AssertEquals not correct." ); print "Should be reached.^"; ]; [ __testAssertEquals2 ; assertEquals( 1, 0, "Ignore: assertEquals Correctly working." ); print "** Should not be reached **^"; ]; !------------------------------------------------------------------------------ [ testAssertNotNothing ; _testIURoutine( __testAssertNotNothing1, "assertNotNothing", false ); _testIURoutine( __testAssertNotNothing2, "assertNotNothing", true ); ]; Object SampleObject; [ __testAssertNotNothing1 ; assertNotNothing( SampleObject, "AssertNotNothing not correct." ); print "Should be reached.^"; ]; [ __testAssertNotNothing2 ; assertNotNothing( nothing, "Ignore: assertNotNothing Correctly working." ); print "** Should not be reached **^"; ]; !------------------------------------------------------------------------------ [ testFail ; _testIURoutine( __testFail1, "fail", true ); ]; [ __testFail1 ; fail( "Ignore: fail Correctly working." ); print "** Should not be reached **^"; ]; !------------------------------------------------------------------------------ [ _testIURoutine routine routineName generatesError ! parameters origTestCount origErrCount; !locals origTestCount = infunit__testCount; origErrCount = infunit__errorCount; ++origTestCount; infunit__testCount = 0; infunit__errorCount = 0; StartTest( routine ); if (infunit__testCount ~= 1) { print "Error: ",(string)routineName, " did not increase test count by 1.^"; ++origErrCount; } if (generatesError == true) { if (infunit__errorCount ~= 1) { print "Error: ",(string)routineName, " did not increase error count by 1.^"; ++origErrCount; } } else { if (infunit__errorCount ~= 0) { print "Error: ",(string)routineName, " did not keep error count the same.^"; ++origErrCount; } } infunit__testCount = origTestCount; infunit__errorCount = origErrCount; ];