List of commits:
Subject Hash Author Date (UTC)
Replace matlab_xunit by newer version and register as submodule 9632e49f347b134641aee897729b05ad6db2cef4 Jason Hoelscher-Obermaier 2017-03-01 08:51:41
Adapt entanglement_evaluation_test to potential change in relative sign of mode fcts 994e925215553d620a8cf6a6c1dcac3d3a0b46bb Jason Hoelscher-Obermaier 2017-02-28 17:06:30
Add test for checking result of mode function calculation 808efd738f0056c2f61a1fb93ca39163ef4a699d Jason Hoelscher-Obermaier 2017-02-28 16:33:16
Insures accurate ON and improve speed f285f3fb89a63b3f01c4a9e54cc97218bf9407eb Jason Hoelscher-Obermaier 2017-02-24 16:51:21
Toggle matrix size mismatch e5dc8b2e1509750d4c2d32bd037d9eab5932da63 Jason Hoelscher-Obermaier 2017-02-24 16:44:00
ON-isation algorithm, much (~100 times) slower than m_gs but yields far (~1e14 times) better orthogonality precision. 8794b11475ada039c000bdc314e7c4ddd4f32b64 Jason Hoelscher-Obermaier 2017-02-21 13:02:13
When m_GS fails to pass ON-ity test, the ON-isation is done with Householder method (which is slower, but not dramatically slower). ON_ity is tested again after Householder. cf29269fae6d698ddb7e4cc8e831db3933325c2d Jason Hoelscher-Obermaier 2017-02-21 11:00:35
Add test for pulse_pairs_coverage to entanglement_evaluation_test.m e3e72443e0acce38cf9de712f32dd57dde7f069a Jason Hoelscher-Obermaier 2017-02-18 17:52:05
Refactor: Improve folder structure of repository ba05dd281e1351d6524058fc395912ea2da25e3a Jason Hoelscher-Obermaier 2017-02-18 15:33:57
Move importCrossCorrelationFunctions to @entanglement_evaluation_obsolete a7eeed4248479b1a6ef4c5f7895cc723f0cd0c0b Jason Hoelscher-Obermaier 2017-02-18 15:32:41
Refactor: Remove obsolete functions export_fields_from_ev and storeEvaluationObject 2f32101be0943a5dc2aeb1c898d243ab7cbf0c74 Jason Hoelscher-Obermaier 2017-02-18 15:30:51
Refactor: Move correlation-fct-based stuff from entanglement_evaluation to entanglement_evaluation_obsolete 731a121618cf46705a49ef5b48c6de64df559312 Jason Hoelscher-Obermaier 2017-02-18 10:30:43
Turn pulse_Q, pulse_P etc into dependent properties 87b52c9451c88a4779ea065b53a11748f6ffa0c6 Jason Hoelscher-Obermaier 2017-02-17 18:59:13
Add test to check for compatibility of future versions with inverted evaluation as of now 22daa5f0c4f2f0a1950442517adf89e380548bfe Jason Hoelscher-Obermaier 2017-02-17 09:46:34
Aesthetic 66a8585916657f0bcf2e106b2235730a59138f5c Jason Hoelscher-Obermaier 2017-02-17 13:57:49
Improve calculation of modefunctions (such that orthonormalization is more likely to succeed) 754e283187e9e9a6385b0f9a8a26f5fd2807ccd0 Jason Hoelscher-Obermaier 2017-02-16 12:10:30
Adapt calculate_mode_vectors_gammalist and calculateModeVectors to properly check for orthonormality 21518c79132770339704341beb22d4c0c34fe15d Jason Hoelscher-Obermaier 2017-02-16 12:07:50
Reformulate orthonormality_test to give more information about the reason of failure 3dc41307e864ba1de33b0e8a36ccb0a94a488e24 Jason Hoelscher-Obermaier 2017-02-16 12:05:39
Cosmetics.. c2a2487f7ef09fcc77194f0882082e38871d77f9 Jason Hoelscher-Obermaier 2017-02-16 10:08:45
Orthonormality test function to warn us if modified Grahm-Schmid algo failed. Added to 'auxfunctions'? d2aab5cb7009041a1dd2f66603b734013a6b9980 Corentin Gut 2017-02-15 15:37:49
Commit 9632e49f347b134641aee897729b05ad6db2cef4 - Replace matlab_xunit by newer version and register as submodule
Had to adapt tests to avoid a future warning regarding the removal of "initTestSuite"-script.
This should make the tests compatible with all current versions of MATLAB
(whereas without the change they should have failed on 2016a and newer).
Author: Jason Hoelscher-Obermaier
Author date (UTC): 2017-03-01 08:51
Committer name: Jason Hoelscher-Obermaier
Committer date (UTC): 2017-03-01 08:51
Parent(s): 994e925215553d620a8cf6a6c1dcac3d3a0b46bb
Signer:
Signing key:
Signing status: N
Tree: 798ea1c83264556fc0877ac61954d0ce6897d5f5
File Lines added Lines deleted
.gitmodules 3 0
data_analysis/unittests/PXItrace_test.m 4 2
data_analysis/unittests/blocked_cross_correlation_test.m 11 10
data_analysis/unittests/entanglement_evaluation_test.m 16 14
data_analysis/unittests/homo_measurement_test.m 3 1
data_analysis/unittests/homotrace_test.m 3 1
data_analysis/unittests/matlab_xunit 1 0
data_analysis/unittests/matlab_xunit_3_1_1/Readme.html 0 10
data_analysis/unittests/matlab_xunit_3_1_1/architecture/class_diagram_a.vsd 0 0
data_analysis/unittests/matlab_xunit_3_1_1/architecture/class_diagram_b.vsd 0 0
data_analysis/unittests/matlab_xunit_3_1_1/architecture/class_diagram_c.vsd 0 0
data_analysis/unittests/matlab_xunit_3_1_1/architecture/html/class_diagram_a.gif 0 0
data_analysis/unittests/matlab_xunit_3_1_1/architecture/html/class_diagram_b.gif 0 0
data_analysis/unittests/matlab_xunit_3_1_1/architecture/html/class_diagram_c.gif 0 0
data_analysis/unittests/matlab_xunit_3_1_1/architecture/html/matlab_xunit_architecture.html 0 652
data_analysis/unittests/matlab_xunit_3_1_1/architecture/matlab_xunit_architecture.m 0 346
data_analysis/unittests/matlab_xunit_3_1_1/architecture/testSample.m 0 8
data_analysis/unittests/matlab_xunit_3_1_1/doc/+abc/+tests/test_that.m 0 6
data_analysis/unittests/matlab_xunit_3_1_1/doc/+abc/+tests/test_this.m 0 6
data_analysis/unittests/matlab_xunit_3_1_1/doc/+abc_tests/test_that.m 0 6
data_analysis/unittests/matlab_xunit_3_1_1/doc/+abc_tests/test_this.m 0 6
data_analysis/unittests/matlab_xunit_3_1_1/doc/exException.m 0 67
data_analysis/unittests/matlab_xunit_3_1_1/doc/exQuickStart.m 0 48
data_analysis/unittests/matlab_xunit_3_1_1/doc/exRunSpecificTest.m 0 23
data_analysis/unittests/matlab_xunit_3_1_1/doc/exRunTestsInADirectory.m 0 17
data_analysis/unittests/matlab_xunit_3_1_1/doc/exRunTestsInPackage.m 0 30
data_analysis/unittests/matlab_xunit_3_1_1/doc/exSilentRunning.m 0 76
data_analysis/unittests/matlab_xunit_3_1_1/doc/exSubfunctionTests.m 0 33
data_analysis/unittests/matlab_xunit_3_1_1/doc/exTestCase.m 0 62
data_analysis/unittests/matlab_xunit_3_1_1/doc/exTestCaseSearching.m 0 42
data_analysis/unittests/matlab_xunit_3_1_1/doc/exTestFixtures.m 0 38
data_analysis/unittests/matlab_xunit_3_1_1/doc/exTolerance.m 0 89
data_analysis/unittests/matlab_xunit_3_1_1/doc/example_quick_start/testFliplrMatrix.m 0 7
data_analysis/unittests/matlab_xunit_3_1_1/doc/example_quick_start/testFliplrVector.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/doc/example_subfunction_tests/testFliplr.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/TestUsingTestCase.m 0 29
data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/testBadSinTest.m 0 9
data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/testCos.m 0 7
data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/testSetupExample.m 0 16
data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/testSin.m 0 4
data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/testWithSetupError.m 0 15
data_analysis/unittests/matlab_xunit_3_1_1/doc/file_exchange_description.txt 0 13
data_analysis/unittests/matlab_xunit_3_1_1/doc/helptoc.xml 0 47
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exException.html 0 158
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exQuickStart.html 0 143
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exRunSpecificTest.html 0 103
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exRunTestsInADirectory.html 0 91
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exRunTestsInPackage.html 0 116
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exSilentRunning.html 0 233
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exSubfunctionTests.html 0 122
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTestCase.html 0 175
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTestCaseSearching.html 0 136
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTestFixtures.html 0 129
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTolerance.html 0 192
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTolerance_eq28823.png 0 0
data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTolerance_eq55725.png 0 0
data_analysis/unittests/matlab_xunit_3_1_1/doc/index.html 0 8
data_analysis/unittests/matlab_xunit_3_1_1/doc/release-history.html 0 260
data_analysis/unittests/matlab_xunit_3_1_1/doc/screen-shot.png 0 0
data_analysis/unittests/matlab_xunit_3_1_1/doc/xunit_product_page.html 0 186
data_analysis/unittests/matlab_xunit_3_1_1/license.txt 0 27
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/Contents.m 0 24
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/compareFloats.m 0 104
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/containsRegexp.m 0 17
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/generateDoc.m 0 14
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/isAlmostEqual.m 0 46
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/isSetUpString.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/isTearDownString.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/isTestCaseSubclass.m 0 39
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/isTestString.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/parseFloatAssertInputs.m 0 64
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/assertAlmostEqual.m 0 52
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/mtest.m 0 75
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/MtestTest.m 0 39
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/cwd_test/TestCaseSubclass.m 0 20
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/cwd_test/testFoobar.m 0 5
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/cwd_test/testSubfunctions.m 0 11
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/testAssertAlmostEqual.m 0 40
data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/testIsAlmostEqual.m 0 41
data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/+subpkg/test_a_bit.m 0 9
data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/A.m 0 19
data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/B.m 0 6
data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/FooTest.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/helper_that.m 0 6
data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/test_that.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/test_this.m 0 5
data_analysis/unittests/matlab_xunit_3_1_1/tests/Readme.m 0 16
data_analysis/unittests/matlab_xunit_3_1_1/tests/RuntestsTest.m 0 115
data_analysis/unittests/matlab_xunit_3_1_1/tests/TestCaseTest.m 0 57
data_analysis/unittests/matlab_xunit_3_1_1/tests/TestCaseWithAddPathTest.m 0 29
data_analysis/unittests/matlab_xunit_3_1_1/tests/TestFuncHandleTests.m 0 111
data_analysis/unittests/matlab_xunit_3_1_1/tests/TestRunLoggerTest.m 0 53
data_analysis/unittests/matlab_xunit_3_1_1/tests/TestSuiteTest.m 0 113
data_analysis/unittests/matlab_xunit_3_1_1/tests/ThrowsExceptionTest.m 0 39
data_analysis/unittests/matlab_xunit_3_1_1/tests/almost_black.tif 0 0
data_analysis/unittests/matlab_xunit_3_1_1/tests/black.png 0 0
data_analysis/unittests/matlab_xunit_3_1_1/tests/black.tif 0 0
data_analysis/unittests/matlab_xunit_3_1_1/tests/cwd_test/TestCaseSubclass.m 0 20
data_analysis/unittests/matlab_xunit_3_1_1/tests/cwd_test/testFoobar.m 0 5
data_analysis/unittests/matlab_xunit_3_1_1/tests/cwd_test/testSubfunctions.m 0 11
data_analysis/unittests/matlab_xunit_3_1_1/tests/dir1/test_thatPasses.m 0 8
data_analysis/unittests/matlab_xunit_3_1_1/tests/dir2/test_thatFails.m 0 8
data_analysis/unittests/matlab_xunit_3_1_1/tests/empty_file 0 0
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/BadFixture.m 0 18
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/Contents.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/ExceptionNotThrownTest.m 0 13
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/FailingTestCase.m 0 20
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/LoggingTestCase.m 0 36
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/NoTestMethods.m 0 9
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/PassingExceptionTest.m 0 14
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/TestsToBeDiscovered.m 0 21
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/TwoPassingTests.m 0 17
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/WrongExceptionThrownTest.m 0 14
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/notTestString.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesA.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesB.m 0 20
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesC.m 0 22
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesD.m 0 21
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesE.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesTeardownNoSetup.m 0 13
data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testSimple.m 0 5
data_analysis/unittests/matlab_xunit_3_1_1/tests/testAssertEqual.m 0 49
data_analysis/unittests/matlab_xunit_3_1_1/tests/testAssertExceptionThrown.m 0 23
data_analysis/unittests/matlab_xunit_3_1_1/tests/testAssertFalse.m 0 25
data_analysis/unittests/matlab_xunit_3_1_1/tests/testAssertTrue.m 0 25
data_analysis/unittests/matlab_xunit_3_1_1/tests/testContainsRegexp.m 0 18
data_analysis/unittests/matlab_xunit_3_1_1/tests/testIsSetUpString.m 0 19
data_analysis/unittests/matlab_xunit_3_1_1/tests/testIsTearDownString.m 0 19
data_analysis/unittests/matlab_xunit_3_1_1/tests/testIsTestCaseSubclass.m 0 16
data_analysis/unittests/matlab_xunit_3_1_1/tests/testIsTestString.m 0 19
data_analysis/unittests/matlab_xunit_3_1_1/tests/testRuntestsWithDirectoryName.m 0 13
data_analysis/unittests/matlab_xunit_3_1_1/tests/test_TestSuiteInDir.m 0 24
data_analysis/unittests/matlab_xunit_3_1_1/tests/test_arrayToString.m 0 18
data_analysis/unittests/matlab_xunit_3_1_1/tests/test_assertElementsAlmostEqual.m 0 53
data_analysis/unittests/matlab_xunit_3_1_1/tests/test_assertFilesEqual.m 0 33
data_analysis/unittests/matlab_xunit_3_1_1/tests/test_assertVectorsAlmostEqual.m 0 68
data_analysis/unittests/matlab_xunit_3_1_1/tests/test_compareFloats.m 0 95
data_analysis/unittests/matlab_xunit_3_1_1/tests/test_comparisonMessage.m 0 25
data_analysis/unittests/matlab_xunit_3_1_1/tests/test_packageName.m 0 29
data_analysis/unittests/matlab_xunit_3_1_1/tests/test_parseFloatAssertInputs.m 0 119
data_analysis/unittests/matlab_xunit_3_1_1/tests/test_stringToCellArray.m 0 23
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/Contents.m 0 24
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/arrayToString.m 0 96
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/compareFloats.m 0 128
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/comparisonMessage.m 0 33
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/containsRegexp.m 0 17
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/generateDoc.m 0 14
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/isAlmostEqual.m 0 46
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/isSetUpString.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/isTearDownString.m 0 12
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/isTestCaseSubclass.m 0 39
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/isTestString.m 0 15
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/parseFloatAssertInputs.m 0 56
data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/stringToCellArray.m 0 14
data_analysis/unittests/matlab_xunit_3_1_1/xunit/CommandWindowTestRunDisplay.m 0 30
data_analysis/unittests/matlab_xunit_3_1_1/xunit/Contents.m 0 33
data_analysis/unittests/matlab_xunit_3_1_1/xunit/FunctionHandleTestCase.m 0 154
data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestCase.m 0 103
data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestCaseInDir.m 0 30
data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestCaseWithAddPath.m 0 53
data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestComponent.m 0 59
data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestComponentInDir.m 0 58
data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestRunDisplay.m 0 262
data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestRunLogger.m 0 104
data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestRunMonitor.m 0 35
data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestSuite.m 0 342
data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestSuiteInDir.m 0 50
data_analysis/unittests/matlab_xunit_3_1_1/xunit/VerboseTestRunDisplay.m 0 112
data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertElementsAlmostEqual.m 0 61
data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertEqual.m 0 43
data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertExceptionThrown.m 0 53
data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertFalse.m 0 31
data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertFilesEqual.m 0 68
data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertTrue.m 0 33
data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertVectorsAlmostEqual.m 0 59
data_analysis/unittests/matlab_xunit_3_1_1/xunit/info.xml 0 31
data_analysis/unittests/matlab_xunit_3_1_1/xunit/initTestSuite.m 0 55
data_analysis/unittests/matlab_xunit_3_1_1/xunit/runtests.m 0 160
data_analysis/unittests/permute_data_test.m 4 2
data_analysis/unittests/pseudo_hash_test.m 4 2
data_analysis/unittests/read_permute_write_data_test.m 4 2
data_analysis/unittests/timetrace_test.m 4 3
File .gitmodules changed (mode: 100644) (index 9e28965..1614928)
1 1 [submodule "misc/3rdparty/export_fig"] [submodule "misc/3rdparty/export_fig"]
2 2 path = misc/3rdparty/export_fig path = misc/3rdparty/export_fig
3 3 url = https://github.com/altmany/export_fig.git url = https://github.com/altmany/export_fig.git
4 [submodule "data_analysis/unittests/matlab_xunit"]
5 path = data_analysis/unittests/matlab_xunit
6 url = https://github.com/psexton/matlab-xunit
File data_analysis/unittests/PXItrace_test.m changed (mode: 100644) (index dcc3fa1..6cdf1d1)
1 1 function test_suite = PXItrace_test %#ok<STOUT> function test_suite = PXItrace_test %#ok<STOUT>
2 initTestSuite;
3
2 localFunctionHandles = cellfun(@str2func,...
3 which('-subfun', mfilename('fullpath')), 'UniformOutput', false);
4 test_suite = buildFunctionHandleTestSuite(localFunctionHandles);
5
4 6 function shared = setup function shared = setup
5 7 shared.DAQrange = 0; shared.DAQrange = 0;
6 8 shared.amplification = 10; shared.amplification = 10;
File data_analysis/unittests/blocked_cross_correlation_test.m changed (mode: 100644) (index 00ca511..eb65bab)
1 1 function test_suite = blocked_cross_correlation_test %#ok<STOUT> function test_suite = blocked_cross_correlation_test %#ok<STOUT>
2 clc;
3 initTestSuite;
2 localFunctionHandles = cellfun(@str2func,...
3 which('-subfun', mfilename('fullpath')), 'UniformOutput', false);
4 test_suite = buildFunctionHandleTestSuite(localFunctionHandles);
4 5
5 6 function shared = setup function shared = setup
6 7 shared.sample_no = 1e2; shared.sample_no = 1e2;
 
... ... function blocked_cross_correlation_regular_test(shared)
59 60 % suppress std out from call to blocked_cross_correlation % suppress std out from call to blocked_cross_correlation
60 61
61 62 rel_tol = 1e-13; rel_tol = 1e-13;
62 assertAlmostEqual(xx, flipud(xx), rel_tol);
63 assertAlmostEqual(pp, flipud(pp), rel_tol);
63 assertElementsAlmostEqual(xx, flipud(xx), 'relative', rel_tol);
64 assertElementsAlmostEqual(pp, flipud(pp), 'relative', rel_tol);
64 65
65 66 xx_ = xcorr(shared.x.data, shared.x.data, max_lags); xx_ = xcorr(shared.x.data, shared.x.data, max_lags);
66 67 xp_ = xcorr(shared.x.data, shared.p.data, max_lags); xp_ = xcorr(shared.x.data, shared.p.data, max_lags);
67 assertAlmostEqual(xx, xx_, rel_tol);
68 assertAlmostEqual(xp, xp_, rel_tol);
68 assertElementsAlmostEqual(xx, xx_, 'relative', rel_tol);
69 assertElementsAlmostEqual(xp, xp_, 'relative', rel_tol);
69 70
70 71 function blocked_cross_correlation_methods_test(shared) function blocked_cross_correlation_methods_test(shared)
71 72 max_lags = 2; max_lags = 2;
 
... ... function blocked_cross_correlation_methods_test(shared)
80 81 % suppress std out from call to blocked_cross_correlation % suppress std out from call to blocked_cross_correlation
81 82
82 83 rel_tol = 1e-13; rel_tol = 1e-13;
83 assertAlmostEqual(xx, flipud(xx), rel_tol);
84 assertAlmostEqual(pp, flipud(pp), rel_tol);
84 assertElementsAlmostEqual(xx, flipud(xx), 'relative', rel_tol);
85 assertElementsAlmostEqual(pp, flipud(pp), 'relative', rel_tol);
85 86
86 87 xx_ = xcorr(shared.x.data, shared.x.data, max_lags, scaleopt); xx_ = xcorr(shared.x.data, shared.x.data, max_lags, scaleopt);
87 88 xp_ = xcorr(shared.x.data, shared.p.data, max_lags, scaleopt); xp_ = xcorr(shared.x.data, shared.p.data, max_lags, scaleopt);
88 89
89 assertAlmostEqual(xx, xx_, rel_tol);
90 assertAlmostEqual(xp, xp_, rel_tol);
90 assertElementsAlmostEqual(xx, xx_, 'relative', rel_tol);
91 assertElementsAlmostEqual(xp, xp_, 'relative', rel_tol);
91 92 end end
File data_analysis/unittests/entanglement_evaluation_test.m changed (mode: 100644) (index 96267f5..ff48bdd)
1 1 function test_suite = entanglement_evaluation_test %#ok<STOUT> function test_suite = entanglement_evaluation_test %#ok<STOUT>
2 initTestSuite;
2 localFunctionHandles = cellfun(@str2func,...
3 which('-subfun', mfilename('fullpath')), 'UniformOutput', false);
4 test_suite = buildFunctionHandleTestSuite(localFunctionHandles);
3 5
4 6 function shared = setup function shared = setup
5 7 shared.evaluation_folder = tempname; shared.evaluation_folder = tempname;
 
... ... function modefunctions_test(shared)
153 155 for k=1:ev.pulse_gammas_no for k=1:ev.pulse_gammas_no
154 156 start_mode = (k-1)*ev.mech_frequencies_no + 1; start_mode = (k-1)*ev.mech_frequencies_no + 1;
155 157 stop_mode = k*ev.mech_frequencies_no; stop_mode = k*ev.mech_frequencies_no;
156 assertAlmostEqual(...
158 assertElementsAlmostEqual(...
157 159 on_matrix_entangling(start_mode:stop_mode,start_mode:stop_mode),... on_matrix_entangling(start_mode:stop_mode,start_mode:stop_mode),...
158 eye(ev.mech_frequencies_no), 1e-12)
159 assertAlmostEqual(...
160 eye(ev.mech_frequencies_no), 'absolute', 1e-12)
161 assertElementsAlmostEqual(...
160 162 on_matrix_readout(start_mode:stop_mode,start_mode:stop_mode),... on_matrix_readout(start_mode:stop_mode,start_mode:stop_mode),...
161 eye(ev.mech_frequencies_no), 1e-12)
163 eye(ev.mech_frequencies_no), 'absolute', 1e-12)
162 164 end end
163 165
164 166 % check correct sidebands are addressed % check correct sidebands are addressed
 
... ... function modefunctions_test(shared)
166 168 mean_rotation_freq = @(vector)mean(diff(phase(vector))*shared.samplingrate)/(2*pi); mean_rotation_freq = @(vector)mean(diff(phase(vector))*shared.samplingrate)/(2*pi);
167 169 for f=1:ev.mech_frequencies_no for f=1:ev.mech_frequencies_no
168 170 % entangling_modes should pick out down-scattered light --> should be prop. to exp(+i om t) % entangling_modes should pick out down-scattered light --> should be prop. to exp(+i om t)
169 assertAlmostEqual(...
171 assertElementsAlmostEqual(...
170 172 mean_rotation_freq(ev.entangling_modes(f,:)),... mean_rotation_freq(ev.entangling_modes(f,:)),...
171 -ev.mech_frequencies(f), tol)
173 -ev.mech_frequencies(f), 'absolute', tol)
172 174 % readout modes should pick out up-scattered light --> should be prop. to exp(-i om t) % readout modes should pick out up-scattered light --> should be prop. to exp(-i om t)
173 assertAlmostEqual(...
175 assertElementsAlmostEqual(...
174 176 mean_rotation_freq(ev.readout_modes(f,:)),... mean_rotation_freq(ev.readout_modes(f,:)),...
175 +ev.mech_frequencies(f), tol)
177 +ev.mech_frequencies(f), 'absolute', tol)
176 178 % for some reasons it's exactly the other way round... % for some reasons it's exactly the other way round...
177 179 end end
178 180 %figure; plot(phase(ev.readout_modes(1,1:100))) %figure; plot(phase(ev.readout_modes(1,1:100)))
 
... ... function corrfct_test(shared)
530 532 pp = ev.correlation_functions{1}{2,2}; pp = ev.correlation_functions{1}{2,2};
531 533 xp = ev.correlation_functions{1}{1,2}; xp = ev.correlation_functions{1}{1,2};
532 534 px = ev.correlation_functions{1}{2,1}; px = ev.correlation_functions{1}{2,1};
533 assertAlmostEqual(xx, flipud(xx));
534 assertAlmostEqual(pp, flipud(pp));
535 assertAlmostEqual(xp, flipud(px));
535 assertElementsAlmostEqual(xx, flipud(xx));
536 assertElementsAlmostEqual(pp, flipud(pp));
537 assertElementsAlmostEqual(xp, flipud(px));
536 538
537 539 xx_ = xcorr(shared.x.data, shared.x.data, max_lags); xx_ = xcorr(shared.x.data, shared.x.data, max_lags);
538 540 xp_ = xcorr(shared.x.data, shared.p.data, max_lags); xp_ = xcorr(shared.x.data, shared.p.data, max_lags);
539 assertAlmostEqual(xx, xx_);
541 assertElementsAlmostEqual(xx, xx_);
540 542
541 543 rel_tol = 1e-12; rel_tol = 1e-12;
542 assertAlmostEqual(xp, xp_, rel_tol);
544 assertElementsAlmostEqual(xp, xp_, 'relative', rel_tol);
543 545
544 546 % test export and import % test export and import
545 547 corrfct_old = ev.correlation_functions; corrfct_old = ev.correlation_functions;
File data_analysis/unittests/homo_measurement_test.m changed (mode: 100644) (index 8083211..7d788da)
1 1 function test_suite = homo_measurement_test %#ok<STOUT> function test_suite = homo_measurement_test %#ok<STOUT>
2 initTestSuite;
2 localFunctionHandles = cellfun(@str2func,...
3 which('-subfun', mfilename('fullpath')), 'UniformOutput', false);
4 test_suite = buildFunctionHandleTestSuite(localFunctionHandles);
3 5
4 6 function shared = setup function shared = setup
5 7 shared.evaluation_folder = tempname; shared.evaluation_folder = tempname;
File data_analysis/unittests/homotrace_test.m changed (mode: 100644) (index b62d44b..2c294e2)
1 1 function test_suite = homotrace_test %#ok<STOUT> function test_suite = homotrace_test %#ok<STOUT>
2 initTestSuite;
2 localFunctionHandles = cellfun(@str2func,...
3 which('-subfun', mfilename('fullpath')), 'UniformOutput', false);
4 test_suite = buildFunctionHandleTestSuite(localFunctionHandles);
3 5
4 6 function shared = setup function shared = setup
5 7 shared.samplingrate = 100; shared.samplingrate = 100;
File data_analysis/unittests/matlab_xunit added (mode: 160000) (index 0000000..f88af39)
1 Subproject commit f88af39fb1ad9b218608951e95b6b74955d98d3f
File data_analysis/unittests/matlab_xunit_3_1_1/Readme.html deleted (index 314cbbd..0000000)
1 <html>
2 <!--
3 Copyright 2013 The MathWorks, Inc.
4 -->
5 <head>
6 <meta http-equiv="REFRESH" content="0;url=doc/xunit_product_page.html">
7 </head>
8 <body>
9 </body>
10 </html>
File data_analysis/unittests/matlab_xunit_3_1_1/architecture/class_diagram_a.vsd deleted (index d4eb32b..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/architecture/class_diagram_b.vsd deleted (index 6ebf41d..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/architecture/class_diagram_c.vsd deleted (index d95d8dc..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/architecture/html/class_diagram_a.gif deleted (index 28f602e..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/architecture/html/class_diagram_b.gif deleted (index 8a67019..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/architecture/html/class_diagram_c.gif deleted (index 100b0e0..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/architecture/html/matlab_xunit_architecture.html deleted (index 074955f..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html>
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
8 <!--
9 This HTML is auto-generated from an M-file.
10 To make changes, update the M-file and republish this document.
11 -->
12 <title>MATLAB xUnit Test Framework: Architectural Notes</title>
13 <meta name="generator" content="MATLAB 7.8">
14 <meta name="date" content="2009-06-05">
15 <meta name="m-file" content="mtest_architecture"><style type="text/css">
16
17 body {
18 background-color: white;
19 margin:10px;
20 }
21
22 h1 {
23 color: #990000;
24 font-size: x-large;
25 }
26
27 h2 {
28 color: #990000;
29 font-size: medium;
30 }
31
32 /* Make the text shrink to fit narrow windows, but not stretch too far in
33 wide windows. */
34 p,h1,h2,div.content div {
35 max-width: 600px;
36 /* Hack for IE6 */
37 width: auto !important; width: 600px;
38 }
39
40 pre.codeinput {
41 background: #EEEEEE;
42 padding: 10px;
43 }
44 @media print {
45 pre.codeinput {word-wrap:break-word; width:100%;}
46 }
47
48 span.keyword {color: #0000FF}
49 span.comment {color: #228B22}
50 span.string {color: #A020F0}
51 span.untermstring {color: #B20000}
52 span.syscmd {color: #B28C00}
53
54 pre.codeoutput {
55 color: #666666;
56 padding: 10px;
57 }
58
59 pre.error {
60 color: red;
61 }
62
63 p.footer {
64 text-align: right;
65 font-size: xx-small;
66 font-weight: lighter;
67 font-style: italic;
68 color: gray;
69 }
70
71 </style></head>
72 <body>
73 <div class="content">
74 <h1>MATLAB xUnit Test Framework: Architectural Notes</h1>
75 <!--introduction-->
76 <p>This document summarizes the key classes and design choices for MATLAB xUnit, a MATLAB unit testing framework based on xUnit
77 patterns.
78 </p>
79 <p>Note: Testing pattern and smell terminology in this document is drawn from <i>xUnit Test Patterns: Refactoring Test Code</i>, by Gerard Meszaros, Addison-Wesley, 2007.
80 </p>
81 <!--/introduction-->
82 <h2>Contents</h2>
83 <div>
84 <ul>
85 <li><a href="#1">TestComponent, TestCase, and TestSuite</a></li>
86 <li><a href="#2">TestCase: The Four-Phase Test</a></li>
87 <li><a href="#3">Test Case Discovery</a></li>
88 <li><a href="#4">FunctionHandleTestCase: For the Procedural World</a></li>
89 <li><a href="#5">Writing Procedural Test Cases</a></li>
90 <li><a href="#6">TestRunMonitor</a></li>
91 <li><a href="#7">File System Test Runner</a></li>
92 <li><a href="#8">Test Selection</a></li>
93 <li><a href="#9">Assertion Methods</a></li>
94 <li><a href="#10">Stack Traces and "Assertion Roulette"</a></li>
95 <li><a href="#11">Extending the Framework</a></li>
96 </ul>
97 </div>
98 <h2>TestComponent, TestCase, and TestSuite<a name="1"></a></h2>
99 <p><img vspace="5" hspace="5" src="class_diagram_a.gif" alt=""> </p>
100 <p>The abstract <tt>TestComponent</tt> class defines an object that has a description (a name and a location) and that can be run.
101 </p>
102 <p>A <tt>TestCase</tt> object is a test component that defines an individual test case that can be run with a pass or fail result.
103 </p>
104 <p>A <tt>TestSuite</tt> object is a test component that contains a collection of other test components. Note the hierarchical nature of test suites;
105 they can contain both individual test case objects as well as other test suites. Running a test suite means invoking the <tt>run</tt> method on each test component in its collection.
106 </p>
107 <h2>TestCase: The Four-Phase Test<a name="2"></a></h2>
108 <p>The TestCase class provides the standard xUnit <i>Four-Phase Test</i>, using a <i>Fresh Fixture</i>, <i>Implicit Setup</i>, and <i>Implicit Teardown</i>. These all elements can all be seen in the <tt>run</tt> method of TestCase:
109 </p><pre> function did_pass = run(self, monitor)
110 %run Execute the test case
111 % test_case.run(monitor) calls the TestCase object's setUp()
112 % method, then the test method, then the tearDown() method.
113 % observer is a TestRunObserver object. The testStarted(),
114 % testFailure(), testError(), and testFinished() methods of
115 % observer are called at the appropriate times. monitor is a
116 % TestRunMonitor object. Typically it is either a TestRunLogger
117 % subclass or a CommandWindowTestRunDisplay subclass.
118 %
119 % test_case.run() automatically uses a
120 % CommandWindowTestRunDisplay object in order to print test
121 % suite execution information to the Command Window.</pre><pre> if nargin &lt; 2
122 monitor = CommandWindowTestRunDisplay();
123 end</pre><pre> did_pass = true;
124 monitor.testComponentStarted(self);</pre><pre> try
125 self.setUp();
126 f = str2func(self.MethodName);</pre><pre> try
127 % Call the test method.
128 f(self);
129 catch failureException
130 monitor.testCaseFailure(self, failureException);
131 did_pass = false;
132 end</pre><pre> self.tearDown();</pre><pre> catch errorException
133 monitor.testCaseError(self, errorException);
134 did_pass = false;
135 end</pre><pre> monitor.testComponentFinished(self, did_pass);
136 end</pre><p>Phase 1 sets up the test fixture via the <i>Implicit Setup</i> call, <tt>self.setUp()</tt>. The base class <tt>setUp()</tt> method does nothing.
137 </p>
138 <p>Phases 2 and 3 (exercising the system under test and verifying the expected outcome) are handled by the test method, which
139 is invoked by <tt>f(self)</tt>.
140 </p>
141 <p>Phase 4 tears down the test fixture via the <i>Implicit Teardown</i> call, <tt>self.tearDown()</tt>. The base class <tt>tearDown()</tt> method does nothing.
142 </p>
143 <p>Test failure and test error exceptions are caught and handled by the <tt>run()</tt> method, so test methods do not need to use try-catch. This facilitates simple, straight-line test-method code.
144 </p>
145 <p><i>Note: The <tt>monitor</tt> object will be discussed later.</i></p>
146 <h2>Test Case Discovery<a name="3"></a></h2>
147 <p>The static method <tt>TestSuite.fromName</tt> constructs a test suite based on the name of an M-file. If the M-file defines a <tt>TestCase</tt> subclass, then <tt>fromName</tt> inspects the methods of the class and constructs a <tt>TestCase</tt> object for each method whose name begins with "[tT]est". If the M-file does not define a <tt>TestCase</tt> subclass, then <tt>fromName</tt> attempts to construct either a simple procedural test case or a set of subfunction-based test cases. (See the next section).
148 </p>
149 <p>The static method <tt>TestSuite.fromPwd</tt> constructs a test suite by discovering all the test cases in the present working directory. It discovers all <tt>TestCase</tt> subclasses in the directory. In addition, it constructs test suites from all the procedural M-files in the directory beginning
150 with "[tT]est".
151 </p>
152 <p>The <i>File System Test Runner</i>, <tt>runtests</tt>, provides convenient syntaxes for performing test case discovery automatically.
153 </p>
154 <h2>FunctionHandleTestCase: For the Procedural World<a name="4"></a></h2>
155 <p>Most MATLAB users are much more comfortable with procedural programming. An important design goal for MATLAB xUnit is to
156 make it as easy as possible for MATLAB users with little object-oriented programming experience to create and run their own
157 tests. The FunctionHandleTestCase supplies the plumbing necessary to support procedural test functions:
158 </p>
159 <p><img vspace="5" hspace="5" src="class_diagram_b.gif" alt=""> </p>
160 <p>Private properties <tt>SetupFcn</tt>, <tt>TestFcn</tt>, and <tt>TeardownFcn</tt> are procedural <i>function handles</i> (similar to function pointers or function references in other languages).
161 </p>
162 <p><tt>runTestCase()</tt> is the test method used for constructing a TestCase object.
163 </p>
164 <p>Managing test fixtures requires special consideration, because procedural function handles don't have access to object instance
165 data in order to access a test fixture.
166 </p>
167 <p>The overridden <tt>setUp()</tt> method looks at the number of outputs of the function handle <tt>SetupFcn</tt>. If it has an output argument, then the argument is saved in the private <tt>TestData</tt> property, and <tt>TestData</tt> is then passed to both <tt>TestFcn</tt> and <tt>TeardownFcn</tt> for their use.
168 </p>
169 <h2>Writing Procedural Test Cases<a name="5"></a></h2>
170 <p>Procedural test cases can be written in two ways:</p>
171 <div>
172 <ul>
173 <li>A simple M-file function that is treated as a single test case</li>
174 <li>An M-file containing multiple subfunctions that are each treated as a test case.</li>
175 </ul>
176 </div>
177 <p>In either case, the test case is considered to pass if it executes without error.</p>
178 <p>Writing one test case per file is not ideal; it would lead to either zillions of tiny little test files, or long test methods
179 exhibiting various bad test smells (<i>Multiple Test Conditions</i>, <i>Flexible Test</i>, <i>Conditional Test Logic</i>, <i>Eager Test</i>, <i>Obscure Test</i>, etc.) So we need a way to write multiple test cases in a single procedural M-file. The natural MATLAB way would be to
180 use subfunctions.
181 </p>
182 <p>However, subfunction-based test cases require special consideration. Consider the following M-file structure:</p><pre> === File A.m ===
183 function A
184 ...</pre><pre> function B
185 ...</pre><pre> function C
186 ...</pre><pre> function D
187 ...</pre><p>The first function in the file, <tt>A</tt>, has the same name as the file. When other code outside this function calls <tt>A</tt>, it is this first function that gets called. Functions <tt>B</tt>, <tt>C</tt>, and <tt>D</tt> are called <i>subfunctions</i>. Normally, these subfunctions are only visible to and can only be called by <tt>A</tt>. The only way that code elsewhere might be able to call <tt>B</tt>, <tt>C</tt>, or <tt>D</tt> is if function <tt>A</tt> forms handles to them and passes those handles out of its scope. Normally this would be done by returning the function handles
188 as output arguments.
189 </p>
190 <p>Note that no code executing outside the scope of a function in A.m can form function handles to <tt>B</tt>, <tt>C</tt>, or <tt>D</tt>, or can even determine that these functions exist.
191 </p>
192 <p>This obviously poses a problem for test discovery!</p>
193 <p>The MATLAB xUnit solution is to establish the following convention for subfunction-based tests. The first function in a test
194 M-file containing subfunction tests has to begin with these lines:
195 </p><pre> === File A.m ===
196 function test_suite = A
197 initTestSuite;
198 ...</pre><p><tt>initTestSuite</tt> is a <i>script</i> that runs in the scope of the function <tt>A</tt>. <tt>initTestSuite</tt> determines which subfunctions are test functions, as well as setup or teardown functions. It forms handles to these functions
199 and constructs a set of FunctionHandleTestCase objects, which function <tt>A</tt> returns as the output argument <tt>test_suite</tt>.
200 </p>
201 <h2>TestRunMonitor<a name="6"></a></h2>
202 <p>The abstract <tt>TestRunMonitor</tt> class defines the interface for an object that "observe" the in-progress execution of a test suite. MATLAB xUnit provides
203 two subclasses of <tt>TestRunMonitor</tt>:
204 </p>
205 <div>
206 <ul>
207 <li><tt>TestRunLogger</tt> silently logs test suite events and captures the details of any test failures or test errors.
208 </li>
209 <li><tt>CommandWindowTestRunDisplay</tt> prints the progress of an executing test suite to the Command Window.
210 </li>
211 </ul>
212 </div>
213 <p><img vspace="5" hspace="5" src="class_diagram_c.gif" alt=""> </p>
214 <p>A TestRunMonitor is passed to the <tt>run()</tt> method of a TestComponent object. The <tt>run()</tt> method calls the appropriate notification methods of the monitor.
215 </p>
216 <p>Here is the output when using the CommandWindowTestRunDisplay object on the MATLAB xUnit's own test suite:</p><pre> runtests
217 Starting test run with 92 test cases.
218 ....................
219 ....................
220 ....................
221 ....................
222 ............
223 PASSED in 7.040 seconds.</pre><h2>File System Test Runner<a name="7"></a></h2>
224 <p>MATLAB xUnit provides a command-line <i>File System Test Runner</i> called <tt>runtests</tt>. When called with no input arguments, <tt>runtests</tt> gathers all the test cases from the current directory and runs them, summarizing the results to the Command Window. <tt>runtests</tt> can also take a string argument specifying which test file, and optionally which specific test case, to run.
225 </p>
226 <h2>Test Selection<a name="8"></a></h2>
227 <p>Test selection is supported in <tt>runtests</tt> by passing in a string of the form:
228 </p><pre> 'Location:Name'</pre><p>or just:</p><pre> 'Location'</pre><p>Both of these forms are handled by <tt>runtests</tt> and by <tt>TestSuite.fromName</tt>.
229 </p>
230 <p>'Location' is the name of the M-file containing test cases. 'Name' is the name of a specific test case. Normally, the name
231 of the test case is the name of the corresponding TestCase method. For FunctionHandleTestCase objects, though, 'Name' is
232 the subfunction name.
233 </p>
234 <h2>Assertion Methods<a name="9"></a></h2>
235 <p>MATLAB xUnit provides the following assertion methods:</p>
236 <div>
237 <ul>
238 <li><i>Stated Outcome Assertion</i> (<tt>assertTrue</tt>, <tt>assertFalse</tt>)
239 </li>
240 <li><i>Equality Assertion</i> (<tt>assertEqual</tt>)
241 </li>
242 <li><i>Fuzzy Equality Assertion</i> (<tt>assertElementsAlmostEqual</tt>, <tt>assertVectorsAlmostEqual</tt>)
243 </li>
244 <li><i>Expected Exception Assertion</i> (<tt>assertExceptionRaised</tt>)
245 </li>
246 </ul>
247 </div>
248 <p>Assertion functions are provided via globally accessible names (e.g., <tt>assertEqual</tt>). The assertion functions could be moved to the <tt>xunit</tt> package, but MATLAB users are not accustomed yet to packages and package name-scoping syntax.
249 </p>
250 <p>'message' is the last input to the assertion functions and is optional. (See below for discussion of <i>Assertion Roulette</i>.)
251 </p>
252 <p>The <i>Expected Exception Assertion</i>, <tt>assertExceptionRaised</tt> is used by forming an anonymous function handle from an expression that is expected to error, and then passing that function
253 handle to <tt>assertExceptionRaised</tt> along with the expected exception identifier. For example:
254 </p><pre> f = @() sin(1,2,3);
255 assertExceptionRaised(f, 'MATLAB:maxrhs')</pre><p>By using this mechanism, test writers can verify exceptions without using try-catch logic in their test code.</p>
256 <h2>Stack Traces and "Assertion Roulette"<a name="10"></a></h2>
257 <p><i>xUnit Test Patterns</i> explains the smell <i>Assertion Roulette</i> this way: "It is hard to tell which of several assertions within the same test method caused a test failure.
258 </p>
259 <p>MATLAB xUnit mitigates against <i>Assertion Roulette</i> by capturing the entire stack trace, including line numbers, for every test failure and test error. (The MATLAB MException
260 object, which you obtain via the <tt>catch</tt> clause, contains the stack trace.) The stack trace is displayed to the Command Window, with clickable links that load the
261 corresponding M-file into editor at the appropriate line number.
262 </p>
263 <p>Stack traces can be pretty long, though. Also, test framework plumbing tends to occupy the trace in between the assertion
264 and the user's test code, thus making the trace hard to interpret for less-experienced users. MATLAB xUnit, therefore, uses
265 a stack filtering heuristic for displaying test fault traces: Starting at the deepest call level, once the trace leaves MATLAB
266 xUnit framework functions, all further framework functions are filtered out of the stack trace.
267 </p>
268 <p>Here's an example of stack trace display in the output of <tt>runtests</tt>:
269 </p>
270 <p><html> <tt> >> runtests testSample<br /> Starting test run with 1 test case.<br /> F<br /> FAILED in 0.081 seconds.<br />
271 <br /> ===== Test Case Failure =====<br /> Location: c:\work\matlab_xunit\architecture\testSample.m<br /> Name: testMyCode<br
272 /> <br /> c:\work\matlab_xunit\architecture\testSample.m at <span style="color:blue; text-decoration:underline">line 6</span><br
273 /> <br /> Input elements are not all equal within relative tolerance: 1.49012e-008<br /> <br /> First input:<br /> 1<br
274 /> <br /> Second input:<br /> 1.1000<br /> </tt> </html>
275 </p>
276 <p>Clicking on the blue, underlined link above loads the corresponding file into the editor, positioned at the appropriate line.</p>
277 <h2>Extending the Framework<a name="11"></a></h2>
278 <p>The MATLAB xUnit framework can be extended primarily by subclassing <tt>TestCase</tt>, <tt>TestSuite</tt>, and <tt>TestMonitor</tt>.
279 </p>
280 <p><tt>TestCase</tt> can be subclassed to enable a new set of test cases that all share some particular behavior. The MATLAB xUnit Test Framework
281 contains three examples of extending <tt>TestCase</tt> behavior in this way:
282 </p>
283 <div>
284 <ul>
285 <li><tt>FunctionHandleTestCase</tt> provides the ability to define test cases based on procedural function handles.
286 </li>
287 <li><tt>TestCaseInDir</tt> defines a test case that must be run inside a particular directory. The <tt>setUp</tt> and <tt>tearDown</tt> functions are overridden to change the MATLAB working directory before running the test case, and then to restore the original
288 working directory when the test case finished. The class is used by the framework's own test suite.
289 </li>
290 <li><tt>TestCaseInPath</tt> defines a test case that must be run with a particular directory temporarily added to the MATLAB path. Its implementation
291 is similar to <tt>TestCaseInDir</tt>, and it is also used by the framework's own test suite.
292 </li>
293 </ul>
294 </div>
295 <p><tt>TestSuite</tt> could be similarly extended by subclassing. This might a provide a way in the future to define a test suite containing collections
296 of test components in separate directories, which is not currently supported.
297 </p>
298 <p>Finally <tt>TestRunMonitor</tt> could be subclassed to support a variety of test monitoring mechanisms, such as what might be required by a <i>Graphical Test Runner</i>.
299 </p>
300 <p class="footer"><br>
301 Published with MATLAB&reg; 7.8<br></p>
302 </div>
303 <!--
304 ##### SOURCE BEGIN #####
305 %% MATLAB xUnit Test Framework: Architectural Notes
306 % This document summarizes the key classes and design choices for MATLAB xUnit,
307 % a MATLAB unit testing framework based on xUnit patterns.
308 %
309 % Note: Testing pattern and smell terminology in this document is drawn from
310 % _xUnit Test Patterns: Refactoring Test Code_, by Gerard Meszaros,
311 % Addison-Wesley, 2007.
312
313 %% TestComponent, TestCase, and TestSuite
314 %
315 % <<class_diagram_a.gif>>
316 %
317 % The abstract |TestComponent| class defines an object that has a description (a
318 % name and a location) and that can be run.
319 %
320 % A |TestCase| object is a test component that defines an individual test case
321 % that can be run with a pass or fail result.
322 %
323 % A |TestSuite| object is a test component that contains a collection of other
324 % test components. Note the hierarchical nature of test suites; they can
325 % contain both individual test case objects as well as other test suites.
326 % Running a test suite means invoking the |run| method on each test component in
327 % its collection.
328
329 %% TestCase: The Four-Phase Test
330 %
331 % The TestCase class provides the standard xUnit _Four-Phase Test_, using
332 % a _Fresh Fixture_, _Implicit Setup_, and _Implicit Teardown_. These all
333 % elements can all be seen in the |run| method of TestCase:
334 %
335 % function did_pass = run(self, monitor)
336 % %run Execute the test case
337 % % test_case.run(monitor) calls the TestCase object's setUp()
338 % % method, then the test method, then the tearDown() method.
339 % % observer is a TestRunObserver object. The testStarted(),
340 % % testFailure(), testError(), and testFinished() methods of
341 % % observer are called at the appropriate times. monitor is a
342 % % TestRunMonitor object. Typically it is either a TestRunLogger
343 % % subclass or a CommandWindowTestRunDisplay subclass.
344 % %
345 % % test_case.run() automatically uses a
346 % % CommandWindowTestRunDisplay object in order to print test
347 % % suite execution information to the Command Window.
348 %
349 % if nargin < 2
350 % monitor = CommandWindowTestRunDisplay();
351 % end
352 %
353 % did_pass = true;
354 % monitor.testComponentStarted(self);
355 %
356 % try
357 % self.setUp();
358 % f = str2func(self.MethodName);
359 %
360 % try
361 % % Call the test method.
362 % f(self);
363 % catch failureException
364 % monitor.testCaseFailure(self, failureException);
365 % did_pass = false;
366 % end
367 %
368 % self.tearDown();
369 %
370 % catch errorException
371 % monitor.testCaseError(self, errorException);
372 % did_pass = false;
373 % end
374 %
375 % monitor.testComponentFinished(self, did_pass);
376 % end
377 %
378 % Phase 1 sets up the test fixture via the _Implicit Setup_ call, |self.setUp()|.
379 % The base class |setUp()| method does nothing.
380 %
381 % Phases 2 and 3 (exercising the system under test and verifying the expected
382 % outcome) are handled by the test method, which is invoked by |f(self)|.
383 %
384 % Phase 4 tears down the test fixture via the _Implicit Teardown_ call,
385 % |self.tearDown()|. The base class |tearDown()| method does nothing.
386 %
387 % Test failure and test error exceptions are caught and handled by the |run()|
388 % method, so test methods do not need to use try-catch. This facilitates
389 % simple, straight-line test-method code.
390 %
391 % _Note: The |monitor| object will be discussed later._
392
393 %% Test Case Discovery
394 % The static method |TestSuite.fromName| constructs a test suite based on the
395 % name of an M-file. If the M-file defines a |TestCase| subclass, then |fromName|
396 % inspects the methods of the class and constructs a |TestCase| object for each
397 % method whose name begins with "[tT]est". If the M-file does not define a
398 % |TestCase| subclass, then |fromName| attempts to construct either a simple
399 % procedural test case or a set of subfunction-based test cases. (See the next
400 % section).
401 %
402 % The static method |TestSuite.fromPwd| constructs a test suite by discovering
403 % all the test cases in the present working directory. It discovers all
404 % |TestCase| subclasses in the directory. In addition, it constructs test suites
405 % from all the procedural M-files in the directory beginning with "[tT]est".
406 %
407 % The _File System Test Runner_, |runtests|, provides convenient syntaxes for
408 % performing test case discovery automatically.
409
410 %% FunctionHandleTestCase: For the Procedural World
411 % Most MATLAB users are much more comfortable with procedural programming. An
412 % important design goal for MATLAB xUnit is to make it as easy as possible for MATLAB
413 % users with little object-oriented programming experience to create and run
414 % their own tests. The FunctionHandleTestCase supplies the plumbing necessary
415 % to support procedural test functions:
416 %
417 % <<class_diagram_b.gif>>
418 %
419 % Private properties |SetupFcn|, |TestFcn|, and |TeardownFcn| are procedural
420 % _function handles_ (similar to function pointers or function references in
421 % other languages).
422 %
423 % |runTestCase()| is the test method used for constructing a TestCase object.
424 %
425 % Managing test fixtures requires special consideration, because procedural
426 % function handles don't have access to object instance data in order to access
427 % a test fixture.
428 %
429 % The overridden |setUp()| method looks at the number of outputs of the function
430 % handle |SetupFcn|. If it has an output argument, then the argument is saved
431 % in the private |TestData| property, and |TestData| is then passed to both
432 % |TestFcn| and |TeardownFcn| for their use.
433
434 %% Writing Procedural Test Cases
435 % Procedural test cases can be written in two ways:
436 %
437 % * A simple M-file function that is treated as a single test case
438 % * An M-file containing multiple subfunctions that are each treated as a test case.
439 %
440 % In either case, the test
441 % case is considered to pass if it executes without error.
442 %
443 % Writing one test case per file is not ideal; it would lead to either zillions
444 % of tiny little test files, or long test methods exhibiting various bad test
445 % smells (_Multiple Test Conditions_, _Flexible Test_, _Conditional Test Logic_,
446 % _Eager Test_, _Obscure Test_, etc.) So we need a way to write multiple test
447 % cases in a single procedural M-file. The natural MATLAB way would be to use
448 % subfunctions.
449 %
450 % However, subfunction-based test cases require special consideration. Consider
451 % the following M-file structure:
452 %
453 % === File A.m ===
454 % function A
455 % ...
456 %
457 % function B
458 % ...
459 %
460 % function C
461 % ...
462 %
463 % function D
464 % ...
465 %
466 % The first function in the file, |A|, has the same name as the file. When
467 % other code outside this function calls |A|, it is this first function that
468 % gets called. Functions |B|, |C|, and |D| are called _subfunctions_.
469 % Normally, these subfunctions are only visible to and can only be called by
470 % |A|. The only way that code elsewhere might be able to call |B|, |C|, or |D|
471 % is if function |A| forms handles to them and passes those handles out of its
472 % scope. Normally this would be done by returning the function handles as
473 % output arguments.
474 %
475 % Note that no code executing outside the scope of a function in A.m can form
476 % function handles to |B|, |C|, or |D|, or can even determine that these
477 % functions exist.
478 %
479 % This obviously poses a problem for test discovery!
480 %
481 % The MATLAB xUnit solution is to establish the following convention for
482 % subfunction-based tests. The first function in a test M-file containing
483 % subfunction tests has to begin with these lines:
484 %
485 % === File A.m ===
486 % function test_suite = A
487 % initTestSuite;
488 % ...
489 %
490 % |initTestSuite| is a _script_ that runs in the scope of the function |A|.
491 % |initTestSuite| determines which subfunctions are test functions, as well as setup
492 % or teardown functions. It forms handles to these functions and constructs a
493 % set of FunctionHandleTestCase objects, which function |A| returns as the
494 % output argument |test_suite|.
495
496 %% TestRunMonitor
497 % The abstract |TestRunMonitor| class defines the interface for an object that
498 % "observe" the in-progress execution of a test suite. MATLAB xUnit provides two
499 % subclasses of |TestRunMonitor|:
500 %
501 % * |TestRunLogger| silently logs test suite events and captures the details of
502 % any test failures or test errors.
503 % * |CommandWindowTestRunDisplay| prints the progress of an executing test suite
504 % to the Command Window.
505 %
506 % <<class_diagram_c.gif>>
507 %
508 % A TestRunMonitor is passed to the |run()| method of a TestComponent object.
509 % The |run()| method calls the appropriate notification methods of the
510 % monitor.
511 %
512 % Here is the output when using the CommandWindowTestRunDisplay object on the
513 % MATLAB xUnit's own test suite:
514 %
515 % runtests
516 % Starting test run with 92 test cases.
517 % ....................
518 % ....................
519 % ....................
520 % ....................
521 % ............
522 % PASSED in 7.040 seconds.
523
524 %% File System Test Runner
525 % MATLAB xUnit provides a command-line _File System Test Runner_ called
526 % |runtests|. When called with no input arguments, |runtests| gathers all the
527 % test cases from the current directory and runs them, summarizing the results
528 % to the Command Window. |runtests| can also take a string argument specifying
529 % which test file, and optionally which specific test case, to run.
530
531 %% Test Selection
532 % Test selection is supported in |runtests| by passing in a string of the form:
533 %
534 % 'Location:Name'
535 %
536 % or just:
537 %
538 % 'Location'
539 %
540 % Both of these forms are handled by |runtests| and by |TestSuite.fromName|.
541 %
542 % 'Location' is the name of the M-file containing test cases. 'Name' is the
543 % name of a specific test case. Normally, the name of the test case is the name
544 % of the corresponding TestCase method. For FunctionHandleTestCase objects,
545 % though, 'Name' is the subfunction name.
546
547 %% Assertion Methods
548 % MATLAB xUnit provides the following assertion methods:
549 %
550 % * _Stated Outcome Assertion_ (|assertTrue|, |assertFalse|)
551 % * _Equality Assertion_ (|assertEqual|)
552 % * _Fuzzy Equality Assertion_ (|assertElementsAlmostEqual|, |assertVectorsAlmostEqual|)
553 % * _Expected Exception Assertion_ (|assertExceptionRaised|)
554 %
555 % Assertion functions are provided via globally accessible names (e.g.,
556 % |assertEqual|). The assertion functions could be moved to the |xunit|
557 % package, but MATLAB users are not accustomed yet to packages and package
558 % name-scoping syntax.
559 %
560 % 'message' is the last input to the assertion functions and is optional. (See
561 % below for discussion of _Assertion Roulette_.)
562 %
563 % The _Expected Exception Assertion_, |assertExceptionRaised| is used by forming
564 % an anonymous function handle from an expression that is expected to error, and
565 % then passing that function handle to |assertExceptionRaised| along with the
566 % expected exception identifier. For example:
567 %
568 % f = @() sin(1,2,3);
569 % assertExceptionRaised(f, 'MATLAB:maxrhs')
570 %
571 % By using this mechanism, test writers can verify exceptions without using
572 % try-catch logic in their test code.
573
574 %% Stack Traces and "Assertion Roulette"
575 % _xUnit Test Patterns_ explains the smell _Assertion Roulette_ this way: "It is
576 % hard to tell which of several assertions within the same test method caused a
577 % test failure.
578 %
579 % MATLAB xUnit mitigates against _Assertion Roulette_ by capturing the entire stack
580 % trace, including line numbers, for every test failure and test error. (The
581 % MATLAB MException object, which you obtain via the |catch| clause, contains
582 % the stack trace.) The stack trace is displayed to the Command Window, with
583 % clickable links that load the corresponding M-file into editor at the
584 % appropriate line number.
585 %
586 % Stack traces can be pretty long, though. Also, test framework plumbing tends
587 % to occupy the trace in between the assertion and the user's test code, thus
588 % making the trace hard to interpret for less-experienced users. MATLAB xUnit,
589 % therefore, uses a stack filtering heuristic for displaying test fault traces:
590 % Starting at the deepest call level, once the trace leaves MATLAB xUnit framework
591 % functions, all further framework functions are filtered out of the stack
592 % trace.
593 %
594 % Here's an example of stack trace display in the output of |runtests|:
595 %
596 % <html>
597 % <tt>
598 % >> runtests testSample<br />
599 % Starting test run with 1 test case.<br />
600 % F<br />
601 % FAILED in 0.081 seconds.<br />
602 % <br />
603 % ===== Test Case Failure =====<br />
604 % Location: c:\work\matlab_xunit\architecture\testSample.m<br />
605 % Name: testMyCode<br />
606 % <br />
607 % c:\work\matlab_xunit\architecture\testSample.m at <span style="color:blue;
608 % text-decoration:underline">line 6</span><br />
609 % <br />
610 % Input elements are not all equal within relative tolerance: 1.49012e-008<br />
611 % <br />
612 % First input:<br />
613 % 1<br />
614 % <br />
615 % Second input:<br />
616 % 1.1000<br />
617 % </tt>
618 % </html>
619 %
620 % Clicking on the blue, underlined link above loads the corresponding file into
621 % the editor, positioned at the appropriate line.
622
623 %% Extending the Framework
624 % The MATLAB xUnit framework can be extended primarily by subclassing |TestCase|,
625 % |TestSuite|, and |TestMonitor|.
626 %
627 % |TestCase| can be subclassed to enable a new set of test cases that all share
628 % some particular behavior. The MATLAB xUnit Test Framework contains three
629 % examples of extending |TestCase| behavior in this way:
630 %
631 % * |FunctionHandleTestCase| provides the ability to define test cases based on
632 % procedural function handles.
633 % * |TestCaseInDir| defines a test case that must be run inside a particular
634 % directory. The |setUp| and |tearDown| functions are overridden to change the
635 % MATLAB working directory before running the test case, and then to restore the
636 % original working directory when the test case finished. The class is used by
637 % the framework's own test suite.
638 % * |TestCaseInPath| defines a test case that must be run with a particular
639 % directory temporarily added to the MATLAB path. Its implementation is similar
640 % to |TestCaseInDir|, and it is also used by the framework's own test suite.
641 %
642 % |TestSuite| could be similarly extended by subclassing. This might a provide a
643 % way in the future to define a test suite containing collections of test
644 % components in separate directories, which is not currently supported.
645 %
646 % Finally |TestRunMonitor| could be subclassed to support a variety of test
647 % monitoring mechanisms, such as what might be required by a _Graphical Test
648 % Runner_.
649 ##### SOURCE END #####
650 -->
651 </body>
652 </html>
File data_analysis/unittests/matlab_xunit_3_1_1/architecture/matlab_xunit_architecture.m deleted (index dd9c6c7..0000000)
1 %% MATLAB xUnit Test Framework: Architectural Notes
2 % This document summarizes the key classes and design choices for MATLAB xUnit,
3 % a MATLAB unit testing framework based on xUnit patterns.
4 %
5 % Note: Testing pattern and smell terminology in this document is drawn from
6 % _xUnit Test Patterns: Refactoring Test Code_, by Gerard Meszaros,
7 % Addison-Wesley, 2007.
8
9 %% TestComponent, TestCase, and TestSuite
10 %
11 % <<class_diagram_a.gif>>
12 %
13 % The abstract |TestComponent| class defines an object that has a description (a
14 % name and a location) and that can be run.
15 %
16 % A |TestCase| object is a test component that defines an individual test case
17 % that can be run with a pass or fail result.
18 %
19 % A |TestSuite| object is a test component that contains a collection of other
20 % test components. Note the hierarchical nature of test suites; they can
21 % contain both individual test case objects as well as other test suites.
22 % Running a test suite means invoking the |run| method on each test component in
23 % its collection.
24
25 %% TestCase: The Four-Phase Test
26 %
27 % The TestCase class provides the standard xUnit _Four-Phase Test_, using
28 % a _Fresh Fixture_, _Implicit Setup_, and _Implicit Teardown_. These all
29 % elements can all be seen in the |run| method of TestCase:
30 %
31 % function did_pass = run(self, monitor)
32 % %run Execute the test case
33 % % test_case.run(monitor) calls the TestCase object's setUp()
34 % % method, then the test method, then the tearDown() method.
35 % % observer is a TestRunObserver object. The testStarted(),
36 % % testFailure(), testError(), and testFinished() methods of
37 % % observer are called at the appropriate times. monitor is a
38 % % TestRunMonitor object. Typically it is either a TestRunLogger
39 % % subclass or a CommandWindowTestRunDisplay subclass.
40 % %
41 % % test_case.run() automatically uses a
42 % % CommandWindowTestRunDisplay object in order to print test
43 % % suite execution information to the Command Window.
44 %
45 % if nargin < 2
46 % monitor = CommandWindowTestRunDisplay();
47 % end
48 %
49 % did_pass = true;
50 % monitor.testComponentStarted(self);
51 %
52 % try
53 % self.setUp();
54 % f = str2func(self.MethodName);
55 %
56 % try
57 % % Call the test method.
58 % f(self);
59 % catch failureException
60 % monitor.testCaseFailure(self, failureException);
61 % did_pass = false;
62 % end
63 %
64 % self.tearDown();
65 %
66 % catch errorException
67 % monitor.testCaseError(self, errorException);
68 % did_pass = false;
69 % end
70 %
71 % monitor.testComponentFinished(self, did_pass);
72 % end
73 %
74 % Phase 1 sets up the test fixture via the _Implicit Setup_ call, |self.setUp()|.
75 % The base class |setUp()| method does nothing.
76 %
77 % Phases 2 and 3 (exercising the system under test and verifying the expected
78 % outcome) are handled by the test method, which is invoked by |f(self)|.
79 %
80 % Phase 4 tears down the test fixture via the _Implicit Teardown_ call,
81 % |self.tearDown()|. The base class |tearDown()| method does nothing.
82 %
83 % Test failure and test error exceptions are caught and handled by the |run()|
84 % method, so test methods do not need to use try-catch. This facilitates
85 % simple, straight-line test-method code.
86 %
87 % _Note: The |monitor| object will be discussed later._
88
89 %% Test Case Discovery
90 % The static method |TestSuite.fromName| constructs a test suite based on the
91 % name of an M-file. If the M-file defines a |TestCase| subclass, then |fromName|
92 % inspects the methods of the class and constructs a |TestCase| object for each
93 % method whose name begins with "[tT]est". If the M-file does not define a
94 % |TestCase| subclass, then |fromName| attempts to construct either a simple
95 % procedural test case or a set of subfunction-based test cases. (See the next
96 % section).
97 %
98 % The static method |TestSuite.fromPwd| constructs a test suite by discovering
99 % all the test cases in the present working directory. It discovers all
100 % |TestCase| subclasses in the directory. In addition, it constructs test suites
101 % from all the procedural M-files in the directory beginning with "[tT]est".
102 %
103 % The _File System Test Runner_, |runtests|, provides convenient syntaxes for
104 % performing test case discovery automatically.
105
106 %% FunctionHandleTestCase: For the Procedural World
107 % Most MATLAB users are much more comfortable with procedural programming. An
108 % important design goal for MATLAB xUnit is to make it as easy as possible for MATLAB
109 % users with little object-oriented programming experience to create and run
110 % their own tests. The FunctionHandleTestCase supplies the plumbing necessary
111 % to support procedural test functions:
112 %
113 % <<class_diagram_b.gif>>
114 %
115 % Private properties |SetupFcn|, |TestFcn|, and |TeardownFcn| are procedural
116 % _function handles_ (similar to function pointers or function references in
117 % other languages).
118 %
119 % |runTestCase()| is the test method used for constructing a TestCase object.
120 %
121 % Managing test fixtures requires special consideration, because procedural
122 % function handles don't have access to object instance data in order to access
123 % a test fixture.
124 %
125 % The overridden |setUp()| method looks at the number of outputs of the function
126 % handle |SetupFcn|. If it has an output argument, then the argument is saved
127 % in the private |TestData| property, and |TestData| is then passed to both
128 % |TestFcn| and |TeardownFcn| for their use.
129
130 %% Writing Procedural Test Cases
131 % Procedural test cases can be written in two ways:
132 %
133 % * A simple M-file function that is treated as a single test case
134 % * An M-file containing multiple subfunctions that are each treated as a test case.
135 %
136 % In either case, the test
137 % case is considered to pass if it executes without error.
138 %
139 % Writing one test case per file is not ideal; it would lead to either zillions
140 % of tiny little test files, or long test methods exhibiting various bad test
141 % smells (_Multiple Test Conditions_, _Flexible Test_, _Conditional Test Logic_,
142 % _Eager Test_, _Obscure Test_, etc.) So we need a way to write multiple test
143 % cases in a single procedural M-file. The natural MATLAB way would be to use
144 % subfunctions.
145 %
146 % However, subfunction-based test cases require special consideration. Consider
147 % the following M-file structure:
148 %
149 % === File A.m ===
150 % function A
151 % ...
152 %
153 % function B
154 % ...
155 %
156 % function C
157 % ...
158 %
159 % function D
160 % ...
161 %
162 % The first function in the file, |A|, has the same name as the file. When
163 % other code outside this function calls |A|, it is this first function that
164 % gets called. Functions |B|, |C|, and |D| are called _subfunctions_.
165 % Normally, these subfunctions are only visible to and can only be called by
166 % |A|. The only way that code elsewhere might be able to call |B|, |C|, or |D|
167 % is if function |A| forms handles to them and passes those handles out of its
168 % scope. Normally this would be done by returning the function handles as
169 % output arguments.
170 %
171 % Note that no code executing outside the scope of a function in A.m can form
172 % function handles to |B|, |C|, or |D|, or can even determine that these
173 % functions exist.
174 %
175 % This obviously poses a problem for test discovery!
176 %
177 % The MATLAB xUnit solution is to establish the following convention for
178 % subfunction-based tests. The first function in a test M-file containing
179 % subfunction tests has to begin with these lines:
180 %
181 % === File A.m ===
182 % function test_suite = A
183 % initTestSuite;
184 % ...
185 %
186 % |initTestSuite| is a _script_ that runs in the scope of the function |A|.
187 % |initTestSuite| determines which subfunctions are test functions, as well as setup
188 % or teardown functions. It forms handles to these functions and constructs a
189 % set of FunctionHandleTestCase objects, which function |A| returns as the
190 % output argument |test_suite|.
191
192 %% TestRunMonitor
193 % The abstract |TestRunMonitor| class defines the interface for an object that
194 % "observe" the in-progress execution of a test suite. MATLAB xUnit provides two
195 % subclasses of |TestRunMonitor|:
196 %
197 % * |TestRunLogger| silently logs test suite events and captures the details of
198 % any test failures or test errors.
199 % * |CommandWindowTestRunDisplay| prints the progress of an executing test suite
200 % to the Command Window.
201 %
202 % <<class_diagram_c.gif>>
203 %
204 % A TestRunMonitor is passed to the |run()| method of a TestComponent object.
205 % The |run()| method calls the appropriate notification methods of the
206 % monitor.
207 %
208 % Here is the output when using the CommandWindowTestRunDisplay object on the
209 % MATLAB xUnit's own test suite:
210 %
211 % runtests
212 % Starting test run with 92 test cases.
213 % ....................
214 % ....................
215 % ....................
216 % ....................
217 % ............
218 % PASSED in 7.040 seconds.
219
220 %% File System Test Runner
221 % MATLAB xUnit provides a command-line _File System Test Runner_ called
222 % |runtests|. When called with no input arguments, |runtests| gathers all the
223 % test cases from the current directory and runs them, summarizing the results
224 % to the Command Window. |runtests| can also take a string argument specifying
225 % which test file, and optionally which specific test case, to run.
226
227 %% Test Selection
228 % Test selection is supported in |runtests| by passing in a string of the form:
229 %
230 % 'Location:Name'
231 %
232 % or just:
233 %
234 % 'Location'
235 %
236 % Both of these forms are handled by |runtests| and by |TestSuite.fromName|.
237 %
238 % 'Location' is the name of the M-file containing test cases. 'Name' is the
239 % name of a specific test case. Normally, the name of the test case is the name
240 % of the corresponding TestCase method. For FunctionHandleTestCase objects,
241 % though, 'Name' is the subfunction name.
242
243 %% Assertion Methods
244 % MATLAB xUnit provides the following assertion methods:
245 %
246 % * _Stated Outcome Assertion_ (|assertTrue|, |assertFalse|)
247 % * _Equality Assertion_ (|assertEqual|)
248 % * _Fuzzy Equality Assertion_ (|assertElementsAlmostEqual|, |assertVectorsAlmostEqual|)
249 % * _Expected Exception Assertion_ (|assertExceptionRaised|)
250 %
251 % Assertion functions are provided via globally accessible names (e.g.,
252 % |assertEqual|). The assertion functions could be moved to the |xunit|
253 % package, but MATLAB users are not accustomed yet to packages and package
254 % name-scoping syntax.
255 %
256 % 'message' is the last input to the assertion functions and is optional. (See
257 % below for discussion of _Assertion Roulette_.)
258 %
259 % The _Expected Exception Assertion_, |assertExceptionRaised| is used by forming
260 % an anonymous function handle from an expression that is expected to error, and
261 % then passing that function handle to |assertExceptionRaised| along with the
262 % expected exception identifier. For example:
263 %
264 % f = @() sin(1,2,3);
265 % assertExceptionRaised(f, 'MATLAB:maxrhs')
266 %
267 % By using this mechanism, test writers can verify exceptions without using
268 % try-catch logic in their test code.
269
270 %% Stack Traces and "Assertion Roulette"
271 % _xUnit Test Patterns_ explains the smell _Assertion Roulette_ this way: "It is
272 % hard to tell which of several assertions within the same test method caused a
273 % test failure.
274 %
275 % MATLAB xUnit mitigates against _Assertion Roulette_ by capturing the entire stack
276 % trace, including line numbers, for every test failure and test error. (The
277 % MATLAB MException object, which you obtain via the |catch| clause, contains
278 % the stack trace.) The stack trace is displayed to the Command Window, with
279 % clickable links that load the corresponding M-file into editor at the
280 % appropriate line number.
281 %
282 % Stack traces can be pretty long, though. Also, test framework plumbing tends
283 % to occupy the trace in between the assertion and the user's test code, thus
284 % making the trace hard to interpret for less-experienced users. MATLAB xUnit,
285 % therefore, uses a stack filtering heuristic for displaying test fault traces:
286 % Starting at the deepest call level, once the trace leaves MATLAB xUnit framework
287 % functions, all further framework functions are filtered out of the stack
288 % trace.
289 %
290 % Here's an example of stack trace display in the output of |runtests|:
291 %
292 % <html>
293 % <tt>
294 % >> runtests testSample<br />
295 % Starting test run with 1 test case.<br />
296 % F<br />
297 % FAILED in 0.081 seconds.<br />
298 % <br />
299 % ===== Test Case Failure =====<br />
300 % Location: c:\work\matlab_xunit\architecture\testSample.m<br />
301 % Name: testMyCode<br />
302 % <br />
303 % c:\work\matlab_xunit\architecture\testSample.m at <span style="color:blue;
304 % text-decoration:underline">line 6</span><br />
305 % <br />
306 % Input elements are not all equal within relative tolerance: 1.49012e-008<br />
307 % <br />
308 % First input:<br />
309 % 1<br />
310 % <br />
311 % Second input:<br />
312 % 1.1000<br />
313 % </tt>
314 % </html>
315 %
316 % Clicking on the blue, underlined link above loads the corresponding file into
317 % the editor, positioned at the appropriate line.
318
319 %% Extending the Framework
320 % The MATLAB xUnit framework can be extended primarily by subclassing |TestCase|,
321 % |TestSuite|, and |TestMonitor|.
322 %
323 % |TestCase| can be subclassed to enable a new set of test cases that all share
324 % some particular behavior. The MATLAB xUnit Test Framework contains three
325 % examples of extending |TestCase| behavior in this way:
326 %
327 % * |FunctionHandleTestCase| provides the ability to define test cases based on
328 % procedural function handles.
329 % * |TestCaseInDir| defines a test case that must be run inside a particular
330 % directory. The |setUp| and |tearDown| functions are overridden to change the
331 % MATLAB working directory before running the test case, and then to restore the
332 % original working directory when the test case finished. The class is used by
333 % the framework's own test suite.
334 % * |TestCaseInPath| defines a test case that must be run with a particular
335 % directory temporarily added to the MATLAB path. Its implementation is similar
336 % to |TestCaseInDir|, and it is also used by the framework's own test suite.
337 %
338 % |TestSuite| could be similarly extended by subclassing. This might a provide a
339 % way in the future to define a test suite containing collections of test
340 % components in separate directories, which is not currently supported.
341 %
342 % Finally |TestRunMonitor| could be subclassed to support a variety of test
343 % monitoring mechanisms, such as what might be required by a _Graphical Test
344 % Runner_.
345 %
346 % Copyright 2013 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/architecture/testSample.m deleted (index 253d097..0000000)
1 function test_suite = testSample
2 % Copyright 2013 The MathWorks, Inc.
3 initTestSuite;
4
5 function testMyCode
6 assertEqual(1, 1);
7 assertElementsAlmostEqual(1, 1.1);
8 assertTrue(10 == 10);
File data_analysis/unittests/matlab_xunit_3_1_1/doc/+abc/+tests/test_that.m deleted (index 9b569db..0000000)
1 % Do-nothing test used in the examples for organizing tests inside packages.
2 %
3 % Steven L. Eddins
4 % Copyright 2010 The MathWorks, Inc.
5
6 function test_that
File data_analysis/unittests/matlab_xunit_3_1_1/doc/+abc/+tests/test_this.m deleted (index d7f0ee1..0000000)
1 % Do-nothing test used in the examples for organizing tests inside packages.
2 %
3 % Steven L. Eddins
4 % Copyright 2010 The MathWorks, Inc.
5
6 function test_this
File data_analysis/unittests/matlab_xunit_3_1_1/doc/+abc_tests/test_that.m deleted (index 9b569db..0000000)
1 % Do-nothing test used in the examples for organizing tests inside packages.
2 %
3 % Steven L. Eddins
4 % Copyright 2010 The MathWorks, Inc.
5
6 function test_that
File data_analysis/unittests/matlab_xunit_3_1_1/doc/+abc_tests/test_this.m deleted (index d7f0ee1..0000000)
1 % Do-nothing test used in the examples for organizing tests inside packages.
2 %
3 % Steven L. Eddins
4 % Copyright 2010 The MathWorks, Inc.
5
6 function test_this
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exException.m deleted (index e1086d8..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How to Test an Error Message
2 % It's surprising to most people (but not quality engineers) how
3 % often programmers make errors in error-handling code. Because of
4 % this unfortunate truth, it is useful to write unit tests that
5 % verify that your MATLAB code throws the proper error, at the
6 % proper time.
7 %
8 % The assertion function that makes this task easy is
9 % |assertExceptionThrown|. This example shows how to write a unit
10 % test that verifies the "Too many input arguments" error for the
11 % |cos| function.
12 %
13 % Your first step is to determine the _error identifier_ associated
14 % with the error message. You can find out the error identifier by
15 % using the |lasterror| function.
16 %
17 % If you call |cos| with two input arguments, like this:
18 %
19 % cos(1, 2)
20 %
21 % you get this error message:
22 %
23 % Error using ==> cos
24 % Too many input arguments.
25 %
26 % Then if you call |lasterror|, you get this output:
27 %
28 % ans =
29 %
30 % message: [1x45 char]
31 % identifier: 'MATLAB:maxrhs'
32 % stack: [0x1 struct]
33 %
34 % So the _identifier_ associated with this error message is
35 % |'MATLAB:maxrhs'|.
36 %
37 % When you write your test function, you'll form an anonymous
38 % function handle that calls |cos| with the erroneous additional
39 % input argument.
40
41 f = @() cos(1, 2)
42
43 %%
44 % You then pass this function to |assertExceptionThrown|, along with
45 % the expected error identifier.
46
47 assertExceptionThrown(f, 'MATLAB:maxrhs');
48
49 %%
50 % |assertExceptionThrown| verifies that when |f()| is called, an
51 % error results with the specified error identifier.
52 %
53 % Here's our error condition test for the |cos| function.
54
55 cd examples_general
56 type testCos
57
58 %%
59 % Run the test using |runtests|.
60
61 runtests testCos
62
63 %%
64 % <../index.html Back to MATLAB xUnit Test Framework>
65
66 %%
67 % Copyright 2008-2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exQuickStart.m deleted (index a7c236c..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How to Write and Run Tests
2 % This example shows how to write and run a couple of test cases for the MATLAB
3 % |fliplr| function.
4
5 %% Make a folder for your tests
6 % To get started, create a folder (directory) that will contain your tests, and
7 % then make that your working folder. The test directory in this example is
8 % example_quick_start.
9
10 cd example_quick_start
11
12 %% Write each test case as a simple M-file
13 % Write each test case as an M-file function that returns no output arguments.
14 % The function name should start or end with "test" or "Test". The test case
15 % passes if the function runs with no error.
16 %
17 % Here's a test-case M-file that verifies the correct output for a vector input.
18
19 type testFliplrVector
20
21 %%
22 % The function |testFliplrVector| calls the function being tested and checks the
23 % output against the expected output. If the output is different than expected,
24 % the function calls |error|.
25 %
26 % Here's another test-case M-file that verifies the correct |fliplr| output for
27 % a matrix input.
28
29 type testFliplrMatrix
30
31 %%
32 % This function is simpler than |testFliplrVector| because it uses the utility
33 % testing function |assertEqual|. |assertEqual| checks to see whether its two
34 % inputs are equal. If they are equal, |assertEqual| simply returns silently.
35 % If they are not equal, |assertEqual| calls |error|.
36
37 %% Run all the tests using |runtests|
38 % To run all your test cases, simply call |runtests|. |runtests| automatically finds
39 % all the test cases in the current directory, runs them, and reports the
40 % results to the Command Window.
41
42 runtests
43
44 %%
45 % <../index.html Back to MATLAB xUnit Test Framework>
46
47 %%
48 % Copyright 2008-2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exRunSpecificTest.m deleted (index df5a706..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How to Run a Specific Test
2 % To run all the test cases in just one M-file, ignoring other test
3 % cases that might be in other files in the same directory, give
4 % the name of the file (without the ".m" extension) as an argument
5 % to |runtests|.
6 %
7 % For example
8
9 cd example_subfunction_tests
10
11 runtests testFliplr
12
13 %%
14 % To run a single test case, add the name of the test case using a
15 % colon (":"), like this:
16
17 runtests testFliplr:testFliplrVector
18
19 %%
20 % <../index.html Back to MATLAB xUnit Test Framework>
21
22 %%
23 % Copyright 2008-2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exRunTestsInADirectory.m deleted (index 977dcf2..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How to Run Tests in Specific Directories
2 % To run all the test cases in a specific directory, give the name of the
3 % directory as an argument to |runtests|.
4 %
5 % For example
6
7 runtests example_subfunction_tests
8
9 %%
10 % To run tests in multiple directories, give each directory name as a separate
11 % argument to |runtests|.
12
13 %%
14 % <../index.html Back to MATLAB xUnit Test Framework>
15
16 %%
17 % Copyright 2008-2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exRunTestsInPackage.m deleted (index 38d48d9..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How to Run Tests in a Package
2 % To run all the test cases in a package, give the name of the
3 % package as an argument to |runtests|. *Note:* Running tests in a package
4 % requires MATLAB R2009a or later.
5 %
6 % For example, suppose you are distributing a set of MATLAB files called the
7 % "ABC Toolbox." Then you could put your tests inside a package called abc_tests
8 % and run them like this:
9
10 runtests abc_tests
11
12 %%
13 % (Note that the initial "+" character in the name of the package folder on disk
14 % is not part of the package name.)
15 %
16 % Or you could put your tests inside a subpackage called abc.tests and run them
17 % like this:
18
19 runtests abc.tests
20
21 %%
22 % You should not use a generic top-level package name such "tests" because then
23 % your package might be unintentionally combined with packages with the same
24 % name created by other people.
25
26 %%
27 % <../index.html Back to MATLAB xUnit Test Framework>
28
29 %%
30 % Copyright 2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exSilentRunning.m deleted (index 25b3f1a..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How to Run Tests Silently and Query the Results
2 % When you run a test suite using |runtests|, the results are
3 % summarized in the Command Window. This example shows you how to
4 % run a test suite so that nothing prints to the Command Window, and
5 % it shows you how to write a program to automatically determine the
6 % results of running the test suite.
7 %
8 % There are four steps to follow.
9 %
10 % 1. Construct a |TestSuite| object. In this example we'll use the |fromPwd|
11 % method of the |TestSuite| class to construct a test suite using all the test
12 % cases found in the |examples_general| directory.
13
14 cd examples_general
15 suite = TestSuite.fromPwd();
16
17 %%
18 % You can look up information about the individual test cases.
19
20 suite.TestComponents{1}
21
22 %%
23 % You can see above that the first test component in the test suite is itself
24 % another test suite, which contains the test cases defined by the M-file named
25 % TestUsingTestCase. Here's what one of these individual test cases looks like:
26
27 suite.TestComponents{1}.TestComponents{1}
28
29 %%
30 % 2. Construct a TestLogger object. This object can receive
31 % notifications about what happens when a test suite is executed.
32
33 logger = TestRunLogger;
34
35 %%
36 % 3. Call the |run| method of the |TestSuite| object, passing it the
37 % logger.
38
39 suite.run(logger);
40
41 %%
42 % The |TestLogger| object can now be queried to determine what
43 % happened during the test.
44
45 logger
46
47 %%
48 % There were eight test cases run (logger.NumTestCases), resulting in
49 % one test failure and one test error. Detailed information about
50 % what went wrong can be found in |logger.Faults|.
51
52 logger.Faults(1)
53
54 %%
55
56 logger.Faults(2)
57
58 %%
59 % You can drill further to determine the names of the failing tests,
60 % as well as the complete stack trace associated with each failure.
61
62 logger.Faults(1).TestCase
63
64 %%
65
66 logger.Faults(1).Exception.stack(1)
67
68 %%
69
70 logger.Faults(1).Exception.stack(2)
71
72 %%
73 % <../index.html Back to MATLAB xUnit Test Framework>
74
75 %%
76 % Copyright 2008-2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exSubfunctionTests.m deleted (index d14d3c4..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How to Put Multiple Test Cases in One M-file
2 % The Quick Start example showed how you can write a simple M-file
3 % to be a single test case. This example shows you how to put multiple
4 % test cases in one M-file.
5 %
6 % Name your M-file beginning or ending with "test", like
7 % "testMyFunc". Start by putting the following two lines at the
8 % beginning of the file. It's important that the output variable
9 % name on line 1 be |test_suite|.
10 %
11 % function test_suite = testMyFunc
12 % initTestSuite;
13 %
14 % Next, add subfunctions to the file. Each subfunction beginning
15 % or ending with "test" becomes an individual test case.
16 %
17 % The directory example_subfunction_tests contains a test M-file
18 % containing subfunction test cases for the |fliplr| function.
19
20 cd example_subfunction_tests
21
22 type testFliplr
23
24 %%
25 % As usual, run the test cases using |runtests|:
26
27 runtests
28
29 %%
30 % <../index.html Back to MATLAB xUnit Test Framework>
31
32 %%
33 % Copyright 2008-2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exTestCase.m deleted (index 264b6f9..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How to Write xUnit-Style Tests by Subclassing TestCase
2 % The MATLAB xUnit architecture is based closely on the xUnit style, in
3 % which each test case is an instance of a subclass of the base
4 % TestCase class. Programmers who are familiar with this style may
5 % want to write their own TestCase subclasses instead of using
6 % <./exSubfunctionTests.html subfunction-based tests>.
7 %
8 % This example shows a TestCase subclass containing test case
9 % methods and test fixture methods. If you are not familiar with
10 % defining your own classes in MATLAB, you might want to review the
11 % MATLAB documentation on
12 % <http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_oop/ug_intropage.html
13 % classes and object-oriented programming>,
14 % or you can simply stick to using subfunction-based tests.
15 %
16 % The sample M-file begins with the |classdef| statement, which sets
17 % the name of the class and indicates that it is a subclass of
18 % |TestCase|.
19
20 cd examples_general
21 dbtype TestUsingTestCase 1
22
23 %%
24 % The properties block contains a field that is initialized by the
25 % setup method and is used by the two test methods.
26
27 dbtype TestUsingTestCase 3:5
28
29 %%
30 % The first method in the methods block is the constructor. It
31 % takes the desired test method name as its input argument, and it
32 % passes that input along to the base class constructor.
33
34 dbtype TestUsingTestCase 7:10
35
36 %%
37 % The |setUp| method creates a figure window and stores its handle in
38 % the field |fh|.
39
40 dbtype TestUsingTestCase 12:14
41
42 %%
43 % Test methods are those beginning with "test".
44
45 dbtype TestUsingTestCase 20:26
46
47 %%
48 % The |tearDown| method cleans up by deleting the figure window.
49
50 dbtype TestUsingTestCase 16:18
51
52 %%
53 % Run the test cases in the class by calling |runtests| with the name
54 % of the class.
55
56 runtests TestUsingTestCase
57
58 %%
59 % <../index.html Back to MATLAB xUnit Test Framework>
60
61 %%
62 % Copyright 2008-2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exTestCaseSearching.m deleted (index 058e52c..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How RUNTESTS Searches for Test Cases
2 % When you call |runtests| with no input arguments:
3 %
4 % >> runtests
5 %
6 % it automatically searches for all the test cases in the current directory. It
7 % looks for test cases in three types of M-files:
8 %
9 % 1. An M-file function whose name begins or ends with "test" or "Test" and that does
10 % not return an output argument. Such a function is considered to be a single
11 % test case.
12 %
13 % 2. An M-file function whose name begins or ends with "test" or "Test" and that returns
14 % an output argument that is a test suite. Such a function is considered to contain
15 % subfunction-style test cases. Each subfunction whose name begins or ends with "test"
16 % or "Test" is a test case.
17 %
18 % 3. An M-file that defines a subclass of TestCase. Each method beginning or ending with
19 % "test" or "Test" is a test case.
20 %
21 % |runtests| uses the |TestSuite| static methods |fromName| and |fromPwd| to
22 % automatically construct the test suites.
23 %
24 % Here are a couple of examples.
25 %
26 % |TestSuite.fromName| takes an M-file name, determines what
27 % kind of test file it is, and returns a cell array of test case objects.
28
29 cd examples_general
30 test_suite_1 = TestSuite.fromName('testSetupExample')
31
32 %%
33 % |TestSuite.fromPwd| returns a test suite based on all the test files in the
34 % current directory.
35
36 test_suite_2 = TestSuite.fromPwd()
37
38 %%
39 % <../index.html Back to MATLAB xUnit Test Framework>
40
41 %%
42 % Copyright 2008-2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exTestFixtures.m deleted (index cf06140..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How to Write Tests That Share Common Set-Up Code
2 % Sometimes you want to write a set of test cases in which the same
3 % set of initialization steps is performed before each test case, or
4 % in which the same set of cleanup steps is performed after each
5 % test case. This set of common _setup_ and _teardown_ code is
6 % called a _test fixture_.
7 %
8 % In subfunction-based test files, you can add subfunctions whose
9 % names begin with "setup" and "teardown". These functions will be
10 % called before and after every test-case subfunction is called. If
11 % the setup function returns an output argument, that value is saved
12 % and passed to every test-case subfunction and also to the teardown
13 % function.
14 %
15 % This example shows a setup function that creates a figure and
16 % returns its handle. The figure handle is passed to each test-case
17 % subfunction. The figure handle is also passed to the teardown
18 % function, which cleans up after each test case by deleting the
19 % figure.
20
21 cd examples_general
22 type testSetupExample
23
24 %%
25 % Run the tests using |runtests|.
26
27 runtests testSetupExample
28
29 %%
30 % You might also want to see the
31 % <./exTestCase.html example on writing test cases by
32 % subclassing TestCase>.
33
34 %%
35 % <../index.html Back to MATLAB xUnit Test Framework>
36
37 %%
38 % Copyright 2008-2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/exTolerance.m deleted (index e325662..0000000)
1 %% <../index.html MATLAB xUnit Test Framework>: How to Test Using a Floating-Point Tolerance
2 % MATLAB performs arithmetic operations using the floating-point
3 % hardware instructions on your processor. Because
4 % almost all floating-point operations are subject to round-off
5 % error, arithmetic operations can sometimes produce surprising
6 % results. Here's an example.
7
8 a = 1 + 0.1 + 0.1 + 0.1
9
10 %%
11 a == 1.3
12
13 %%
14 % So why doesn't |a| equal 1.3? Because 0.1, 1.3, and most other
15 % decimal fractions do not have exact representations in the binary
16 % floating-point number representation your computer uses. The
17 % first line above is doing an approximate addition of 1 plus an
18 % approximation of 0.1, plus an approximation of 0.1, plus an
19 % approximation of 0.1. The second line compares the result of all
20 % that with an approximation of 1.3.
21 %
22 % If you subtract 1.3 from |a|, you can see that the computed result
23 % for |a| is _extremely close_ to the floating-point approximation
24 % of 1.3, but it is not exactly the same.
25
26 a - 1.3
27
28 %%
29 % As a general rule, when comparing the results of floating-point
30 % calculations for equality, it is necessary to use a tolerance
31 % value. Two types of tolerance comparisons are commonly used: absolute
32 % tolerance and relative tolerance. An absolute tolerance comparison of _a_ and _b_
33 % looks like:
34 %
35 % $$|a-b| \leq T$$
36 %
37 % A relative tolerance comparison looks like:
38 %
39 % $$|a-b| \leq T\max(|a|,|b|) + T_f$$
40 %
41 % where _Tf_ is called the _floor tolerance_. It acts as an absolute tolerance
42 % when _a_ and _b_ are very close to 0.
43 %
44 % For example, suppose that _a_ is 100, _b_ is 101, and T is 0.1. Then _a_ and
45 % _b_ would not be considered equal using an absolute tolerance, because 1 >
46 % 0.1. However, _a_ and _b_ would be considered equal using a relative
47 % tolerance, because they differ by only 1 part in 100.
48 %
49 % MATLAB xUnit provides the utility assertion functions called
50 % |assertElementsAlmostEqual| and |assertVectorAlmostEqual|. These functions
51 % make it easy to write tests involving floating-point tolerances.
52 %
53 % |assertElementsAlmostEqual(A,B)| applies the tolerance test independently to
54 % every element of |A| and |B|. The function uses a relative tolerance test by
55 % default, but you make it use an absolute tolerance test, or change the
56 % tolerance values used, by passing additional arguments to it.
57 %
58 % |assertVectorsAlmostEqual(A,B)| applies the tolerance test to the vectors |A|
59 % and |B| in the L2-norm sense. For example, suppose |A| is |[1 1e10|], |B|
60 % is |[2 1e10]|, and the tolerance is 1e-8. Then |A| and |B| would fail an
61 % elementwise relative tolerance comparison, because the relative difference
62 % between the first elements is 0.5. However, they would pass a vector relative
63 % tolerance comparison, because the relative vector difference between |A| and
64 % |B| is only about 1 part in 1e10.
65 %
66 % The |examples_general| directory contains a portion of a unit test for the
67 % |sin| function. The output of |sin| can sometimes be a bit surprising because
68 % of floating-point issues. For example:
69
70 sin(pi)
71
72 %%
73 % That's very close but not exactly equal to 0. Here's how the
74 % |sin| unit test uses |assertElementsAlmostEqual| to write the |sin(pi)|
75 % test with a minimum of fuss.
76
77 cd examples_general
78 type testSin
79
80 %%
81 % Run the test using |runtests|.
82
83 runtests testSin
84
85 %%
86 % <../index.html Back to MATLAB xUnit Test Framework>
87
88 %%
89 % Copyright 2008-2010 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/example_quick_start/testFliplrMatrix.m deleted (index dcb2c1c..0000000)
1 function testFliplrMatrix
2 %testFliplrMatrix Unit test for fliplr with matrix input
3 %
4 % Copyright 2013 The MathWorks, Inc.
5
6 in = magic(3);
7 assertEqual(fliplr(in), in(:, [3 2 1]));
File data_analysis/unittests/matlab_xunit_3_1_1/doc/example_quick_start/testFliplrVector.m deleted (index d146a3f..0000000)
1 function testFliplrVector
2 %testFliplrVector Unit test for fliplr with vector input
3 %
4 % Copyright 2013 The MathWorks, Inc.
5
6 in = [1 4 10];
7 out = fliplr(in);
8 expected_out = [10 4 1];
9
10 if ~isequal(out, expected_out)
11 error('testFliplrVector:notEqual', 'Incorrect output for vector.');
12 end
File data_analysis/unittests/matlab_xunit_3_1_1/doc/example_subfunction_tests/testFliplr.m deleted (index 5486a07..0000000)
1 function test_suite = testFliplr
2 % Copyright 2013 The MathWorks, Inc.
3
4 initTestSuite;
5
6 function testFliplrMatrix
7 in = magic(3);
8 assertEqual(fliplr(in), in(:, [3 2 1]));
9
10 function testFliplrVector
11 assertEqual(fliplr([1 4 10]), [10 4 1]);
12
File data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/TestUsingTestCase.m deleted (index 15e2418..0000000)
1 classdef TestUsingTestCase < TestCase
2 % Copyright 2013 The MathWorks, Inc.
3
4 properties
5 fh
6 end
7
8 methods
9 function self = TestUsingTestCase(name)
10 self = self@TestCase(name);
11 end
12
13 function setUp(self)
14 self.fh = figure;
15 end
16
17 function tearDown(self)
18 delete(self.fh);
19 end
20
21 function testColormapColumns(self)
22 assertEqual(size(get(self.fh, 'Colormap'), 2), 3);
23 end
24
25 function testPointer(self)
26 assertEqual(get(self.fh, 'Pointer'), 'arrow');
27 end
28 end
29 end
File data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/testBadSinTest.m deleted (index e580276..0000000)
1 function test_suite = testBadSinTest
2 % Copyright 2013 The MathWorks, Inc.
3
4 initTestSuite;
5
6 function testSinPi
7 % Example of a failing test case. The test writer should have used
8 % assertAlmostEqual here.
9 assertEqual(sin(pi), 0);
File data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/testCos.m deleted (index da2eaea..0000000)
1 function test_suite = testCos
2 % Copyright 2013 The MathWorks, Inc.
3
4 initTestSuite;
5
6 function testTooManyInputs
7 assertExceptionThrown(@() cos(1, 2), 'MATLAB:maxrhs');
File data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/testSetupExample.m deleted (index ce614a6..0000000)
1 function test_suite = testSetupExample
2 % Copyright 2013 The MathWorks, Inc.
3
4 initTestSuite;
5
6 function fh = setup
7 fh = figure;
8
9 function teardown(fh)
10 delete(fh);
11
12 function testColormapColumns(fh)
13 assertEqual(size(get(fh, 'Colormap'), 2), 3);
14
15 function testPointer(fh)
16 assertEqual(get(fh, 'Pointer'), 'arrow');
File data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/testSin.m deleted (index 09787d8..0000000)
1 function testSin
2 % Copyright 2013 The MathWorks, Inc.
3
4 assertElementsAlmostEqual(sin(pi), 0);
File data_analysis/unittests/matlab_xunit_3_1_1/doc/examples_general/testWithSetupError.m deleted (index 1db85b9..0000000)
1 function test_suite = testWithSetupError
2 % Copyright 2013 The MathWorks, Inc.
3 %
4 %Example of a test with an error. The setup function calls cos with
5 %too many input arguments.
6
7 initTestSuite;
8
9 function testData = setup
10 testData = cos(1, 2);
11
12 function testMyFeature(testData)
13 assertEqual(1, 1);
14
15 function teardown(testData)
File data_analysis/unittests/matlab_xunit_3_1_1/doc/file_exchange_description.txt deleted (index f0e278a..0000000)
1 NOTE: As of R2013a (March 2013), MATLAB includes a unit test framework. There are no plans to continue further development of MATLAB xUnit. For information about the new unit test framework in MATLAB, see the documentation (http://www.mathworks.com/help/matlab/matlab-unit-test-framework.html).
2
3 MATLAB xUnit Test Framework is a unit test framework for MATLAB code.
4
5 MATLAB xUnit is designed to be easy to use for MATLAB users with a wide range of experience. Users can write tests using ordinary M-files that are very simple in structure.
6
7 MATLAB xUnit comes with extensive documentation that ranges in scope from a "Getting Started" section to advanced techniques and architectural notes. You can view this documentation online without downloading the package. For example, scroll down to the "Published M Files" section on this page and click on "MATLAB xUnit Quick Start - How to write and run tests." To see all the MATLAB xUnit documentation online, scroll down to the "HTML Files" section on this page and click on "Readme.html."
8
9 Only the "xunit" directory is needed to use the framework. The "tests" directory contains the framework's own test suite. The "architecture" directory contains architectural notes on the framework's design and how it might be extended.
10
11 MATLAB xUnit can be used with MATLAB releases R2008a and later. MATLAB xUnit relies heavily on object-oriented language features introduced in R2008a and will not work with earlier releases.
12
13 Copyright 2013 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/doc/helptoc.xml deleted (index 8836de5..0000000)
1 <?xml version='1.0' encoding='ISO-8859-1' ?>
2 <!-- Copyright 2013 The MathWorks, Inc. -->
3
4 <toc version="1.0">
5
6 <tocitem target="index.html">MATLAB xUnit Test Framework for MATLAB
7 <tocitem target="html/exQuickStart.html">
8 Quick Start: How to Write and Run Tests
9 </tocitem>
10 <tocitem target="html/exSubfunctionTests.html">
11 How to Put Multiple Test Cases in One M-file
12 </tocitem>
13 <tocitem target="html/exRunSpecificTest.html">
14 How to Run a Specific Test
15 </tocitem>
16 <tocitem target="html/exRunTestsInADirectory.html">
17 How to Run Tests in Specific Directories
18 </tocitem>
19 <tocitem target="html/exRunTestsInPackage.html">
20 How to Run Tests in a Package
21 </tocitem>
22 <tocitem target="html/exTolerance.html">
23 How to Test Using a Floating-Point Tolerance
24 </tocitem>
25 <tocitem target="html/exException.html">
26 How to Test an Error Message
27 </tocitem>
28 <tocitem target="html/exSilentRunning.html">
29 How to Run Tests Silently and Query the Results
30 </tocitem>
31 <tocitem target="html/exTestFixtures.html">
32 How to Write Tests That Share Common Set-Up Code
33 </tocitem>
34 <tocitem target="html/exTestCase.html">
35 How to Write xUnit-Style Tests by Subclassing TestCase
36 </tocitem>
37 <tocitem target="html/exTestCaseSearching.html">
38 How MATLAB xUnit Searches for Test Cases
39 </tocitem>
40 <tocitem target="http://www.mathworks.com/matlabcentral/fileexchange/22846" image="$toolbox/matlab/icons/webicon.gif">
41 Latest Version
42 </tocitem>
43 </tocitem>
44
45
46
47 </toc>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exException.html deleted (index c4d0ee4..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML is auto-generated from an M-file.
8 To make changes, update the M-file and republish this document.
9 --><title>MATLAB xUnit Test Framework: How to Test an Error Message</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-07-29"><meta name="m-file" content="exException"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How to Test an Error Message</h1><p>It's surprising to most people (but not quality engineers) how often programmers make errors in error-handling code. Because of this unfortunate truth, it is useful to write unit tests that verify that your MATLAB code throws the proper error, at the proper time.</p><p>The assertion function that makes this task easy is <tt>assertExceptionThrown</tt>. This example shows how to write a unit test that verifies the "Too many input arguments" error for the <tt>cos</tt> function.</p><p>Your first step is to determine the <i>error identifier</i> associated with the error message. You can find out the error identifier by using the <tt>lasterror</tt> function.</p><p>If you call <tt>cos</tt> with two input arguments, like this:</p><pre> cos(1, 2)</pre><p>you get this error message:</p><pre> Error using ==&gt; cos
66 Too many input arguments.</pre><p>Then if you call <tt>lasterror</tt>, you get this output:</p><pre> ans =</pre><pre> message: [1x45 char]
67 identifier: 'MATLAB:maxrhs'
68 stack: [0x1 struct]</pre><p>So the <i>identifier</i> associated with this error message is <tt>'MATLAB:maxrhs'</tt>.</p><p>When you write your test function, you'll form an anonymous function handle that calls <tt>cos</tt> with the erroneous additional input argument.</p><pre class="codeinput">f = @() cos(1, 2)
69 </pre><pre class="codeoutput">
70 f =
71
72 @()cos(1,2)
73
74 </pre><p>You then pass this function to <tt>assertExceptionThrown</tt>, along with the expected error identifier.</p><pre class="codeinput">assertExceptionThrown(f, <span class="string">'MATLAB:maxrhs'</span>);
75 </pre><p><tt>assertExceptionThrown</tt> verifies that when <tt>f()</tt> is called, an error results with the specified error identifier.</p><p>Here's our error condition test for the <tt>cos</tt> function.</p><pre class="codeinput">cd <span class="string">examples_general</span>
76 type <span class="string">testCos</span>
77 </pre><pre class="codeoutput">
78 function test_suite = testCos
79 initTestSuite;
80
81 function testTooManyInputs
82 assertExceptionThrown(@() cos(1, 2), 'MATLAB:maxrhs');
83 </pre><p>Run the test using <tt>runtests</tt>.</p><pre class="codeinput">runtests <span class="string">testCos</span>
84 </pre><pre class="codeoutput">Starting test run with 1 test case.
85 .
86 PASSED in 0.018 seconds.
87 </pre><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2008-2010 The MathWorks, Inc.<br>
88 Published with MATLAB&reg; 7.10<br></p></div><!--
89 ##### SOURCE BEGIN #####
90 %% <../index.html MATLAB xUnit Test Framework>: How to Test an Error Message
91 % It's surprising to most people (but not quality engineers) how
92 % often programmers make errors in error-handling code. Because of
93 % this unfortunate truth, it is useful to write unit tests that
94 % verify that your MATLAB code throws the proper error, at the
95 % proper time.
96 %
97 % The assertion function that makes this task easy is
98 % |assertExceptionThrown|. This example shows how to write a unit
99 % test that verifies the "Too many input arguments" error for the
100 % |cos| function.
101 %
102 % Your first step is to determine the _error identifier_ associated
103 % with the error message. You can find out the error identifier by
104 % using the |lasterror| function.
105 %
106 % If you call |cos| with two input arguments, like this:
107 %
108 % cos(1, 2)
109 %
110 % you get this error message:
111 %
112 % Error using ==> cos
113 % Too many input arguments.
114 %
115 % Then if you call |lasterror|, you get this output:
116 %
117 % ans =
118 %
119 % message: [1x45 char]
120 % identifier: 'MATLAB:maxrhs'
121 % stack: [0x1 struct]
122 %
123 % So the _identifier_ associated with this error message is
124 % |'MATLAB:maxrhs'|.
125 %
126 % When you write your test function, you'll form an anonymous
127 % function handle that calls |cos| with the erroneous additional
128 % input argument.
129
130 f = @() cos(1, 2)
131
132 %%
133 % You then pass this function to |assertExceptionThrown|, along with
134 % the expected error identifier.
135
136 assertExceptionThrown(f, 'MATLAB:maxrhs');
137
138 %%
139 % |assertExceptionThrown| verifies that when |f()| is called, an
140 % error results with the specified error identifier.
141 %
142 % Here's our error condition test for the |cos| function.
143
144 cd examples_general
145 type testCos
146
147 %%
148 % Run the test using |runtests|.
149
150 runtests testCos
151
152 %%
153 % <../index.html Back to MATLAB xUnit Test Framework>
154
155 %%
156 % Copyright 2008-2010 The MathWorks, Inc.
157 ##### SOURCE END #####
158 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exQuickStart.html deleted (index 935b4df..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML is auto-generated from an M-file.
8 To make changes, update the M-file and republish this document.
9 --><title>MATLAB xUnit Test Framework: How to Write and Run Tests</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-07-29"><meta name="m-file" content="exQuickStart"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How to Write and Run Tests</h1><!--introduction--><p>This example shows how to write and run a couple of test cases for the MATLAB <tt>fliplr</tt> function.</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Make a folder for your tests</a></li><li><a href="#2">Write each test case as a simple M-file</a></li><li><a href="#5">Run all the tests using <tt>runtests</tt></a></li></ul></div><h2>Make a folder for your tests<a name="1"></a></h2><p>To get started, create a folder (directory) that will contain your tests, and then make that your working folder. The test directory in this example is example_quick_start.</p><pre class="codeinput">cd <span class="string">example_quick_start</span>
66 </pre><h2>Write each test case as a simple M-file<a name="2"></a></h2><p>Write each test case as an M-file function that returns no output arguments. The function name should start or end with "test" or "Test". The test case passes if the function runs with no error.</p><p>Here's a test-case M-file that verifies the correct output for a vector input.</p><pre class="codeinput">type <span class="string">testFliplrVector</span>
67 </pre><pre class="codeoutput">
68 function testFliplrVector
69 %testFliplrVector Unit test for fliplr with vector input
70
71 in = [1 4 10];
72 out = fliplr(in);
73 expected_out = [10 4 1];
74
75 if ~isequal(out, expected_out)
76 error('testFliplrVector:notEqual', 'Incorrect output for vector.');
77 end
78
79 </pre><p>The function <tt>testFliplrVector</tt> calls the function being tested and checks the output against the expected output. If the output is different than expected, the function calls <tt>error</tt>.</p><p>Here's another test-case M-file that verifies the correct <tt>fliplr</tt> output for a matrix input.</p><pre class="codeinput">type <span class="string">testFliplrMatrix</span>
80 </pre><pre class="codeoutput">
81 function testFliplrMatrix
82 %testFliplrMatrix Unit test for fliplr with matrix input
83
84 in = magic(3);
85 assertEqual(fliplr(in), in(:, [3 2 1]));
86
87 </pre><p>This function is simpler than <tt>testFliplrVector</tt> because it uses the utility testing function <tt>assertEqual</tt>. <tt>assertEqual</tt> checks to see whether its two inputs are equal. If they are equal, <tt>assertEqual</tt> simply returns silently. If they are not equal, <tt>assertEqual</tt> calls <tt>error</tt>.</p><h2>Run all the tests using <tt>runtests</tt><a name="5"></a></h2><p>To run all your test cases, simply call <tt>runtests</tt>. <tt>runtests</tt> automatically finds all the test cases in the current directory, runs them, and reports the results to the Command Window.</p><pre class="codeinput">runtests
88 </pre><pre class="codeoutput">Starting test run with 2 test cases.
89 ..
90 PASSED in 0.002 seconds.
91 </pre><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2008-2010 The MathWorks, Inc.<br>
92 Published with MATLAB&reg; 7.10<br></p></div><!--
93 ##### SOURCE BEGIN #####
94 %% <../index.html MATLAB xUnit Test Framework>: How to Write and Run Tests
95 % This example shows how to write and run a couple of test cases for the MATLAB
96 % |fliplr| function.
97
98 %% Make a folder for your tests
99 % To get started, create a folder (directory) that will contain your tests, and
100 % then make that your working folder. The test directory in this example is
101 % example_quick_start.
102
103 cd example_quick_start
104
105 %% Write each test case as a simple M-file
106 % Write each test case as an M-file function that returns no output arguments.
107 % The function name should start or end with "test" or "Test". The test case
108 % passes if the function runs with no error.
109 %
110 % Here's a test-case M-file that verifies the correct output for a vector input.
111
112 type testFliplrVector
113
114 %%
115 % The function |testFliplrVector| calls the function being tested and checks the
116 % output against the expected output. If the output is different than expected,
117 % the function calls |error|.
118 %
119 % Here's another test-case M-file that verifies the correct |fliplr| output for
120 % a matrix input.
121
122 type testFliplrMatrix
123
124 %%
125 % This function is simpler than |testFliplrVector| because it uses the utility
126 % testing function |assertEqual|. |assertEqual| checks to see whether its two
127 % inputs are equal. If they are equal, |assertEqual| simply returns silently.
128 % If they are not equal, |assertEqual| calls |error|.
129
130 %% Run all the tests using |runtests|
131 % To run all your test cases, simply call |runtests|. |runtests| automatically finds
132 % all the test cases in the current directory, runs them, and reports the
133 % results to the Command Window.
134
135 runtests
136
137 %%
138 % <../index.html Back to MATLAB xUnit Test Framework>
139
140 %%
141 % Copyright 2008-2010 The MathWorks, Inc.
142 ##### SOURCE END #####
143 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exRunSpecificTest.html deleted (index 4207515..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML is auto-generated from an M-file.
8 To make changes, update the M-file and republish this document.
9 --><title>MATLAB xUnit Test Framework: How to Run a Specific Test</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-07-29"><meta name="m-file" content="exRunSpecificTest"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How to Run a Specific Test</h1><p>To run all the test cases in just one M-file, ignoring other test cases that might be in other files in the same directory, give the name of the file (without the ".m" extension) as an argument to <tt>runtests</tt>.</p><p>For example</p><pre class="codeinput">cd <span class="string">example_subfunction_tests</span>
66
67 runtests <span class="string">testFliplr</span>
68 </pre><pre class="codeoutput">Starting test run with 2 test cases.
69 ..
70 PASSED in 0.023 seconds.
71 </pre><p>To run a single test case, add the name of the test case using a colon (":"), like this:</p><pre class="codeinput">runtests <span class="string">testFliplr:testFliplrVector</span>
72 </pre><pre class="codeoutput">Starting test run with 1 test case.
73 .
74 PASSED in 0.001 seconds.
75 </pre><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2008-2010 The MathWorks, Inc.<br>
76 Published with MATLAB&reg; 7.10<br></p></div><!--
77 ##### SOURCE BEGIN #####
78 %% <../index.html MATLAB xUnit Test Framework>: How to Run a Specific Test
79 % To run all the test cases in just one M-file, ignoring other test
80 % cases that might be in other files in the same directory, give
81 % the name of the file (without the ".m" extension) as an argument
82 % to |runtests|.
83 %
84 % For example
85
86 cd example_subfunction_tests
87
88 runtests testFliplr
89
90 %%
91 % To run a single test case, add the name of the test case using a
92 % colon (":"), like this:
93
94 runtests testFliplr:testFliplrVector
95
96 %%
97 % <../index.html Back to MATLAB xUnit Test Framework>
98
99 %%
100 % Copyright 2008-2010 The MathWorks, Inc.
101
102 ##### SOURCE END #####
103 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exRunTestsInADirectory.html deleted (index d2249a8..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML is auto-generated from an M-file.
8 To make changes, update the M-file and republish this document.
9 --><title>MATLAB xUnit Test Framework: How to Run Tests in Specific Directories</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-07-29"><meta name="m-file" content="exRunTestsInADirectory"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How to Run Tests in Specific Directories</h1><p>To run all the test cases in a specific directory, give the name of the directory as an argument to <tt>runtests</tt>.</p><p>For example</p><pre class="codeinput">runtests <span class="string">example_subfunction_tests</span>
66 </pre><pre class="codeoutput">Starting test run with 2 test cases.
67 ..
68 PASSED in 0.062 seconds.
69 </pre><p>To run tests in multiple directories, give each directory name as a separate argument to <tt>runtests</tt>.</p><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2008-2010 The MathWorks, Inc.<br>
70 Published with MATLAB&reg; 7.10<br></p></div><!--
71 ##### SOURCE BEGIN #####
72 %% <../index.html MATLAB xUnit Test Framework>: How to Run Tests in Specific Directories
73 % To run all the test cases in a specific directory, give the name of the
74 % directory as an argument to |runtests|.
75 %
76 % For example
77
78 runtests example_subfunction_tests
79
80 %%
81 % To run tests in multiple directories, give each directory name as a separate
82 % argument to |runtests|.
83
84 %%
85 % <../index.html Back to MATLAB xUnit Test Framework>
86
87 %%
88 % Copyright 2008-2010 The MathWorks, Inc.
89
90 ##### SOURCE END #####
91 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exRunTestsInPackage.html deleted (index 3174627..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML was auto-generated from MATLAB code.
8 To make changes, update the MATLAB code and republish this document.
9 --><title>MATLAB xUnit Test Framework: How to Run Tests in a Package</title><meta name="generator" content="MATLAB 7.11"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2010-11-19"><meta name="DC.source" content="exRunTestsInPackage.m"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How to Run Tests in a Package</h1><p>To run all the test cases in a package, give the name of the package as an argument to <tt>runtests</tt>. <b>Note:</b> Running tests in a package requires MATLAB R2009a or later.</p><p>For example, suppose you are distributing a set of MATLAB files called the "ABC Toolbox." Then you could put your tests inside a package called abc_tests and run them like this:</p><pre class="codeinput">runtests <span class="string">abc_tests</span>
66 </pre><pre class="codeoutput">Test suite: abc_tests
67 Test suite location: Package
68 19-Nov-2010 14:14:36
69
70 Starting test run with 2 test cases.
71 ..
72 PASSED in 0.028 seconds.
73 </pre><p>(Note that the initial "+" character in the name of the package folder on disk is not part of the package name.)</p><p>Or you could put your tests inside a subpackage called abc.tests and run them like this:</p><pre class="codeinput">runtests <span class="string">abc.tests</span>
74 </pre><pre class="codeoutput">Test suite: abc.tests
75 Test suite location: Package
76 19-Nov-2010 14:14:36
77
78 Starting test run with 2 test cases.
79 ..
80 PASSED in 0.001 seconds.
81 </pre><p>You should not use a generic top-level package name such "tests" because then your package might be unintentionally combined with packages with the same name created by other people.</p><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2010 The MathWorks, Inc.<br>
82 Published with MATLAB&reg; 7.11<br></p></div><!--
83 ##### SOURCE BEGIN #####
84 %% <../index.html MATLAB xUnit Test Framework>: How to Run Tests in a Package
85 % To run all the test cases in a package, give the name of the
86 % package as an argument to |runtests|. *Note:* Running tests in a package
87 % requires MATLAB R2009a or later.
88 %
89 % For example, suppose you are distributing a set of MATLAB files called the
90 % "ABC Toolbox." Then you could put your tests inside a package called abc_tests
91 % and run them like this:
92
93 runtests abc_tests
94
95 %%
96 % (Note that the initial "+" character in the name of the package folder on disk
97 % is not part of the package name.)
98 %
99 % Or you could put your tests inside a subpackage called abc.tests and run them
100 % like this:
101
102 runtests abc.tests
103
104 %%
105 % You should not use a generic top-level package name such "tests" because then
106 % your package might be unintentionally combined with packages with the same
107 % name created by other people.
108
109 %%
110 % <../index.html Back to MATLAB xUnit Test Framework>
111
112 %%
113 % Copyright 2010 The MathWorks, Inc.
114
115 ##### SOURCE END #####
116 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exSilentRunning.html deleted (index 28576a3..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML is auto-generated from an M-file.
8 To make changes, update the M-file and republish this document.
9 --><title>MATLAB xUnit Test Framework: How to Run Tests Silently and Query the Results</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-07-29"><meta name="m-file" content="exSilentRunning"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How to Run Tests Silently and Query the Results</h1><p>When you run a test suite using <tt>runtests</tt>, the results are summarized in the Command Window. This example shows you how to run a test suite so that nothing prints to the Command Window, and it shows you how to write a program to automatically determine the results of running the test suite.</p><p>There are four steps to follow.</p><p>1. Construct a <tt>TestSuite</tt> object. In this example we'll use the <tt>fromPwd</tt> method of the <tt>TestSuite</tt> class to construct a test suite using all the test cases found in the <tt>examples_general</tt> directory.</p><pre class="codeinput">cd <span class="string">examples_general</span>
66 suite = TestSuite.fromPwd();
67 </pre><p>You can look up information about the individual test cases.</p><pre class="codeinput">suite.TestComponents{1}
68 </pre><pre class="codeoutput">
69 ans =
70
71 TestSuite handle
72
73 Properties:
74 TestComponents: {[1x1 TestUsingTestCase] [1x1 TestUsingTestCase]}
75 Name: 'TestUsingTestCase'
76 Location: [1x80 char]
77
78
79 </pre><p>You can see above that the first test component in the test suite is itself another test suite, which contains the test cases defined by the M-file named TestUsingTestCase. Here's what one of these individual test cases looks like:</p><pre class="codeinput">suite.TestComponents{1}.TestComponents{1}
80 </pre><pre class="codeoutput">
81 ans =
82
83 TestUsingTestCase handle
84
85 Properties:
86 fh: []
87 MethodName: 'testPointer'
88 Name: 'testPointer'
89 Location: 'C:\Users\eddins\local-work\matlab_xunit\doc\examples_general\TestUsingTestCase.m'
90
91
92 </pre><p>2. Construct a TestLogger object. This object can receive notifications about what happens when a test suite is executed.</p><pre class="codeinput">logger = TestRunLogger;
93 </pre><p>3. Call the <tt>run</tt> method of the <tt>TestSuite</tt> object, passing it the logger.</p><pre class="codeinput">suite.run(logger);
94 </pre><p>The <tt>TestLogger</tt> object can now be queried to determine what happened during the test.</p><pre class="codeinput">logger
95 </pre><pre class="codeoutput">
96 logger =
97
98 TestRunLogger handle
99
100 Properties:
101 Log: {1x34 cell}
102 NumFailures: 1
103 NumErrors: 1
104 NumTestCases: 8
105 Faults: [1x2 struct]
106
107
108 </pre><p>There were eight test cases run (logger.NumTestCases), resulting in one test failure and one test error. Detailed information about what went wrong can be found in <tt>logger.Faults</tt>.</p><pre class="codeinput">logger.Faults(1)
109 </pre><pre class="codeoutput">
110 ans =
111
112 Type: 'failure'
113 TestCase: [1x1 FunctionHandleTestCase]
114 Exception: [1x1 MException]
115
116 </pre><pre class="codeinput">logger.Faults(2)
117 </pre><pre class="codeoutput">
118 ans =
119
120 Type: 'error'
121 TestCase: [1x1 FunctionHandleTestCase]
122 Exception: [1x1 MException]
123
124 </pre><p>You can drill further to determine the names of the failing tests, as well as the complete stack trace associated with each failure.</p><pre class="codeinput">logger.Faults(1).TestCase
125 </pre><pre class="codeoutput">
126 ans =
127
128 FunctionHandleTestCase handle
129
130 Properties:
131 MethodName: 'runTestCase'
132 Name: 'testSinPi'
133 Location: 'C:\Users\eddins\local-work\matlab_xunit\doc\examples_general\testBadSinTest.m'
134
135
136 </pre><pre class="codeinput">logger.Faults(1).Exception.stack(1)
137 </pre><pre class="codeoutput">
138 ans =
139
140 file: 'C:\Users\eddins\local-work\matlab_xunit\doc\examples_general\testBadSinTest.m'
141 name: 'testSinPi'
142 line: 7
143
144 </pre><pre class="codeinput">logger.Faults(1).Exception.stack(2)
145 </pre><pre class="codeoutput">
146 ans =
147
148 file: 'C:\Users\eddins\local-work\matlab_xunit\xunit\FunctionHandleTestCase.m'
149 name: 'FunctionHandleTestCase.runTestCase'
150 line: 112
151
152 </pre><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2008-2010 The MathWorks, Inc.<br>
153 Published with MATLAB&reg; 7.10<br></p></div><!--
154 ##### SOURCE BEGIN #####
155 %% <../index.html MATLAB xUnit Test Framework>: How to Run Tests Silently and Query the Results
156 % When you run a test suite using |runtests|, the results are
157 % summarized in the Command Window. This example shows you how to
158 % run a test suite so that nothing prints to the Command Window, and
159 % it shows you how to write a program to automatically determine the
160 % results of running the test suite.
161 %
162 % There are four steps to follow.
163 %
164 % 1. Construct a |TestSuite| object. In this example we'll use the |fromPwd|
165 % method of the |TestSuite| class to construct a test suite using all the test
166 % cases found in the |examples_general| directory.
167
168 cd examples_general
169 suite = TestSuite.fromPwd();
170
171 %%
172 % You can look up information about the individual test cases.
173
174 suite.TestComponents{1}
175
176 %%
177 % You can see above that the first test component in the test suite is itself
178 % another test suite, which contains the test cases defined by the M-file named
179 % TestUsingTestCase. Here's what one of these individual test cases looks like:
180
181 suite.TestComponents{1}.TestComponents{1}
182
183 %%
184 % 2. Construct a TestLogger object. This object can receive
185 % notifications about what happens when a test suite is executed.
186
187 logger = TestRunLogger;
188
189 %%
190 % 3. Call the |run| method of the |TestSuite| object, passing it the
191 % logger.
192
193 suite.run(logger);
194
195 %%
196 % The |TestLogger| object can now be queried to determine what
197 % happened during the test.
198
199 logger
200
201 %%
202 % There were eight test cases run (logger.NumTestCases), resulting in
203 % one test failure and one test error. Detailed information about
204 % what went wrong can be found in |logger.Faults|.
205
206 logger.Faults(1)
207
208 %%
209
210 logger.Faults(2)
211
212 %%
213 % You can drill further to determine the names of the failing tests,
214 % as well as the complete stack trace associated with each failure.
215
216 logger.Faults(1).TestCase
217
218 %%
219
220 logger.Faults(1).Exception.stack(1)
221
222 %%
223
224 logger.Faults(1).Exception.stack(2)
225
226 %%
227 % <../index.html Back to MATLAB xUnit Test Framework>
228
229 %%
230 % Copyright 2008-2010 The MathWorks, Inc.
231
232 ##### SOURCE END #####
233 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exSubfunctionTests.html deleted (index 0fa3530..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML is auto-generated from an M-file.
8 To make changes, update the M-file and republish this document.
9 --><title>MATLAB xUnit Test Framework: How to Put Multiple Test Cases in One M-file</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-07-29"><meta name="m-file" content="exSubfunctionTests"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How to Put Multiple Test Cases in One M-file</h1><p>The Quick Start example showed how you can write a simple M-file to be a single test case. This example shows you how to put multiple test cases in one M-file.</p><p>Name your M-file beginning or ending with "test", like "testMyFunc". Start by putting the following two lines at the beginning of the file. It's important that the output variable name on line 1 be <tt>test_suite</tt>.</p><pre> function test_suite = testMyFunc
66 initTestSuite;</pre><p>Next, add subfunctions to the file. Each subfunction beginning or ending with "test" becomes an individual test case.</p><p>The directory example_subfunction_tests contains a test M-file containing subfunction test cases for the <tt>fliplr</tt> function.</p><pre class="codeinput">cd <span class="string">example_subfunction_tests</span>
67
68 type <span class="string">testFliplr</span>
69 </pre><pre class="codeoutput">
70 function test_suite = testFliplr
71 initTestSuite;
72
73 function testFliplrMatrix
74 in = magic(3);
75 assertEqual(fliplr(in), in(:, [3 2 1]));
76
77 function testFliplrVector
78 assertEqual(fliplr([1 4 10]), [10 4 1]);
79
80
81 </pre><p>As usual, run the test cases using <tt>runtests</tt>:</p><pre class="codeinput">runtests
82 </pre><pre class="codeoutput">Starting test run with 2 test cases.
83 ..
84 PASSED in 0.027 seconds.
85 </pre><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2008-2010 The MathWorks, Inc.<br>
86 Published with MATLAB&reg; 7.10<br></p></div><!--
87 ##### SOURCE BEGIN #####
88 %% <../index.html MATLAB xUnit Test Framework>: How to Put Multiple Test Cases in One M-file
89 % The Quick Start example showed how you can write a simple M-file
90 % to be a single test case. This example shows you how to put multiple
91 % test cases in one M-file.
92 %
93 % Name your M-file beginning or ending with "test", like
94 % "testMyFunc". Start by putting the following two lines at the
95 % beginning of the file. It's important that the output variable
96 % name on line 1 be |test_suite|.
97 %
98 % function test_suite = testMyFunc
99 % initTestSuite;
100 %
101 % Next, add subfunctions to the file. Each subfunction beginning
102 % or ending with "test" becomes an individual test case.
103 %
104 % The directory example_subfunction_tests contains a test M-file
105 % containing subfunction test cases for the |fliplr| function.
106
107 cd example_subfunction_tests
108
109 type testFliplr
110
111 %%
112 % As usual, run the test cases using |runtests|:
113
114 runtests
115
116 %%
117 % <../index.html Back to MATLAB xUnit Test Framework>
118
119 %%
120 % Copyright 2008-2010 The MathWorks, Inc.
121 ##### SOURCE END #####
122 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTestCase.html deleted (index c8c096d..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML is auto-generated from an M-file.
8 To make changes, update the M-file and republish this document.
9 --><title>MATLAB xUnit Test Framework: How to Write xUnit-Style Tests by Subclassing TestCase</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-07-29"><meta name="m-file" content="exTestCase"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How to Write xUnit-Style Tests by Subclassing TestCase</h1><p>The MATLAB xUnit architecture is based closely on the xUnit style, in which each test case is an instance of a subclass of the base TestCase class. Programmers who are familiar with this style may want to write their own TestCase subclasses instead of using <a href="./exSubfunctionTests.html">subfunction-based tests</a>.</p><p>This example shows a TestCase subclass containing test case methods and test fixture methods. If you are not familiar with defining your own classes in MATLAB, you might want to review the MATLAB documentation on <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_oop/ug_intropage.html">classes and object-oriented programming</a>, or you can simply stick to using subfunction-based tests.</p><p>The sample M-file begins with the <tt>classdef</tt> statement, which sets the name of the class and indicates that it is a subclass of <tt>TestCase</tt>.</p><pre class="codeinput">cd <span class="string">examples_general</span>
66 dbtype <span class="string">TestUsingTestCase</span> <span class="string">1</span>
67 </pre><pre class="codeoutput">
68 1 classdef TestUsingTestCase &lt; TestCase
69
70 </pre><p>The properties block contains a field that is initialized by the setup method and is used by the two test methods.</p><pre class="codeinput">dbtype <span class="string">TestUsingTestCase</span> <span class="string">3:5</span>
71 </pre><pre class="codeoutput">
72 3 properties
73 4 fh
74 5 end
75
76 </pre><p>The first method in the methods block is the constructor. It takes the desired test method name as its input argument, and it passes that input along to the base class constructor.</p><pre class="codeinput">dbtype <span class="string">TestUsingTestCase</span> <span class="string">7:10</span>
77 </pre><pre class="codeoutput">
78 7 methods
79 8 function self = TestUsingTestCase(name)
80 9 self = self@TestCase(name);
81 10 end
82
83 </pre><p>The <tt>setUp</tt> method creates a figure window and stores its handle in the field <tt>fh</tt>.</p><pre class="codeinput">dbtype <span class="string">TestUsingTestCase</span> <span class="string">12:14</span>
84 </pre><pre class="codeoutput">
85 12 function setUp(self)
86 13 self.fh = figure;
87 14 end
88
89 </pre><p>Test methods are those beginning with "test".</p><pre class="codeinput">dbtype <span class="string">TestUsingTestCase</span> <span class="string">20:26</span>
90 </pre><pre class="codeoutput">
91 20 function testColormapColumns(self)
92 21 assertEqual(size(get(self.fh, 'Colormap'), 2), 3);
93 22 end
94 23
95 24 function testPointer(self)
96 25 assertEqual(get(self.fh, 'Pointer'), 'arrow');
97 26 end
98
99 </pre><p>The <tt>tearDown</tt> method cleans up by deleting the figure window.</p><pre class="codeinput">dbtype <span class="string">TestUsingTestCase</span> <span class="string">16:18</span>
100 </pre><pre class="codeoutput">
101 16 function tearDown(self)
102 17 delete(self.fh);
103 18 end
104
105 </pre><p>Run the test cases in the class by calling <tt>runtests</tt> with the name of the class.</p><pre class="codeinput">runtests <span class="string">TestUsingTestCase</span>
106 </pre><pre class="codeoutput">Starting test run with 2 test cases.
107 ..
108 PASSED in 0.095 seconds.
109 </pre><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2008-2010 The MathWorks, Inc.<br>
110 Published with MATLAB&reg; 7.10<br></p></div><!--
111 ##### SOURCE BEGIN #####
112 %% <../index.html MATLAB xUnit Test Framework>: How to Write xUnit-Style Tests by Subclassing TestCase
113 % The MATLAB xUnit architecture is based closely on the xUnit style, in
114 % which each test case is an instance of a subclass of the base
115 % TestCase class. Programmers who are familiar with this style may
116 % want to write their own TestCase subclasses instead of using
117 % <./exSubfunctionTests.html subfunction-based tests>.
118 %
119 % This example shows a TestCase subclass containing test case
120 % methods and test fixture methods. If you are not familiar with
121 % defining your own classes in MATLAB, you might want to review the
122 % MATLAB documentation on
123 % <http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_oop/ug_intropage.html
124 % classes and object-oriented programming>,
125 % or you can simply stick to using subfunction-based tests.
126 %
127 % The sample M-file begins with the |classdef| statement, which sets
128 % the name of the class and indicates that it is a subclass of
129 % |TestCase|.
130
131 cd examples_general
132 dbtype TestUsingTestCase 1
133
134 %%
135 % The properties block contains a field that is initialized by the
136 % setup method and is used by the two test methods.
137
138 dbtype TestUsingTestCase 3:5
139
140 %%
141 % The first method in the methods block is the constructor. It
142 % takes the desired test method name as its input argument, and it
143 % passes that input along to the base class constructor.
144
145 dbtype TestUsingTestCase 7:10
146
147 %%
148 % The |setUp| method creates a figure window and stores its handle in
149 % the field |fh|.
150
151 dbtype TestUsingTestCase 12:14
152
153 %%
154 % Test methods are those beginning with "test".
155
156 dbtype TestUsingTestCase 20:26
157
158 %%
159 % The |tearDown| method cleans up by deleting the figure window.
160
161 dbtype TestUsingTestCase 16:18
162
163 %%
164 % Run the test cases in the class by calling |runtests| with the name
165 % of the class.
166
167 runtests TestUsingTestCase
168
169 %%
170 % <../index.html Back to MATLAB xUnit Test Framework>
171
172 %%
173 % Copyright 2008-2010 The MathWorks, Inc.
174 ##### SOURCE END #####
175 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTestCaseSearching.html deleted (index 3ba3306..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML was auto-generated from MATLAB code.
8 To make changes, update the MATLAB code and republish this document.
9 --><title>MATLAB xUnit Test Framework: How RUNTESTS Searches for Test Cases</title><meta name="generator" content="MATLAB 7.11"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2010-11-19"><meta name="DC.source" content="exTestCaseSearching.m"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How RUNTESTS Searches for Test Cases</h1><p>When you call <tt>runtests</tt> with no input arguments:</p><pre> &gt;&gt; runtests</pre><p>it automatically searches for all the test cases in the current directory. It looks for test cases in three types of M-files:</p><p>1. An M-file function whose name begins or ends with "test" or "Test" and that does not return an output argument. Such a function is considered to be a single test case.</p><p>2. An M-file function whose name begins or ends with "test" or "Test" and that returns an output argument that is a test suite. Such a function is considered to contain subfunction-style test cases. Each subfunction whose name begins or ends with "test" or "Test" is a test case.</p><p>3. An M-file that defines a subclass of TestCase. Each method beginning or ending with "test" or "Test" is a test case.</p><p><tt>runtests</tt> uses the <tt>TestSuite</tt> static methods <tt>fromName</tt> and <tt>fromPwd</tt> to automatically construct the test suites.</p><p>Here are a couple of examples.</p><p><tt>TestSuite.fromName</tt> takes an M-file name, determines what kind of test file it is, and returns a cell array of test case objects.</p><pre class="codeinput">cd <span class="string">examples_general</span>
66 test_suite_1 = TestSuite.fromName(<span class="string">'testSetupExample'</span>)
67 </pre><pre class="codeoutput">
68 test_suite_1 =
69
70 TestSuite handle
71
72 Properties:
73 TestComponents: {[1x1 FunctionHandleTestCase] [1x1 FunctionHandleTestCase]}
74 Name: 'testSetupExample'
75 Location: [1x79 char]
76
77
78 </pre><p><tt>TestSuite.fromPwd</tt> returns a test suite based on all the test files in the current directory.</p><pre class="codeinput">test_suite_2 = TestSuite.fromPwd()
79 </pre><pre class="codeoutput">
80 test_suite_2 =
81
82 TestSuite handle
83
84 Properties:
85 TestComponents: {1x6 cell}
86 Name: 'C:\Users\eddins\local-work\matlab_xunit\doc\examples_general'
87 Location: 'C:\Users\eddins\local-work\matlab_xunit\doc\examples_general'
88
89
90 </pre><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2008-2010 The MathWorks, Inc.<br>
91 Published with MATLAB&reg; 7.11<br></p></div><!--
92 ##### SOURCE BEGIN #####
93 %% <../index.html MATLAB xUnit Test Framework>: How RUNTESTS Searches for Test Cases
94 % When you call |runtests| with no input arguments:
95 %
96 % >> runtests
97 %
98 % it automatically searches for all the test cases in the current directory. It
99 % looks for test cases in three types of M-files:
100 %
101 % 1. An M-file function whose name begins or ends with "test" or "Test" and that does
102 % not return an output argument. Such a function is considered to be a single
103 % test case.
104 %
105 % 2. An M-file function whose name begins or ends with "test" or "Test" and that returns
106 % an output argument that is a test suite. Such a function is considered to contain
107 % subfunction-style test cases. Each subfunction whose name begins or ends with "test"
108 % or "Test" is a test case.
109 %
110 % 3. An M-file that defines a subclass of TestCase. Each method beginning or ending with
111 % "test" or "Test" is a test case.
112 %
113 % |runtests| uses the |TestSuite| static methods |fromName| and |fromPwd| to
114 % automatically construct the test suites.
115 %
116 % Here are a couple of examples.
117 %
118 % |TestSuite.fromName| takes an M-file name, determines what
119 % kind of test file it is, and returns a cell array of test case objects.
120
121 cd examples_general
122 test_suite_1 = TestSuite.fromName('testSetupExample')
123
124 %%
125 % |TestSuite.fromPwd| returns a test suite based on all the test files in the
126 % current directory.
127
128 test_suite_2 = TestSuite.fromPwd()
129
130 %%
131 % <../index.html Back to MATLAB xUnit Test Framework>
132
133 %%
134 % Copyright 2008-2010 The MathWorks, Inc.
135 ##### SOURCE END #####
136 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTestFixtures.html deleted (index 0ce5854..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML is auto-generated from an M-file.
8 To make changes, update the M-file and republish this document.
9 --><title>MATLAB xUnit Test Framework: How to Write Tests That Share Common Set-Up Code</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-07-29"><meta name="m-file" content="exTestFixtures"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How to Write Tests That Share Common Set-Up Code</h1><p>Sometimes you want to write a set of test cases in which the same set of initialization steps is performed before each test case, or in which the same set of cleanup steps is performed after each test case. This set of common <i>setup</i> and <i>teardown</i> code is called a <i>test fixture</i>.</p><p>In subfunction-based test files, you can add subfunctions whose names begin with "setup" and "teardown". These functions will be called before and after every test-case subfunction is called. If the setup function returns an output argument, that value is saved and passed to every test-case subfunction and also to the teardown function.</p><p>This example shows a setup function that creates a figure and returns its handle. The figure handle is passed to each test-case subfunction. The figure handle is also passed to the teardown function, which cleans up after each test case by deleting the figure.</p><pre class="codeinput">cd <span class="string">examples_general</span>
66 type <span class="string">testSetupExample</span>
67 </pre><pre class="codeoutput">
68 function test_suite = testSetupExample
69 initTestSuite;
70
71 function fh = setup
72 fh = figure;
73
74 function teardown(fh)
75 delete(fh);
76
77 function testColormapColumns(fh)
78 assertEqual(size(get(fh, 'Colormap'), 2), 3);
79
80 function testPointer(fh)
81 assertEqual(get(fh, 'Pointer'), 'arrow');
82
83 </pre><p>Run the tests using <tt>runtests</tt>.</p><pre class="codeinput">runtests <span class="string">testSetupExample</span>
84 </pre><pre class="codeoutput">Starting test run with 2 test cases.
85 ..
86 PASSED in 0.095 seconds.
87 </pre><p>You might also want to see the <a href="./exTestCase.html">example on writing test cases by subclassing TestCase</a>.</p><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2008-2010 The MathWorks, Inc.<br>
88 Published with MATLAB&reg; 7.10<br></p></div><!--
89 ##### SOURCE BEGIN #####
90 %% <../index.html MATLAB xUnit Test Framework>: How to Write Tests That Share Common Set-Up Code
91 % Sometimes you want to write a set of test cases in which the same
92 % set of initialization steps is performed before each test case, or
93 % in which the same set of cleanup steps is performed after each
94 % test case. This set of common _setup_ and _teardown_ code is
95 % called a _test fixture_.
96 %
97 % In subfunction-based test files, you can add subfunctions whose
98 % names begin with "setup" and "teardown". These functions will be
99 % called before and after every test-case subfunction is called. If
100 % the setup function returns an output argument, that value is saved
101 % and passed to every test-case subfunction and also to the teardown
102 % function.
103 %
104 % This example shows a setup function that creates a figure and
105 % returns its handle. The figure handle is passed to each test-case
106 % subfunction. The figure handle is also passed to the teardown
107 % function, which cleans up after each test case by deleting the
108 % figure.
109
110 cd examples_general
111 type testSetupExample
112
113 %%
114 % Run the tests using |runtests|.
115
116 runtests testSetupExample
117
118 %%
119 % You might also want to see the
120 % <./exTestCase.html example on writing test cases by
121 % subclassing TestCase>.
122
123 %%
124 % <../index.html Back to MATLAB xUnit Test Framework>
125
126 %%
127 % Copyright 2008-2010 The MathWorks, Inc.
128 ##### SOURCE END #####
129 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTolerance.html deleted (index f13c7f6..0000000)
1
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html><head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <!--
7 This HTML is auto-generated from an M-file.
8 To make changes, update the M-file and republish this document.
9 --><title>MATLAB xUnit Test Framework: How to Test Using a Floating-Point Tolerance</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-07-29"><meta name="m-file" content="exTolerance"><style type="text/css">
10
11 body {
12 background-color: white;
13 margin:10px;
14 }
15
16 h1 {
17 color: #990000;
18 font-size: x-large;
19 }
20
21 h2 {
22 color: #990000;
23 font-size: medium;
24 }
25
26 /* Make the text shrink to fit narrow windows, but not stretch too far in
27 wide windows. */
28 p,h1,h2,div.content div {
29 max-width: 600px;
30 /* Hack for IE6 */
31 width: auto !important; width: 600px;
32 }
33
34 pre.codeinput {
35 background: #EEEEEE;
36 padding: 10px;
37 }
38 @media print {
39 pre.codeinput {word-wrap:break-word; width:100%;}
40 }
41
42 span.keyword {color: #0000FF}
43 span.comment {color: #228B22}
44 span.string {color: #A020F0}
45 span.untermstring {color: #B20000}
46 span.syscmd {color: #B28C00}
47
48 pre.codeoutput {
49 color: #666666;
50 padding: 10px;
51 }
52
53 pre.error {
54 color: red;
55 }
56
57 p.footer {
58 text-align: right;
59 font-size: xx-small;
60 font-weight: lighter;
61 font-style: italic;
62 color: gray;
63 }
64
65 </style></head><body><div class="content"><h1><a href="../index.html">MATLAB xUnit Test Framework</a>: How to Test Using a Floating-Point Tolerance</h1><p>MATLAB performs arithmetic operations using the floating-point hardware instructions on your processor. Because almost all floating-point operations are subject to round-off error, arithmetic operations can sometimes produce surprising results. Here's an example.</p><pre class="codeinput">a = 1 + 0.1 + 0.1 + 0.1
66 </pre><pre class="codeoutput">
67 a =
68
69 1.3000
70
71 </pre><pre class="codeinput">a == 1.3
72 </pre><pre class="codeoutput">
73 ans =
74
75 0
76
77 </pre><p>So why doesn't <tt>a</tt> equal 1.3? Because 0.1, 1.3, and most other decimal fractions do not have exact representations in the binary floating-point number representation your computer uses. The first line above is doing an approximate addition of 1 plus an approximation of 0.1, plus an approximation of 0.1, plus an approximation of 0.1. The second line compares the result of all that with an approximation of 1.3.</p><p>If you subtract 1.3 from <tt>a</tt>, you can see that the computed result for <tt>a</tt> is <i>extremely close</i> to the floating-point approximation of 1.3, but it is not exactly the same.</p><pre class="codeinput">a - 1.3
78 </pre><pre class="codeoutput">
79 ans =
80
81 2.2204e-016
82
83 </pre><p>As a general rule, when comparing the results of floating-point calculations for equality, it is necessary to use a tolerance value. Two types of tolerance comparisons are commonly used: absolute tolerance and relative tolerance. An absolute tolerance comparison of <i>a</i> and <i>b</i> looks like:</p><p><img src="exTolerance_eq55725.png" alt="$$|a-b| \leq T$$"></p><p>A relative tolerance comparison looks like:</p><p><img src="exTolerance_eq28823.png" alt="$$|a-b| \leq T\max(|a|,|b|) + T_f$$"></p><p>where <i>Tf</i> is called the <i>floor tolerance</i>. It acts as an absolute tolerance when <i>a</i> and <i>b</i> are very close to 0.</p><p>For example, suppose that <i>a</i> is 100, <i>b</i> is 101, and T is 0.1. Then <i>a</i> and <i>b</i> would not be considered equal using an absolute tolerance, because 1 &gt; 0.1. However, <i>a</i> and <i>b</i> would be considered equal using a relative tolerance, because they differ by only 1 part in 100.</p><p>MATLAB xUnit provides the utility assertion functions called <tt>assertElementsAlmostEqual</tt> and <tt>assertVectorAlmostEqual</tt>. These functions make it easy to write tests involving floating-point tolerances.</p><p><tt>assertElementsAlmostEqual(A,B)</tt> applies the tolerance test independently to every element of <tt>A</tt> and <tt>B</tt>. The function uses a relative tolerance test by default, but you make it use an absolute tolerance test, or change the tolerance values used, by passing additional arguments to it.</p><p><tt>assertVectorsAlmostEqual(A,B)</tt> applies the tolerance test to the vectors <tt>A</tt> and <tt>B</tt> in the L2-norm sense. For example, suppose <tt>A</tt> is <tt>[1 1e10</tt>], <tt>B</tt> is <tt>[2 1e10]</tt>, and the tolerance is 1e-8. Then <tt>A</tt> and <tt>B</tt> would fail an elementwise relative tolerance comparison, because the relative difference between the first elements is 0.5. However, they would pass a vector relative tolerance comparison, because the relative vector difference between <tt>A</tt> and <tt>B</tt> is only about 1 part in 1e10.</p><p>The <tt>examples_general</tt> directory contains a portion of a unit test for the <tt>sin</tt> function. The output of <tt>sin</tt> can sometimes be a bit surprising because of floating-point issues. For example:</p><pre class="codeinput">sin(pi)
84 </pre><pre class="codeoutput">
85 ans =
86
87 1.2246e-016
88
89 </pre><p>That's very close but not exactly equal to 0. Here's how the <tt>sin</tt> unit test uses <tt>assertElementsAlmostEqual</tt> to write the <tt>sin(pi)</tt> test with a minimum of fuss.</p><pre class="codeinput">cd <span class="string">examples_general</span>
90 type <span class="string">testSin</span>
91 </pre><pre class="codeoutput">
92 function testSin
93
94 assertElementsAlmostEqual(sin(pi), 0);
95 </pre><p>Run the test using <tt>runtests</tt>.</p><pre class="codeinput">runtests <span class="string">testSin</span>
96 </pre><pre class="codeoutput">Starting test run with 1 test case.
97 .
98 PASSED in 0.023 seconds.
99 </pre><p><a href="../index.html">Back to MATLAB xUnit Test Framework</a></p><p class="footer">Copyright 2008-2010 The MathWorks, Inc.<br>
100 Published with MATLAB&reg; 7.10<br></p></div><!--
101 ##### SOURCE BEGIN #####
102 %% <../index.html MATLAB xUnit Test Framework>: How to Test Using a Floating-Point Tolerance
103 % MATLAB performs arithmetic operations using the floating-point
104 % hardware instructions on your processor. Because
105 % almost all floating-point operations are subject to round-off
106 % error, arithmetic operations can sometimes produce surprising
107 % results. Here's an example.
108
109 a = 1 + 0.1 + 0.1 + 0.1
110
111 %%
112 a == 1.3
113
114 %%
115 % So why doesn't |a| equal 1.3? Because 0.1, 1.3, and most other
116 % decimal fractions do not have exact representations in the binary
117 % floating-point number representation your computer uses. The
118 % first line above is doing an approximate addition of 1 plus an
119 % approximation of 0.1, plus an approximation of 0.1, plus an
120 % approximation of 0.1. The second line compares the result of all
121 % that with an approximation of 1.3.
122 %
123 % If you subtract 1.3 from |a|, you can see that the computed result
124 % for |a| is _extremely close_ to the floating-point approximation
125 % of 1.3, but it is not exactly the same.
126
127 a - 1.3
128
129 %%
130 % As a general rule, when comparing the results of floating-point
131 % calculations for equality, it is necessary to use a tolerance
132 % value. Two types of tolerance comparisons are commonly used: absolute
133 % tolerance and relative tolerance. An absolute tolerance comparison of _a_ and _b_
134 % looks like:
135 %
136 % $$|a-b| \leq T$$
137 %
138 % A relative tolerance comparison looks like:
139 %
140 % $$|a-b| \leq T\max(|a|,|b|) + T_f$$
141 %
142 % where _Tf_ is called the _floor tolerance_. It acts as an absolute tolerance
143 % when _a_ and _b_ are very close to 0.
144 %
145 % For example, suppose that _a_ is 100, _b_ is 101, and T is 0.1. Then _a_ and
146 % _b_ would not be considered equal using an absolute tolerance, because 1 >
147 % 0.1. However, _a_ and _b_ would be considered equal using a relative
148 % tolerance, because they differ by only 1 part in 100.
149 %
150 % MATLAB xUnit provides the utility assertion functions called
151 % |assertElementsAlmostEqual| and |assertVectorAlmostEqual|. These functions
152 % make it easy to write tests involving floating-point tolerances.
153 %
154 % |assertElementsAlmostEqual(A,B)| applies the tolerance test independently to
155 % every element of |A| and |B|. The function uses a relative tolerance test by
156 % default, but you make it use an absolute tolerance test, or change the
157 % tolerance values used, by passing additional arguments to it.
158 %
159 % |assertVectorsAlmostEqual(A,B)| applies the tolerance test to the vectors |A|
160 % and |B| in the L2-norm sense. For example, suppose |A| is |[1 1e10|], |B|
161 % is |[2 1e10]|, and the tolerance is 1e-8. Then |A| and |B| would fail an
162 % elementwise relative tolerance comparison, because the relative difference
163 % between the first elements is 0.5. However, they would pass a vector relative
164 % tolerance comparison, because the relative vector difference between |A| and
165 % |B| is only about 1 part in 1e10.
166 %
167 % The |examples_general| directory contains a portion of a unit test for the
168 % |sin| function. The output of |sin| can sometimes be a bit surprising because
169 % of floating-point issues. For example:
170
171 sin(pi)
172
173 %%
174 % That's very close but not exactly equal to 0. Here's how the
175 % |sin| unit test uses |assertElementsAlmostEqual| to write the |sin(pi)|
176 % test with a minimum of fuss.
177
178 cd examples_general
179 type testSin
180
181 %%
182 % Run the test using |runtests|.
183
184 runtests testSin
185
186 %%
187 % <../index.html Back to MATLAB xUnit Test Framework>
188
189 %%
190 % Copyright 2008-2010 The MathWorks, Inc.
191 ##### SOURCE END #####
192 --></body></html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTolerance_eq28823.png deleted (index 5183501..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/doc/html/exTolerance_eq55725.png deleted (index 7d32834..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/doc/index.html deleted (index 4a09f83..0000000)
1 <html>
2 <!-- Copyright 2013 The MathWorks, Inc. -->
3 <head>
4 <meta http-equiv="REFRESH" content="0;url=xunit_product_page.html">
5 </head>
6 <body>
7 </body>
8 </html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/release-history.html deleted (index d3a06bb..0000000)
1 <html>
2 <!-- Copyright 2013 The MathWorks, Inc. -->
3 <head>
4 <title>MATLAB xUnit Release History</title>
5 </head>
6
7 <body>
8 <h1>MATLAB xUnit Release History</h1>
9
10 <h3>3.1.1 10-Jul-2013</h3>
11 <ul>
12 <li>
13 Add links to the
14 <a href="http://www.mathworks.com/help/matlab/matlab-unit-test-framework.html">
15 documentation</a> for the new unit test framework in
16 MATLAB (as of R2013a, March 2013).
17 </li>
18 <li>
19 Subfunction test files no longer execute the tests automatically when
20 called with no output argument. If your subfunction test file is called
21 <tt>foo_test</tt>, then you can execute the tests by calling
22 <tt>run(foo_test)</tt>.
23 </li>
24 </ul>
25
26 <h3>3.1 19-Nov-2010</h3>
27 <ul>
28 <li>
29 Add -logfile option to runtests.
30 </li>
31 <li>
32 Allow test names to be passed to runtests as a cell array of strings.
33 </li>
34 <li>
35 Add test suite name and execution date to output of runtests.
36 </li>
37 <li>
38 Added warning message if function-handle-based test file has a setup function
39 that returns more than one output argument.
40 </li>
41 <li>
42 Fix bug related to handling subfunction test files in packages.
43 </li>
44 <li>
45 Fix TestSuite.fromPackageName to find tests inside subpackages.
46 </li>
47 <li>
48 Correct text in exTestCaseSearching.m to show that test files and functions
49 can begin or end with "test" or "Test".
50 </li>
51 </ul>
52
53 <h3>3.0.2 30-Jul-2010</h3>
54 <ul>
55 <li>
56 Fixed bug that caused TestCase subclasses in a test package to
57 be executed twice in some versions of MATLAB.
58 </li>
59 <li>
60 Documented the <tt>out = runsuite(...)</tt> syntax.
61 </li>
62 <li>
63 Added home doc links to the various doc pages.
64 </li>
65 </ul>
66
67 <h3>3.0.1 16-Jun-2010</h3>
68 <p>
69 Fixed handling of TestCase subclasses in a test package.
70 </p>
71
72 <h3>3.0 12-Jun-2010</h3>
73 <ul>
74 <li> Added capability to run tests stored inside packages. </li>
75 <li> <tt>runtests</tt> errors if no test cases are found instead
76 of silently passing. </li>
77 <li> Accept function names that end in "test" or "Test" as test functions. </li>
78 <li> In <tt>assertElementsAlmostEqual</tt> and <tt>assertVectorsAlmostEqual</tt>, change the
79 default <tt>floor_tol</tt> value to <tt>sqrt(eps)</tt> instead of <tt>eps</tt>. This makes the assertion
80 a bit more forgiving when comparing numbers very close to 0.</li>
81 <li> Added -verbose option to <tt>runtests</tt>. </li>
82 <li> Fixed handling of message strings containing sprintf-style control characters
83 in the assert*.m functions. </li>
84 </ul>
85
86 <h3>2.0.1 04-Aug-2009</h3>
87 <p>
88 Corrected errors in assertElementsAlmostEqual and assertVectorsAlmostEqual
89 related to NaN and Inf inputs. assertElementsAlmostEqual now properly
90 asserts when one input is finite and the other is infinite.
91 assertVectorsAlmostEqual now asserts whenever any input element is NaN
92 or infinite. The behavior of xunit.utils.compareFloats has been changed
93 to match.
94 </p>
95
96 <h3>2.0 05-June-2009</h3>
97 <ul>
98 <li>
99 The name of the package has been changed to "MATLAB xUnit Test Framework."
100 The command-line test runner is now called <tt>runtests</tt>. The utilities
101 package is now called <tt>xunit.utils</tt>. If you want to continue using
102 the old command-line test runner (<tt>mtest</tt>) and utilities package
103 (<tt>mtest.utils</tt>), then put the <tt>obsolete</tt> directory on the
104 MATLAB path.
105 </li>
106 <li>
107 The assertion functions <tt>assertEqual</tt>, <tt>assertElementsAlmostEqual</tt>,
108 and <tt>assertVectorsAlmostEqual</tt> now print more information about the input
109 values in the case of an assertion failure.
110 </li>
111 <li>
112 A new assertion function, <tt>assertFilesEqual</tt>, has been added.
113 </li>
114 <li>
115 The command-line test runner, <tt>runtests</tt>, now supports multiple directory
116 names.
117 </li>
118 <li>
119 The assertion function <tt>assertAlmostEqual</tt> has been deprecated. Use
120 <tt>assertElementsAlmostEqual</tt> and <tt>assertVectorsAlmostEqual</tt>
121 instead. If you want to continue using <tt>assertAlmostEqual</tt>, then
122 put the <tt>obsolete</tt> directory on the MATLAB path.
123 </li>
124 </ul>
125
126 <h3>1.1.3 20-May-2009</h3>
127 <p>
128 Remove the LICENSE.txt file because the open source BSD license is
129 now supplied automatically by the MATLAB Central File Exchange.
130 There are no functional changes in this version.
131 </p>
132
133 <h3>1.1.2 02-Apr-2009</h3>
134 <p>
135 This release fixes a bug with <tt>assertVectorsAlmostEqual</tt> when
136 the caller provided a custom message. When the function errored out
137 because the tolerance was exceeded, the function would issue a
138 different error message than expected.
139 </p>
140
141 <h3>1.1.1 16-Mar-2009</h3>
142 <p>
143 This release fixes a problem when calling mtest with no input
144 arguments. Previously, it was not limiting its test-case discovery
145 to TestCase subclasses and ordinary M-files beginning with "test"
146 or "Test" as documented.
147 </p>
148
149 <p>
150 This release also integrates the MTEST documentation with the MATLAB
151 Help Browser.
152 </p>
153
154 <h3>1.1 11-Mar-2009</h3>
155 <p>
156 This release adds new tools for performing floating-point
157 comparisons. Using the new assertion functions
158 <tt>assertElementsAlmostEqual</tt> and
159 <tt>assertVectorsAlmostEqual</tt>, you can perform both
160 absolute and relative tolerance comparisons, either elementwise
161 or in a vector L2-norm fashion.
162 </p>
163
164 <p>
165 The previous floating-point comparison function,
166 <tt>assertAlmostEqual</tt>, is still available, but its
167 use is discouraged.
168 </p>
169
170 <h3>1.0 30-Jan-2009</h3>
171 <p>
172 This release, the first to be posted on the MATLAB Central File
173 Exchange, includes a refactoring of TestCase and TestSuite to use
174 the composite design pattern. Both classes now subclass the
175 abstract class TestComponent, and the individual items contained
176 in a TestSuite object are TestComponent objects. That means
177 a TestSuite object can contain both TestSuite objects and
178 TestCase objects.
179 </p>
180
181 <p>
182 TestSuites are now built up hierarchically. All the test cases
183 in a subfunction-based test M-file become a test suite, which in
184 turn can be part of a test suite for an entire test directory.
185 </p>
186
187 <p>
188 The mtest driver function can now take the name of a directory,
189 in which case it will automatically discover and run all the test
190 cases in that directory.
191 </p>
192
193 <p>
194 The old TestRunObserver class has become the abstract TestRunMonitor
195 class, with subclasses TestRunLogger and CommandWindowTestRunDisplay.
196 </p>
197
198 <p>
199 TestCaseInDir has been modified to do a directory change before
200 executing the test case. The new class TestCaseWithAddPath makes
201 a temporary path addition before executing the test case.
202 </p>
203
204 <p>
205 Subfunction-based test M-files written for one of the alpha versions
206 of MTEST need to be revised so that the output variable name is
207 "test_suite", and so that the first line of code calls the script
208 "initTestSuite".
209 </p>
210
211 <h3>0.9 12-Sep-2008</h3>
212 <p>
213 This release is an extensive update that provides simpler ways of
214 writing and running test cases.
215 </p>
216 <ul>
217 <li>
218 The new function mtest automatically finds and runs all test
219 cases in the current directory.
220 </li>
221 <li>
222 Test cases can be written as simple M-file functions.
223 </li>
224 <li>
225 Multiple test cases can be defined in a single M-file by using
226 subfunctions.
227 </li>
228 <li>
229 Many new documentation examples have been provided, including a
230 "Quick Start" example intended to enable users to write and
231 run their first tests in just a few minutes.
232 </li>
233 </ul>
234
235
236 <h3>0.8.1 17-Mar-2008</h3>
237 <ul>
238 <li>
239 Some of the sample TestCase classes were missing classdef lines.
240 FIXED
241 </li>
242 <li>
243 Now using dot method invocation syntax in examples and doc.
244 </li>
245 <li>
246 Minor edits to HTML doc (munit_doc.html).
247 </li>
248 <li>
249 Edited munit_doc.html by hand to clean up command-window links.
250 </li>
251 </ul>
252
253 <h3>0.8 15-Mar-2008</h3>
254 <ul>
255 <li>
256 Limited initial distribution for review and comment.
257 </li>
258 </ul>
259 </body>
260 </html>
File data_analysis/unittests/matlab_xunit_3_1_1/doc/screen-shot.png deleted (index 2cb55e2..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/doc/xunit_product_page.html deleted (index 5b27312..0000000)
1 <html>
2 <!-- Copyright 2013 The MathWorks, Inc. -->
3 <head>
4 <title>MATLAB&reg; xUnit Test Framework</title>
5 </head>
6 <body>
7 <h1>MATLAB<sup>&reg;</sup> xUnit Test Framework</h1>
8
9 <p>
10 <strong>Note:</strong> As of March 2013 and the release of MATLAB R2013a, MATLAB
11 includes a unit test framework, <tt>matlab.unittest</tt>. Users of MATLAB xUnit
12 are encouraged to transition to the new framework at your convenience.
13 There are no plans to continue development of MATLAB xUnit, although it will
14 remain on the MATLAB Central File Exchange for a while. For more information
15 about the new framework, see the
16 <a href="http://www.mathworks.com/videos/matlab-unit-testing-framework-74975.html"
17 overview video</a> or the
18 <a href="http://www.mathworks.com/help/matlab/matlab-unit-test-framework.html">
19 documentation</a>.
20 </p>
21
22 <p>
23 MATLAB xUnit is a unit test framework for MATLAB code.
24 MATLAB xUnit is designed to be easy to use for MATLAB users with a
25 wide range of experience. Users can write tests using
26 ordinary M-files that are very simple in structure.
27 </p>
28
29 <p>
30 MATLAB xUnit
31 relies heavily on object-oriented language features
32 introduced in MATLAB 7.6 (R2008a), which was released in March 2008.
33 MATLAB xUnit functions and classes will not work in earlier MATLAB releases.
34 In addition, writing and running tests inside packages requires MATLAB
35 7.7 (R008b) or later.
36 </p>
37
38
39
40
41 <h2>Installation</h2>
42
43 <p>
44 To use MATLAB xUnit in MATLAB, add the "xunit" folder (directory) to the MATLAB path. See the <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f10-26235.html">
45 MATLAB documentation for setting
46 the search path</a>. (The "tests" directory contains the
47 framework's own self-tests, and the "architecture" directory contains
48 information about the framework architecture; these directories are not
49 needed for using MATLAB xUnit.)
50 </p>
51
52 <p>
53 <strong>Note for users of earlier versions of MATLAB xUnit:</strong> If you have already
54 written unit tests based on MTEST, an earlier version of MATLAB xUnit, you may also want
55 to add the "obsolete" folder to the MATLAB path. This folder contains the old command-line
56 test runner, <tt>mtest</tt>, as well as the deprecated function <tt>assertAlmostEqual</tt>.
57 </p>
58
59 <h2>Getting Started</h2>
60
61 <p>
62 <a href="html/exQuickStart.html">Quick Start: How to Write and
63 Run Tests</a>
64 </p>
65
66 <p>
67 <a href="html/exSubfunctionTests.html">How to Put Multiple Test
68 Cases in One M-file</a>
69 </p>
70
71 <p>
72 <a href="html/exRunSpecificTest.html">How to Run a Specific Test</a>
73 </p>
74
75 <p>
76 <a href="html/exRunTestsInADirectory.html">How to Run Tests in Specific Directories</a>
77 </p>
78
79 <p>
80 <a href="html/exRunTestsInPackage.html">How to Run Tests in a Package</a>
81 </p>
82
83 <h2>Advanced Usage</h2>
84
85 <p>
86 <a href="html/exTolerance.html">How to Test Using a Floating-Point Tolerance</a>
87 </p>
88
89 <p>
90 <a href="html/exException.html">How to Test an Error Message</a>
91 </p>
92
93 <p>
94 <a href="html/exSilentRunning.html">How to Run Tests Silently and Query the Results</a>
95 </p>
96
97 <p>
98 <a href="html/exTestFixtures.html">How to Write Tests That Share Common
99 Set-Up Code</a>
100 </p>
101
102 <p>
103 <a href="html/exTestCase.html">How to Write xUnit-Style Tests by
104 Subclassing TestCase</a>
105 </p>
106
107 <p>
108 <a href="html/exTestCaseSearching.html">How MATLAB xUnit Searches for Test
109 Cases</a>
110 </p>
111
112 <h2>Key Functions and Classes</h2>
113
114 <p>
115 Main test driver function:
116 <ul>
117 <li>
118 <a href="matlab:doc runtests"><code>runtests</code></a>
119 </li>
120 </ul>
121 </p>
122
123 <p>
124 Assertion functions you can use in your tests:
125 <ul>
126 <li>
127 <a href="matlab:doc assertTrue"><code>assertTrue</code></a>
128 </li>
129 <li>
130 <a href="matlab:doc assertFalse"><code>assertFalse</code></a>
131 </li>
132 <li>
133 <a href="matlab:doc assertEqual"><code>assertEqual</code></a>
134 </li>
135 <li>
136 <a href="matlab:doc assertFilesEqual"><code>assertFilesEqual</code></a>
137 </li>
138 <li>
139 <a href="matlab:doc assertElementsAlmostEqual"><code>assertElementsAlmostEqual</code></a>
140 </li>
141 <li>
142 <a href="matlab:doc assertVectorsAlmostEqual"><code>assertVectorsAlmostEqual</code></a>
143 </li>
144 <li>
145 <a href="matlab:doc assertExceptionThrown"><code>assertExceptionThrown</code></a>
146 </li>
147 </ul>
148 </p>
149
150 <p>
151 The key xUnit-style classes that make everything work:
152 <ul>
153 <li>
154 <a href="matlab:doc TestComponent"><code>TestComponent</code></a>
155 </li>
156 <li>
157 <a href="matlab:doc TestSuite"><code>TestSuite</code></a>
158 </li>
159 <li>
160 <a href="matlab:doc TestCase"><code>TestCase</code></a>
161 </li>
162 <li>
163 <a href="matlab:doc FunctionHandleTestCase"><code>FunctionHandleTestCase</code></a>
164 </li>
165 <li>
166 <a href="matlab:doc TestRunMonitor"><code>TestRunMonitor</code></a>
167 </li>
168 <li>
169 <a href="matlab:doc TestRunLogger"><code>TestRunLogger</code></a>
170 </li>
171 <li>
172 <a href="matlab:doc CommandWindowTestRunDisplay"><code>CommandWindowTestRunDisplay</code></a>
173 </li>
174 </ul>
175 </p>
176
177 <p>
178 <a href="release-history.html">Release History</a>
179 </p>
180
181 <p>
182 <em>Copyright 2008-2010 The MathWorks, Inc.</em>
183 </p>
184
185 </body>
186 </html>
File data_analysis/unittests/matlab_xunit_3_1_1/license.txt deleted (index 033a0c5..0000000)
1 Copyright (c) 2013, The MathWorks, Inc.
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are
6 met:
7
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in
12 the documentation and/or other materials provided with the distribution
13 * Neither the name of the The MathWorks, Inc. nor the names
14 of its contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/Contents.m deleted (index 38f1301..0000000)
1 % UTILS Utility package for MTEST unit testing framework
2 %
3 % Array Comparison
4 % compareFloats - Compare floating-point arrays using tolerance
5 %
6 % Test Case Discovery Functions
7 % isTestCaseSubclass - True for name of TestCase subclass
8 %
9 % String Functions
10 % containsRegexp - True if string contains regular expression
11 % isSetUpString - True for string that looks like a setup function
12 % isTearDownString - True for string that looks like teardown function
13 % isTestString - True for string that looks like a test function
14 %
15 % Miscellaneous Functions
16 % generateDoc - Publish test scripts in mtest/doc
17 % parseFloatAssertInputs - Common input-parsing logic for several functions
18
19 % Undocumented Functions
20 % isAlmostEqual - Floating-point equality test using relative tolerance
21
22 % Steven L. Eddins
23 % Copyright 2008-2009 The MathWorks, Inc.
24
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/compareFloats.m deleted (index d5a313f..0000000)
1 function result = compareFloats(varargin)
2 %compareFloats Compare floating-point arrays using tolerance.
3 % result = compareFloats(A, B, compare_type, tol_type, tol, floor_tol)
4 % compares the floating-point arrays A and B using a tolerance. compare_type
5 % is either 'elementwise' or 'vector'. tol_type is either 'relative' or
6 % 'absolute'. tol and floor_tol are the scalar tolerance values.
7 %
8 % There are four different tolerance tests used, depending on the comparison
9 % type and the tolerance type:
10 %
11 % 1. Comparison type: 'elementwise' Tolerance type: 'relative'
12 %
13 % all( abs(A(:) - B(:)) <= tol * max(abs(A(:)), abs(B(:))) + floor_tol )
14 %
15 % 2. Comparison type: 'elementwise' Tolerance type: 'absolute'
16 %
17 % all( abs(A(:) - B(:) <= tol )
18 %
19 % 3. Comparison type: 'vector' Tolerance type: 'relative'
20 %
21 % norm(A(:) - B(:) <= tol * max(norm(A(:)), norm(B(:))) + floor_tol
22 %
23 % 4. Comparison type: 'vector' Tolerance type: 'absolute'
24 %
25 % norm(A(:) - B(:)) <= tol
26 %
27 % Note that floor_tol is not used when the tolerance type is 'absolute'.
28 %
29 % compare_type, tol_type, tol, and floor_tol are all optional inputs. The
30 % default value for compare_type is 'elementwise'. The default value for
31 % tol_type is 'relative'. If both A and B are double, then the default value
32 % for tol is sqrt(eps), and the default value for floor_tol is eps. If either
33 % A or B is single, then the default value for tol is sqrt(eps('single')), and
34 % the default value for floor_tol is eps('single').
35 %
36 % If A or B is complex, then the tolerance test is applied independently to
37 % the real and imaginary parts.
38
39 % Steven L. Eddins
40 % Copyright 2008-2009 The MathWorks, Inc.
41
42 if nargin >= 3
43 % compare_type specified. Grab it and then use parseFloatAssertInputs to
44 % process the remaining input arguments.
45 compare_type = varargin{3};
46 varargin(3) = [];
47 if isempty(strcmp(compare_type, {'elementwise', 'vector'}))
48 error('MTEST:compareFloats:unrecognizedCompareType', ...
49 'COMPARE_TYPE must be ''elementwise'' or ''vector''.');
50 end
51 else
52 compare_type = 'elementwise';
53 end
54
55 params = mtest.utils.parseFloatAssertInputs(varargin{:});
56
57 A = params.A(:);
58 B = params.B(:);
59
60 [A, B] = preprocessNanInf(A, B);
61
62 switch compare_type
63 case 'elementwise'
64 magFcn = @abs;
65
66 case 'vector'
67 magFcn = @norm;
68
69 otherwise
70 error('MTEST:compareFloats:unrecognizedCompareType', ...
71 'COMPARE_TYPE must be ''elementwise'' or ''vector''.');
72 end
73
74 switch params.ToleranceType
75 case 'relative'
76 compareFcn = @(A, B) magFcn(A - B) <= ...
77 params.Tolerance * max(magFcn(A), magFcn(B)) + ...
78 params.FloorTolerance;
79
80 case 'absolute'
81 compareFcn = @(A, B) magFcn(A - B) <= params.Tolerance;
82
83 otherwise
84 error('MTEST:compareFloats:unrecognizedToleranceType', ...
85 'TOL_TYPE must be ''relative'' or ''absolute''.');
86 end
87
88 if isreal(A) && isreal(B)
89 result = compareFcn(A, B);
90 else
91 result = compareFcn(real(A), real(B)) & compareFcn(imag(A), imag(B));
92 end
93
94 result = all(result);
95
96 %===============================================================================
97 function [A, B] = preprocessNanInf(A, B)
98
99 make_zero = isnan(A) & isnan(B);
100 make_zero = make_zero | ((A == Inf) & (B == Inf));
101 make_zero = make_zero | ((A == -Inf) & (B == -Inf));
102
103 A(make_zero) = 0;
104 B(make_zero) = 0;
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/containsRegexp.m deleted (index efbc51b..0000000)
1 function tf = containsRegexp(str, exp)
2 %containsRegexp True if string contains regular expression
3 % TF = containsRegexp(str, exp) returns true if the string str contains the
4 % regular expression exp. If str is a cell array of strings, then
5 % containsRegexp tests each string in the cell array, returning the results in
6 % a logical array with the same size as str.
7
8 % Steven L. Eddins
9 % Copyright 2008-2009 The MathWorks, Inc.
10
11 % Convert to canonical input form: A cell array of strings.
12 if ~iscell(str)
13 str = {str};
14 end
15
16 matches = regexp(str, exp);
17 tf = ~cellfun('isempty', matches);
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/generateDoc.m deleted (index 8cf01f7..0000000)
1 function generateDoc
2 %generateDoc Publish the example scripts in the doc directory
3
4 % Steven L. Eddins
5 % Copyright 2008-2009 The MathWorks, Inc.
6
7 doc_dir = fullfile(fileparts(which('mtest')), '..', 'doc');
8 addpath(doc_dir);
9 cd(doc_dir)
10 mfiles = dir('*.m');
11 for k = 1:numel(mfiles)
12 publish(mfiles(k).name);
13 cd(doc_dir)
14 end
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/isAlmostEqual.m deleted (index 7ad4393..0000000)
1 function same = isAlmostEqual(A, B, reltol)
2 %isAlmostEqual Equality test using relative tolerance
3 % same = isAlmostEqual(A, B, reltol), for two floating-point arrays A and B,
4 % tests A and B for equality using the specified relative tolerance.
5 % isAlmostEqual returns true if the following relationship is satisfied for
6 % all values in A and B:
7 %
8 % abs(A - B) ./ max(abs(A), abs(B)) <= reltol
9 %
10 % same = isAlmostEqual(A, B) uses the following value for the relative
11 % tolerance:
12 %
13 % 100 * max(eps(class(A)), eps(class(B)))
14 %
15 % If either A or B is not a floating-point array, then isAlmostEqual returns
16 % the result of isequal(A, B).
17
18 % Steven L. Eddins
19 % Copyright 2008-2009 The MathWorks, Inc.
20
21 if ~isfloat(A) || ~isfloat(B)
22 same = isequal(A, B);
23 return
24 end
25
26 if nargin < 3
27 reltol = 100 * max(eps(class(A)), eps(class(B)));
28 end
29
30 if ~isequal(size(A), size(B))
31 same = false;
32 return
33 end
34
35 A = A(:);
36 B = B(:);
37
38 delta = abs(A - B) ./ max(max(abs(A), abs(B)), 1);
39
40 % Some floating-point values require special handling.
41 delta((A == 0) & (B == 0)) = 0;
42 delta(isnan(A) & isnan(B)) = 0;
43 delta((A == Inf) & (B == Inf)) = 0;
44 delta((A == -Inf) & (B == -Inf)) = 0;
45
46 same = all(delta <= reltol);
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/isSetUpString.m deleted (index de7abf3..0000000)
1 function tf = isSetUpString(str)
2 %isSetUpString True if string looks like the name of a setup function
3 % tf = isSetUpString(str) returns true if the string str looks like the name
4 % of a setup function. If str is a cell array of strings, then isSetUpString
5 % tests each string in the cell array, returning the results in a logical
6 % array with the same size as str.
7
8 % Steven L. Eddins
9 % Copyright 2008-2009 The MathWorks, Inc.
10
11 setup_exp = '^[sS]et[uU]p';
12 tf = mtest.utils.containsRegexp(str, setup_exp);
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/isTearDownString.m deleted (index 3aa0939..0000000)
1 function tf = isTearDownString(str)
2 %isTearDownString True if string looks like the name of a teardown function
3 % tf = isTearDownString(str) returns true if the string str looks like the
4 % name of a teardown function. If str is a cell array of strings, then
5 % isTearDownString tests each string in the cell array, returning the results
6 % in a logical array with the same size as str.
7
8 % Steven L. Eddins
9 % Copyright 2008-2009 The MathWorks, Inc.
10
11 setup_exp = '^[tT]ear[dD]own';
12 tf = mtest.utils.containsRegexp(str, setup_exp);
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/isTestCaseSubclass.m deleted (index 4df0c7f..0000000)
1 function tf = isTestCaseSubclass(name)
2 %isTestCaseSubclass True for name of a TestCase subclass
3 % tf = isTestCaseSubclass(name) returns true if the string name is the name of
4 % a TestCase subclass on the MATLAB path.
5
6 % Steven L. Eddins
7 % Copyright 2008-2009 The MathWorks, Inc.
8
9 tf = false;
10
11 class_meta = meta.class.fromName(name);
12 if isempty(class_meta)
13 % Not the name of a class
14 return;
15 end
16
17 if strcmp(class_meta.Name, 'TestCase')
18 tf = true;
19 else
20 tf = isMetaTestCaseSubclass(class_meta);
21 end
22
23 function tf = isMetaTestCaseSubclass(class_meta)
24
25 tf = false;
26
27 if strcmp(class_meta.Name, 'TestCase')
28 tf = true;
29 else
30 % Invoke function recursively on parent classes.
31 super_classes = class_meta.SuperClasses;
32 for k = 1:numel(super_classes)
33 if isMetaTestCaseSubclass(super_classes{k})
34 tf = true;
35 break;
36 end
37 end
38 end
39
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/isTestString.m deleted (index b71952a..0000000)
1 function tf = isTestString(str)
2 %isTestString True if string looks like the name of a test
3 % tf = isTestString(str) returns true if the string str looks like the name of
4 % a test. If str is a cell array of strings, then isTestString tests each
5 % string in the cell array, returning the results in a logical array with the
6 % same size as str.
7
8 % Steven L. Eddins
9 % Copyright 2008-2009 The MathWorks, Inc.
10
11 test_exp = '^[tT]est';
12 tf = mtest.utils.containsRegexp(str, test_exp);
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/+mtest/+utils/parseFloatAssertInputs.m deleted (index 59a741b..0000000)
1 function params = parseFloatAssertInputs(varargin)
2 %parseFloatAssertInputs Parse inputs for floating-point assertion functions.
3 % params = parseFloatAssertInputs(varargin) parses the input arguments for
4 % assertElementsAlmostEqual, assertVectorsAlmostEqual, and compareFcn. It
5 % returns a parameter struct containing the fields:
6 %
7 % A B ToleranceType Tolerance FloorTolerance
8
9 % Steven L. Eddins
10 % Copyright 2008-2009 The MathWorks, Inc.
11
12 error(nargchk(2, 6, nargin, 'struct'));
13
14 params = struct('A', {[]}, 'B', {[]}, 'ToleranceType', {[]}, ...
15 'Tolerance', {[]}, 'FloorTolerance', {[]}, 'Message', {''});
16
17 % The first two input arguments are always A and B.
18 params.A = varargin{1};
19 params.B = varargin{2};
20 varargin(1:2) = [];
21
22 % If the last argument is a message string, process it and remove it from the list.
23 if (numel(varargin) >= 1) && ischar(varargin{end}) && ...
24 ~any(strcmp(varargin{end}, {'relative', 'absolute'}))
25 params.Message = varargin{end};
26 varargin(end) = [];
27 end
28
29 checkAB(params.A, params.B);
30
31 epsilon = max(eps(class(params.A)), eps(class(params.B)));
32
33 if numel(varargin) < 3
34 % floor_tol not specified; set default.
35 params.FloorTolerance = epsilon;
36 else
37 params.FloorTolerance = varargin{3};
38 end
39
40 if numel(varargin) < 2
41 % tol not specified; set default.
42 params.Tolerance = sqrt(epsilon);
43 else
44 params.Tolerance = varargin{2};
45 end
46
47 if numel(varargin) < 1
48 % tol_type not specified; set default.
49 params.ToleranceType = 'relative';
50 else
51 params.ToleranceType = varargin{1};
52 end
53
54 %===============================================================================
55 function checkAB(A, B)
56 if ~isfloat(A) || ~isfloat(B)
57 error('MTEST:parseFloatAssertInputs:inputsNotFloat', ...
58 'A and B must be floating-point arrays.');
59 end
60
61 if ~isequal(size(A), size(B))
62 error('MTEST:parseFloatAssertInputs:sizeMismatch', ...
63 'A and B must have the same size.');
64 end
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/assertAlmostEqual.m deleted (index bf09037..0000000)
1 function assertAlmostEqual(A, B, reltol, message)
2 %assertEqual Assert that inputs are equal within relative tolerance
3 % assertEqual(A, B, RELTOL) throws an exception of any of the values in A and
4 % B are not equal within the specified tolerance. NaN values are considered
5 % to be equal. A and B have to have the same class and sparsity to be
6 % considered equal.
7 %
8 % assertEqual(A, B) uses the following relative tolerance value:
9 %
10 % 100 * eps(class(A))
11 %
12 % assertEqual(A, B, RELTOL, MESSAGE) uses the specified message string when
13 % throwing the exception. With this syntax, use RELTOL = [] to specify the
14 % default relative tolerance.
15 %
16 % Note that if either A or B are not floating-point arrays, then A and B are
17 % compared using ISEQUALWITHEQUALNANS and the relative tolerance value is not
18 % used.
19 %
20 % Examples
21 % --------
22 % % This call returns silently.
23 % assertAlmostEqual(1.0, 1.0 + eps);
24 %
25 % % This call throws an error.
26 % assertAlmostEqual(1.0, 1.1);
27 %
28 % See also assertEqual, mtest.utils.isAlmostEqual
29
30 % Steven L. Eddins
31 % Copyright 2008-2009 The MathWorks, Inc.
32
33 if ~(issparse(A) == issparse(B))
34 throw(MException('assertAlmostEqual:sparsityNotEqual', message));
35 end
36
37 if ~strcmp(class(A), class(B))
38 throw(MException('assertAlmostEqual:classNotEqual', message));
39 end
40
41 if nargin < 3 || isempty(reltol)
42 reltol = 100 * eps(class(A));
43 end
44
45 if nargin < 4
46 message = sprintf('Inputs are not equal within relative tolerance: %g', ...
47 reltol);
48 end
49
50 if ~mtest.utils.isAlmostEqual(A, B, reltol)
51 throw(MException('assertAlmostEqual:tolExceeded', message));
52 end
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/mtest.m deleted (index b3e91d5..0000000)
1 function out = mtest(name)
2 %mtest Run unit tests
3 % mtest runs all the test cases that can be found in the current directory and
4 % summarizes the results in the Command Window.
5 %
6 % Test cases can be found in the following places in the current directory:
7 %
8 % * An M-file function whose name starts with "test" or "Test" that
9 % returns no output arguments.
10 %
11 % * An M-file function whose name starts with "test" or "Test" that
12 % contains subfunction tests and uses the initTestSuite script to
13 % return a TestSuite object.
14 %
15 % * An M-file defining a subclass of TestCase.
16 %
17 % mtest(mfilename) runs test cases found in the specified function or class
18 % name. The function or class needs to be in the current directory or on the
19 % MATLAB path.
20 %
21 % mtest('mfilename:testname') runs the specific test case named 'testname'
22 % found in the function or class 'name'.
23 %
24 % mtest(dirname) runs all the test cases that can be found in the specified
25 % directory.
26 %
27 % Examples
28 % --------
29 % Find and run all the test cases in the current directory.
30 %
31 % mtest
32 %
33 % Find and run all the test cases contained in the M-file myfunc.
34 %
35 % mtest myfunc
36 %
37 % Find and run all the test cases contained in the TestCase subclass
38 % MyTestCase.
39 %
40 % mtest MyTestCase
41 %
42 % Run the test case named 'testFeature' contained in the M-file myfunc.
43 %
44 % mtest myfunc:testFeature
45 %
46 % Run all the tests in a specific directory.
47 %
48 % mtest c:\Work\MyProject\tests
49
50 % Steven L. Eddins
51 % Copyright 2008-2009 The MathWorks, Inc.
52
53 if nargin < 1
54 suite = TestSuite.fromPwd();
55 else
56 suite = TestSuite.fromName(name);
57
58 user_gave_a_directory_name = isempty(suite.TestComponents) && ...
59 (exist(name, 'file') == 7);
60 if user_gave_a_directory_name
61 % Before changing directories, arrange to restore the current directory
62 % safely.
63 currentDir = pwd;
64 c = onCleanup(@() cd(currentDir));
65
66 cd(name);
67 suite = TestSuite.fromPwd();
68 end
69 end
70
71 did_pass = suite.run(CommandWindowTestRunDisplay());
72
73 if nargout > 0
74 out = did_pass;
75 end
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/MtestTest.m deleted (index 96087b4..0000000)
1 %TestSuiteTest Unit tests for mtest command-line test runner.
2
3 o% Copyright 2013 The MathWorks, Inc.
4
5 classdef MtestTest < TestCaseInDir
6
7 methods
8
9 function self = MtestTest(name)
10 self = self@TestCaseInDir(name, ...
11 fullfile(fileparts(which(mfilename)), 'cwd_test'));
12 end
13
14 function test_noInputArgs(self)
15 [T, did_pass] = evalc('mtest');
16 % The cwd_test directory contains some test cases that fail,
17 % so output of mtest should be false.
18 assertFalse(did_pass);
19 end
20
21 function test_oneInputArg(self)
22 [T, did_pass] = evalc('mtest(''testFoobar'')');
23 % cwd_test/testFoobar.m is supposed to pass.
24 assertTrue(did_pass);
25 end
26
27 function test_oneInputArgWithFilter_passing(self)
28 [T, did_pass] = evalc('mtest(''TestCaseSubclass:testA'')');
29 assertTrue(did_pass);
30 end
31
32 function test_oneInputArgWithFilter_failing(self)
33 [T, did_pass] = evalc('mtest(''TestCaseSubclass:testB'')');
34 assertFalse(did_pass);
35 end
36
37 end
38
39 end
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/cwd_test/TestCaseSubclass.m deleted (index 91db71c..0000000)
1 %TestCaseSubclass TestCase subclass containing two passing tests
2
3 % Steven L. Eddins
4 % Copyright 2008 The MathWorks, Inc.
5
6 classdef TestCaseSubclass < TestCase
7 methods
8 function self = TestCaseSubclass(name)
9 self = self@TestCase(name);
10 end
11
12 function testA(self)
13 end
14
15 function testB(self)
16 % Intentionally fail this test case.
17 assertFalse(true);
18 end
19 end
20 end
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/cwd_test/testFoobar.m deleted (index c0ee40e..0000000)
1 function testFoobar
2 %testFoobar Passing M-file test
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/cwd_test/testSubfunctions.m deleted (index 52e89d6..0000000)
1 function test_cases = testSubfunctions
2 %testSubfunctions Contains two passing subfunction tests
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 findSubfunctionTests;
8
9 function testSub1
10
11 function testSub2
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/testAssertAlmostEqual.m deleted (index b737b89..0000000)
1 function test_suite = testAssertAlmostEqual
2 %testAssertAlmostEqual Unit tests for assertAlmostEqual
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testEqual
10 assertAlmostEqual(1, 1);
11
12 function testEqualWithThreeInputs
13 assertAlmostEqual(1, 1.1, 0.2);
14
15 function testEqualWithFourInputs
16 assertExceptionThrown(@() assertAlmostEqual(1, 2, 0.1, 'checkmate'), ...
17 'assertAlmostEqual:tolExceeded');
18
19 function testEmptyRelTol
20 assertAlmostEqual(1, 1+10*eps, [], 'checkmate');
21
22 function testNotEqual
23 assertExceptionThrown(@() assertAlmostEqual(1, 1+1000*eps), ...
24 'assertAlmostEqual:tolExceeded');
25
26 function testSingleEqual
27 assertAlmostEqual(single(1), single(1 + 10*eps('single')));
28
29 function testSingleNotEqual
30 assertExceptionThrown(@() assertAlmostEqual(single(1), ...
31 single(1 + 1000*eps('single'))), 'assertAlmostEqual:tolExceeded');
32
33 function testZeros
34 assertAlmostEqual(0, 0);
35
36 function testSingleZeros
37 assertAlmostEqual(single(0), single(0));
38
39 function testSparse
40 assertAlmostEqual(sparse(1), sparse(1 + 10*eps));
File data_analysis/unittests/matlab_xunit_3_1_1/obsolete/tests/testIsAlmostEqual.m deleted (index 752e080..0000000)
1 function test_suite = testIsAlmostEqual
2 %testIsAlmostEqual Unit tests for isAlmostEqual
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testExactlyEqual
10 A = [1 2; 3 4];
11 B = [1 2; 3 4];
12 assertTrue(mtest.utils.isAlmostEqual(A, B));
13
14 function testDefaultTolerance
15 assertTrue(mtest.utils.isAlmostEqual(1, 1+10*eps));
16 assertFalse(mtest.utils.isAlmostEqual(1, 1+1000*eps));
17
18 function testDefaultToleranceSingle
19 assertTrue(mtest.utils.isAlmostEqual(single(1), 1 + 10*eps('single')));
20 assertFalse(mtest.utils.isAlmostEqual(single(1), 1 + 1000*eps('single')));
21
22 function testSpecifiedTolerance
23 assertTrue(mtest.utils.isAlmostEqual(1, 1.09, 0.1));
24 assertFalse(mtest.utils.isAlmostEqual(1, 1.2, 0.1));
25
26 function testSpecialValues
27 A = [Inf, -Inf, NaN, 2.0];
28 B = [Inf, -Inf, NaN, 2.0+10*eps];
29 assertTrue(mtest.utils.isAlmostEqual(A, B));
30
31 C = [Inf, -Inf, NaN, 2.0];
32 D = [Inf, -Inf, 0, 2.0+10*eps];
33 assertFalse(mtest.utils.isAlmostEqual(C, D));
34
35 function testUint8
36 assertTrue(mtest.utils.isAlmostEqual(uint8(1), uint8(1)));
37 assertFalse(mtest.utils.isAlmostEqual(uint8(1), uint8(2)));
38
39 function testChar
40 assertTrue(mtest.utils.isAlmostEqual('foobar', 'foobar'));
41 assertFalse(mtest.utils.isAlmostEqual('foo', 'bar'));
File data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/+subpkg/test_a_bit.m deleted (index 50d60d1..0000000)
1 function test_suite = test_a_bit
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 initTestSuite
6
7 function test_now
8
9 function test_later
File data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/A.m deleted (index 6842d7a..0000000)
1 % Class A is a TestCase subclass containing two test cases (test_a and test_b).
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 classdef A < TestCase
6
7 methods
8 function self = A(name)
9 self = self@TestCase(name);
10 end
11
12 function test_a(self)
13 end
14
15 function test_b(self)
16 end
17 end
18
19 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/B.m deleted (index 68478e6..0000000)
1 % Class B is not a TestCase subclass.
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 classdef B
6 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/FooTest.m deleted (index 4b0f887..0000000)
1 % Copyright 2013 The MathWorks, Inc.
2
3 classdef FooTest < TestCase
4 methods
5 function object = FooTest(name)
6 object = object@TestCase(name);
7 end
8 function test_sanity(object)
9 assertEqual(0, 0)
10 end
11 end
12 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/helper_that.m deleted (index 03281ad..0000000)
1 % helper_that is not a test file.
2
3 function y = helper_that(x)
4 y = x;
5
6 % Copyright 2013 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/test_that.m deleted (index fe8bbb6..0000000)
1 % test_that.m is a subfunction test file.
2 %
3 % Copyright 2013 The MathWorks, Inc.
4
5 function test_suite = test_this
6 initTestSuite
7
8 function test_the_other
9 a = magic(3);
10
11 function test_nifty
12 b = magic(5);
File data_analysis/unittests/matlab_xunit_3_1_1/tests/+xunit/+mocktests/test_this.m deleted (index e4ba9d9..0000000)
1 % test_this.m is a function-file test case.
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 function test_this
File data_analysis/unittests/matlab_xunit_3_1_1/tests/Readme.m deleted (index d203751..0000000)
1 % This directory contains the test suite for the mUnit test framework. Before
2 % running the test suite, do the following:
3 %
4 % 1. Make sure the mUnit test framework directory is on your path
5 % 2. Make sure the helper_classes subdirectory of the test directory is on
6 % your path.
7 % 3. Make the test directory your current directory.
8 %
9 % To run the test suite:
10 %
11 % run(TestSuite())
12
13 % Steven L. Eddins
14 % Copyright 2008 The MathWorks
15
16 help Readme
File data_analysis/unittests/matlab_xunit_3_1_1/tests/RuntestsTest.m deleted (index d9729d0..0000000)
1 %TestSuiteTest Unit tests for runtests command-line test runner.
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 classdef RuntestsTest < TestCaseInDir
6
7 methods
8
9 function self = RuntestsTest(name)
10 self = self@TestCaseInDir(name, ...
11 fullfile(fileparts(which(mfilename)), 'cwd_test'));
12 end
13
14 function test_noInputArgs(self)
15 [T, did_pass] = evalc('runtests');
16 % The cwd_test directory contains some test cases that fail,
17 % so output of runtests should be false.
18 assertFalse(did_pass);
19 end
20
21 function test_Verbose(self)
22 [T, did_pass] = evalc('runtests(''-verbose'')');
23 assertFalse(did_pass);
24 end
25
26 function test_oneInputArg(self)
27 [T, did_pass] = evalc('runtests(''testFoobar'')');
28 % cwd_test/testFoobar.m is supposed to pass.
29 assertTrue(did_pass);
30 end
31
32 function test_verboseThenTestName(self)
33 [T, did_pass] = evalc('runtests(''-verbose'', ''.'')');
34 assertFalse(did_pass);
35 end
36
37 function test_testNameThenVerbose(self)
38 [T, did_pass] = evalc('runtests(''.'', ''-verbose'')');
39 assertFalse(did_pass);
40 end
41
42 function test_oneInputArgWithFilter_passing(self)
43 [T, did_pass] = evalc('runtests(''TestCaseSubclass:testA'')');
44 assertTrue(did_pass);
45 end
46
47 function test_oneInputArgWithFilter_failing(self)
48 [T, did_pass] = evalc('runtests(''TestCaseSubclass:testB'')');
49 assertFalse(did_pass);
50 end
51
52 function test_oneDirname(self)
53 [T, did_pass] = evalc('runtests(''../dir1'')');
54 assertTrue(did_pass);
55
56 [T, did_pass] = evalc('runtests(''../dir2'')');
57 assertFalse(did_pass);
58 end
59
60 function test_twoDirnames(self)
61 [T, did_pass] = evalc('runtests(''../dir1'', ''../dir2'')');
62 assertFalse(did_pass);
63 end
64
65 function test_packageName(self)
66 [T, did_pass] = evalc('runtests(''xunit.mocktests'')');
67 assertTrue(did_pass);
68 end
69
70 function test_noTestCasesFound(self)
71 assertExceptionThrown(@() runtests('no_such_test'), ...
72 'xunit:runtests:noTestCasesFound');
73 end
74
75 function test_optionStringsIgnored(self)
76 % Option string at beginning.
77 [T, did_pass] = evalc('runtests(''-bogus'', ''../dir1'')');
78 assertTrue(did_pass);
79
80 % Option string at end.
81 [T, did_pass] = evalc('runtests(''../dir2'', ''-bogus'')');
82 assertFalse(did_pass);
83 end
84
85 function test_logfile(self)
86 name = tempname;
87 command = sprintf('runtests(''../dir1'', ''-logfile'', ''%s'')', name);
88 [T, did_pass] = evalc(command);
89 assertTrue(did_pass);
90 assertTrue(exist(name, 'file') ~= 0);
91 delete(name);
92 end
93
94 function test_logfileWithNoFile(self)
95 assertExceptionThrown(@() runtests('../dir1', '-logfile'), ...
96 'xunit:runtests:MissingLogfile');
97 end
98
99 function test_logfileWithNoWritePermission(self)
100 assertExceptionThrown(@() runtests('../dir1', '-logfile', ...
101 'C:\dir__does__not__exist\foobar.txt'), ...
102 'xunit:runtests:FileOpenFailed');
103 end
104
105 function test_namesInCellArray(self)
106 [T, did_pass] = evalc('runtests({''TestCaseSubclass:testA''})');
107 assertTrue(did_pass);
108
109 [T, did_pass] = evalc('runtests({''TestCaseSubclass:testA'', ''TestCaseSubclass:testB''})');
110 assertFalse(did_pass);
111 end
112
113 end
114
115 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/TestCaseTest.m deleted (index 7c6c486..0000000)
1 %TestCaseTest Unit tests for the TestCase class
2
3 % Steven L. Eddins
4 % Copyright The MathWorks 2008
5
6 classdef TestCaseTest < TestCaseInDir
7
8 methods
9 function self = TestCaseTest(name)
10 self = self@TestCaseInDir(name, ...
11 fullfile(fileparts(which(mfilename)), 'helper_classes'));
12 end
13
14 function testConstructor(self)
15 % Exercise the constructor. Verify that the Name and Location
16 % properties are set correctly.
17 tc = TwoPassingTests('testMethod1');
18 assertEqual(tc.Name, 'testMethod1');
19 assertEqual(tc.Location, which('TwoPassingTests'));
20 end
21
22 function testPassingTests(self)
23 % Verify that the expected observer notifications are received in
24 % the proper order.
25 logger = TestRunLogger();
26 TestSuite('TwoPassingTests').run(logger);
27 assertTrue(isequal(logger.Log, ...
28 {'TestRunStarted', 'TestComponentStarted', ...
29 'TestComponentStarted', 'TestComponentFinished', ...
30 'TestComponentStarted', 'TestComponentFinished', ...
31 'TestComponentFinished', 'TestRunFinished'}));
32 end
33
34 function testFixtureCalls(self)
35 % Verify that fixture calls are made in the proper order.
36 tc = LoggingTestCase('testMethod');
37 tc.run(TestRunLogger());
38 assertTrue(isequal(tc.log, {'setUp', 'testMethod', 'tearDown'}));
39 end
40
41 function testTestFailure(self)
42 % Verify that a test failure is recorded.
43 logger = TestRunLogger();
44 TestSuite('FailingTestCase').run(logger);
45 assertTrue(isequal(logger.NumFailures, 1));
46 end
47
48 function testTestError(self)
49 % Verify that a test error is recorded.
50 logger = TestRunLogger();
51 TestSuite('BadFixture').run(logger);
52 assertTrue(isequal(logger.NumErrors, 1));
53 end
54
55 end
56
57 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/TestCaseWithAddPathTest.m deleted (index cb8cb3a..0000000)
1 %TestCaseTest Unit tests for the TestCaseWithAddPath class
2
3 % Steven L. Eddins
4 % Copyright The MathWorks 2008
5
6 classdef TestCaseWithAddPathTest < TestCaseWithAddPath
7
8 methods
9 function self = TestCaseWithAddPathTest(name)
10 self = self@TestCaseWithAddPath(name, ...
11 fullfile(fileparts(which(mfilename)), 'helper_classes'));
12 end
13
14 function testPath(self)
15 % Verify that a function in helper_classes is seen on the path.
16 assertEqual(exist('testFunctionHandlesA', 'file'), 2);
17 end
18
19 function testRunTestOnPath(self)
20 % Verify that we can make a test suite and run it using a file
21 % in the new path directory.
22 logger = TestRunLogger();
23 suite = TestSuite('testFunctionHandlesA');
24 did_pass = suite.run(logger);
25 assertTrue(did_pass);
26 end
27 end
28
29 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/TestFuncHandleTests.m deleted (index decdb62..0000000)
1 %TestFuncHandleTests TeseCase class used to test function-handle-based tests
2
3 % Steven L. Eddins
4 % Copyright 2008 The MathWorks, Inc.
5
6 classdef TestFuncHandleTests < TestCaseInDir
7
8 methods
9 function self = TestFuncHandleTests(name)
10 self = self@TestCaseInDir(name, ...
11 fullfile(fileparts(which(mfilename)), 'helper_classes'));
12 end
13
14 function testSuiteNameAndLocation(self)
15 test_suite = testFunctionHandlesA();
16 assertEqual(test_suite.Name, 'testFunctionHandlesA');
17 assertEqual(test_suite.Location, which('testFunctionHandlesA'));
18 end
19
20 function testOutputs(self)
21 % Exercise the function-handle test M-file. Output should be a
22 % two-element cell array of TestCase objects.
23 test_suite = testFunctionHandlesA();
24 assertTrue(isa(test_suite, 'TestSuite'));
25 assertEqual(test_suite.numTestCases(), 2);
26 end
27
28 function testCaseNames(self)
29 % Verify that Name property of test cases is set properly.
30 test_suite = testFunctionHandlesA();
31 assertEqual(test_suite.TestComponents{1}.Name, 'testA');
32 assertEqual(test_suite.TestComponents{2}.Name, 'testB');
33 end
34
35 function testCaseLocation(self)
36 % Verify that the Location field of test cases is set properly.
37 test_suite = testFunctionHandlesA();
38 expected_location = which('testFunctionHandlesA');
39 assertEqual(test_suite.TestComponents{1}.Location, expected_location);
40 assertEqual(test_suite.TestComponents{2}.Location, expected_location);
41 end
42
43 function testPassingTests(self)
44 % Verify that the expected observer notifications are received in
45 % the proper order.
46 logger = TestRunLogger();
47 suite = testFunctionHandlesA;
48 suite.run(logger);
49 assertEqual(logger.Log, ...
50 {'TestRunStarted', 'TestComponentStarted', ...
51 'TestComponentStarted', 'TestComponentFinished', ...
52 'TestComponentStarted', 'TestComponentFinished', ...
53 'TestComponentFinished', 'TestRunFinished'});
54 end
55
56 function testTestFixture(self)
57 % Verify that test fixture functions that use testData run without
58 % error. (See test assertions in testFunctionHandlesB.)
59 logger = TestRunLogger();
60 suite = testFunctionHandlesB;
61 suite.run(logger);
62 assertEqual(logger.NumFailures, 0);
63 assertEqual(logger.NumErrors, 0);
64 end
65
66 function testTestFixtureError(self)
67 % Verify that an exception thrown in a test fixture is recorded as a
68 % test error.
69 logger = TestRunLogger();
70 suite = testFunctionHandlesC();
71 suite.run(logger);
72 assertEqual(logger.NumErrors, 2);
73 end
74
75 function testFixtureNoTestData(self)
76 % Verify that when setupFcn returns no output argument, the test
77 % functions and the teardown function are called with no inputs.
78 % (See test assertions in testFunctionHandlesD.)
79 logger = TestRunLogger();
80 suite = testFunctionHandlesD();
81 suite.run(logger);
82 assertEqual(logger.NumFailures, 0);
83 assertEqual(logger.NumErrors, 0);
84 end
85
86 function testFailingTest(self)
87 % Verify that the expected observer notifications are received in
88 % the proper order for a failing test.
89 logger = TestRunLogger();
90 suite = testFunctionHandlesE();
91 suite.run(logger);
92 assertEqual(logger.Log, ...
93 {'TestRunStarted', 'TestComponentStarted', ...
94 'TestComponentStarted', 'TestCaseFailure', 'TestComponentFinished', ...
95 'TestComponentFinished', 'TestRunFinished'});
96 end
97
98 function testTeardownFcnButNoSetupFcn(self)
99 % Verify that a test file works if it has a teardown function but no
100 % setup function.
101 logger = TestRunLogger();
102 suite = testFunctionHandlesTeardownNoSetup();
103 suite.run(logger);
104
105 assertEqual(logger.NumTestCases, 1);
106 assertEqual(logger.NumFailures, 0);
107 assertEqual(logger.NumErrors, 0);
108 end
109
110 end
111 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/TestRunLoggerTest.m deleted (index 4fc9a56..0000000)
1 %TestSuiteTest Unit tests for TestSuite class
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 classdef TestRunLoggerTest < TestCaseInDir
6
7 methods
8 function self = TestRunLoggerTest(name)
9 self = self@TestCaseInDir(name, ...
10 fullfile(fileparts(which(mfilename)), 'helper_classes'));
11 end
12
13 function testTwoPassingTests(self)
14 logger = TestRunLogger;
15 suite = TestSuite('TwoPassingTests');
16 suite.run(logger);
17
18 assertEqual(logger.Log, ...
19 {'TestRunStarted', ...
20 'TestComponentStarted', ...
21 'TestComponentStarted', 'TestComponentFinished', ...
22 'TestComponentStarted', 'TestComponentFinished', ...
23 'TestComponentFinished', ...
24 'TestRunFinished'});
25
26 assertEqual(logger.NumTestCases, 2);
27 assertEqual(logger.NumFailures, 0);
28 assertEqual(logger.NumErrors, 0);
29 assertTrue(isempty(logger.Faults));
30 end
31
32 function testFailingTestCase(self)
33 logger = TestRunLogger;
34 suite = TestSuite('FailingTestCase');
35 suite.run(logger);
36
37 assertEqual(logger.Log, ...
38 {'TestRunStarted', ...
39 'TestComponentStarted', ...
40 'TestComponentStarted', 'TestCaseFailure', 'TestComponentFinished', ...
41 'TestComponentFinished', ...
42 'TestRunFinished'});
43
44 assertEqual(logger.NumTestCases, 1);
45 assertEqual(logger.NumFailures, 1);
46 assertEqual(logger.NumErrors, 0);
47 assertEqual(numel(logger.Faults), 1);
48 assertEqual(logger.Faults(1).Type, 'failure');
49 end
50
51 end
52
53 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/TestSuiteTest.m deleted (index e86ae53..0000000)
1 %TestSuiteTest Unit tests for TestSuite class
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 classdef TestSuiteTest < TestCaseInDir
6
7 methods
8 function self = TestSuiteTest(name)
9 self = self@TestCaseInDir(name, ...
10 fullfile(fileparts(which(mfilename)), 'helper_classes'));
11 end
12
13 function testClassNameIn(self)
14 % Syntax check: TestSuite('classname')
15 suite = TestSuite('TwoPassingTests');
16 assertTrue(numel(suite.TestComponents) == 2, ...
17 'TestSuite finds two test methods given class name');
18 end
19
20 function testCurrentDirectory(self)
21 % See that the no-input syntax executes without error.
22 % Not sure how to test this more effectively.
23 suite = TestSuite();
24 end
25
26 function testNoTestMethods(self)
27 % TestCase class containing no test methods
28 suite = TestSuite('NoTestMethods');
29 assertTrue(numel(suite.TestComponents) == 0, ...
30 'No test cases when class contains no test methods');
31 end
32
33 function test_fromTestCaseClassName(self)
34 suite = TestSuite.fromTestCaseClassName('TwoPassingTests');
35 assertTrue(numel(suite.TestComponents) == 2);
36 assertTrue(ismember(suite.TestComponents{1}.Name, ...
37 {'testMethod1', 'testMethod2'}));
38 assertTrue(ismember(suite.TestComponents{2}.Name, ...
39 {'testMethod1', 'testMethod2'}));
40 end
41
42 function test_fromTestCaseClassName_badclass(self)
43 assertExceptionThrown(@() TestSuite.fromTestCaseClassName('atan2'), ...
44 'xunit:fromTestCaseClassName');
45 end
46
47 function test_fromName_TestCaseSubclass(self)
48 suite = TestSuite.fromName('TwoPassingTests');
49 assertTrue(numel(suite.TestComponents) == 2);
50 assertEqual(suite.Name, 'TwoPassingTests');
51 end
52
53 function test_fromName_notTestCaseSubclass(self)
54 suite = TestSuite.fromName('TestRunMonitor');
55 assertTrue(isempty(suite.TestComponents));
56 assertEqual(suite.Name, 'TestRunMonitor');
57 end
58
59 function test_fromName_simpleTest(self)
60 suite = TestSuite.fromName('testSimple');
61 assertEqual(numel(suite.TestComponents), 1);
62 assertEqual(suite.Name, 'testSimple');
63 assertEqual(suite.Location, which('testSimple'));
64 end
65
66 function test_fromName_subfunctions(self)
67 suite = TestSuite.fromName('testFunctionHandlesA');
68 assertEqual(numel(suite.TestComponents), 2);
69 assertEqual(suite.Name, 'testFunctionHandlesA');
70 assertEqual(suite.Location, which('testFunctionHandlesA'));
71 end
72
73 function test_fromName_bogus_name(self)
74 suite = TestSuite.fromName('atan2');
75 assertTrue(isempty(suite.TestComponents));
76 assertEqual(suite.Name, 'atan2');
77 end
78
79 function test_fromName_with_filter_string(self)
80 suite = TestSuite.fromName('testFunctionHandlesA:testA');
81 assertEqual(numel(suite.TestComponents), 1);
82 assertEqual(suite.TestComponents{1}.Name, 'testA');
83 assertEqual(suite.Name, 'testFunctionHandlesA');
84 end
85
86 function test_fromName_with_nonmatching_filter_string(self)
87 suite = TestSuite.fromName('testFunctionHandlesA:foobar');
88 assertTrue(isempty(suite.TestComponents));
89 end
90
91 function test_fromName_with_dirname(self)
92 xunit_test_dir = which('TestSuiteTest');
93 xunit_test_dir = fileparts(xunit_test_dir);
94 cwd_test_dir = fullfile(xunit_test_dir, 'cwd_test');
95 suite = TestSuite.fromName(cwd_test_dir);
96
97 assertEqual(suite.Name, 'cwd_test');
98 assertEqual(suite.Location, cwd_test_dir);
99 assertEqual(numel(suite.TestComponents), 3);
100 end
101
102 function test_fromPwd(self)
103 % Verify that the fromPwd method returns a nonempty TestSuite object
104 % from the helper_classes directory, with the correct number of
105 % test components.
106 suite = TestSuite.fromPwd();
107 assertTrue(isa(suite, 'TestSuite'));
108 assertTrue(numel(suite.TestComponents) == 16);
109 end
110
111 end
112
113 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/ThrowsExceptionTest.m deleted (index de107f2..0000000)
1 % Copyright 2013 The MathWorks, Inc.
2
3 classdef ThrowsExceptionTest < TestCaseInDir
4
5 methods
6 function self = ThrowsExceptionTest(methodName)
7 self = self@TestCaseInDir(methodName, ...
8 fullfile(fileparts(which(mfilename)), 'helper_classes'));
9 end
10
11 function testPassingTest(self)
12 logger = TestRunLogger();
13 TestSuite('PassingExceptionTest').run(logger);
14 assertTrue((logger.NumTestCases == 1) && ...
15 (logger.NumFailures == 0) && ...
16 (logger.NumErrors == 0), ...
17 'Passing exception test should have no failures or errors');
18 end
19
20 function testNoExceptionTest(self)
21 logger = TestRunLogger();
22 TestSuite('ExceptionNotThrownTest').run(logger);
23 assertTrue(strcmp(logger.Faults(1).Exception.identifier, ...
24 'assertExceptionThrown:noException'), ...
25 'Fault exception should be throwsException:noException');
26 end
27
28 function testWrongExceptionTest(self)
29 logger = TestRunLogger();
30 TestSuite('WrongExceptionThrownTest').run(logger);
31 assertTrue(strcmp(logger.Faults(1).Exception.identifier, ...
32 'assertExceptionThrown:wrongException'), ...
33 'Fault exception should be throwsException:wrongException');
34 end
35
36 end
37
38
39 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/almost_black.tif deleted (index ed9ee94..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/tests/black.png deleted (index c2f495f..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/tests/black.tif deleted (index 22c8a44..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/tests/cwd_test/TestCaseSubclass.m deleted (index 91db71c..0000000)
1 %TestCaseSubclass TestCase subclass containing two passing tests
2
3 % Steven L. Eddins
4 % Copyright 2008 The MathWorks, Inc.
5
6 classdef TestCaseSubclass < TestCase
7 methods
8 function self = TestCaseSubclass(name)
9 self = self@TestCase(name);
10 end
11
12 function testA(self)
13 end
14
15 function testB(self)
16 % Intentionally fail this test case.
17 assertFalse(true);
18 end
19 end
20 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/cwd_test/testFoobar.m deleted (index c0ee40e..0000000)
1 function testFoobar
2 %testFoobar Passing M-file test
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/tests/cwd_test/testSubfunctions.m deleted (index 6d81c0c..0000000)
1 function test_suite = testSubfunctions
2 %testSubfunctions Contains two passing subfunction tests
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testSub1
10
11 function testSub2
File data_analysis/unittests/matlab_xunit_3_1_1/tests/dir1/test_thatPasses.m deleted (index 9a4679e..0000000)
1 function test_suite = test_thatPasses
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 initTestSuite;
6
7 function test_case
8 assertTrue(true);
File data_analysis/unittests/matlab_xunit_3_1_1/tests/dir2/test_thatFails.m deleted (index e3acb42..0000000)
1 function test_suite = test_thatFails
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 initTestSuite;
6
7 function test_case
8 assertTrue(false);
File data_analysis/unittests/matlab_xunit_3_1_1/tests/empty_file deleted (index e69de29..0000000)
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/BadFixture.m deleted (index a35aa94..0000000)
1 classdef BadFixture < TestCase
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 methods
6 function self = BadFixture(name)
7 self = self@TestCase(name);
8 end
9
10 function setUp(self)
11 throw(MException('setUpError:BadFixture', ...
12 'BadFixture setUp method always throws exception'));
13 end
14
15 function testMethod(self)
16 end
17 end
18 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/Contents.m deleted (index c0e53d8..0000000)
1 % Helper Classes for mUnit Test Suite
2 %
3 % TestCase Subclasses
4 % BadFixture - Contains setUp method that throws exception
5 % FailingTestCase - Contains one test method that throws exception
6 % LoggingTestCase - Logs calls to setUp, tearDown, and test method
7 % NoTestMethods - TestCase subclass that contains no test methods
8 % TestsToBeDiscovered - Used in TestSuiteTest
9 % TwoPassingTests - Contains two passing test methods
10
11 % Steven L. Eddins
12 % Copyright 2008 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/ExceptionNotThrownTest.m deleted (index b2f0b61..0000000)
1 classdef ExceptionNotThrownTest < TestCase
2 % Copyright 2013 The MathWorks, Inc.
3 methods
4 function self = ExceptionNotThrownTest(methodName)
5 self = self@TestCase(methodName);
6 end
7
8 function testThrowsException(self)
9 f = @() [];
10 assertExceptionThrown(f, 'a:b:c');
11 end
12 end
13 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/FailingTestCase.m deleted (index 57b899d..0000000)
1 % FailingTestCase
2 % Utility class used by unit tests.
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 classdef FailingTestCase < TestCase
8
9 methods
10 function self = FailingTestCase(name)
11 self = self@TestCase(name);
12 end
13
14 function testFail(self)
15 throw(MException('testFail:FailingTestCase', ...
16 'testFail always fails'));
17 end
18 end
19
20 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/LoggingTestCase.m deleted (index fd5d2c8..0000000)
1 % LoggingTestCase
2 % Utility class used by unit tests.
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 classdef LoggingTestCase < TestCase
8
9 properties
10 log = {};
11 end
12
13 methods
14 function self = LoggingTestCase(name)
15 self = self@TestCase(name);
16 end
17
18 function setUp(self)
19 self.log{end + 1} = 'setUp';
20 end
21
22 function tearDown(self)
23 self.log{end + 1} = 'tearDown';
24 end
25
26 function testMethod(self)
27 self.log{end + 1} = 'testMethod';
28 end
29
30 function testBrokenMethod(self)
31 throw(MException('brokenMethod:WasRun', ...
32 'Call to testBrokenMethod always throws exception'));
33 end
34 end
35
36 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/NoTestMethods.m deleted (index 9c26c8f..0000000)
1 % Copyright 2013 The MathWorks, Inc.
2
3 classdef NoTestMethods < TestCase
4 methods
5 function self = NoTestMethods(name)
6 self = self@TestCase(name);
7 end
8 end
9 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/PassingExceptionTest.m deleted (index 2470d7b..0000000)
1 % Copyright 2013 The MathWorks, Inc.
2
3 classdef PassingExceptionTest < TestCase
4 methods
5 function self = PassingExceptionTest(methodName)
6 self = self@TestCase(methodName);
7 end
8
9 function testThrowsException(self)
10 f = @() error('a:b:c', 'error message');
11 assertExceptionThrown(f, 'a:b:c');
12 end
13 end
14 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/TestsToBeDiscovered.m deleted (index 428adec..0000000)
1 % Copyright 2013 The MathWorks, Inc.
2
3 classdef TestsToBeDiscovered < TestCase
4
5 methods
6 function self = TestsToBeDiscovered(name)
7 self = self@TestCase(name);
8 end
9
10 function testMethodA
11 end
12
13 function testMethodB
14 end
15
16 function notATestMethod
17 end
18
19 end
20
21 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/TwoPassingTests.m deleted (index 963c713..0000000)
1 % Copyright 2013 The MathWorks, Inc.
2
3 classdef TwoPassingTests < TestCase
4
5 methods
6 function self = TwoPassingTests(name)
7 self = self@TestCase(name);
8 end
9
10 function testMethod1(self)
11 end
12
13 function testMethod2(self)
14 end
15 end
16
17 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/WrongExceptionThrownTest.m deleted (index 7cc3d8f..0000000)
1 % Copyright 2013 The MathWorks, Inc.
2
3 classdef WrongExceptionThrownTest < TestCase
4 methods
5 function self = WrongExceptionThrownTest(methodName)
6 self = self@TestCase(methodName);
7 end
8
9 function testThrowsException(self)
10 f = @() error('d:e:f', 'message');
11 assertExceptionThrown(f, 'a:b:c');
12 end
13 end
14 end
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/notTestString.m deleted (index ba94383..0000000)
1 % Copyright 2013 The MathWorks, Inc.
2
3 function suite = notTestString
4 % This function exists to help test that the TestSuite.fromPwd() method does not
5 % pick up function-handle test files that do not match the naming convention.
6 initTestSuite;
7
8 function testA
9
10 function testB
11
12
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesA.m deleted (index 3b0e0f8..0000000)
1 function test_suite = testFunctionHandlesA
2 %testFunctionHandlesA Test file used by TestFunctionHandlesTest
3 % Contains two passing tests.
4
5 % Steven L. Eddins
6 % Copyright 2008 The MathWorks, Inc.
7
8 initTestSuite;
9
10 function testA
11
12 function testB
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesB.m deleted (index 49ea57f..0000000)
1 function test_suite = testFunctionHandlesB
2 %testFunctionHandlesB Test file used by TestFunctionHandlesTest
3 % Contains two passing tests that use a test fixture.
4
5 % Steven L. Eddins
6 % Copyright 2008 The MathWorks, Inc.
7
8 initTestSuite;
9
10 function testData = setUpFcn
11 testData = 5;
12
13 function testA(testData)
14 assertEqual(testData, 5);
15
16 function testB(testData)
17 assertEqual(testData, 5);
18
19 function tearDownFcn(testData)
20 assertEqual(testData, 5);
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesC.m deleted (index f987204..0000000)
1 function test_suite = testFunctionHandlesC
2 %testFunctionHandlesC Test file used by TestFunctionHandlesTest
3 % Contains two passing tests that use a test fixture containing an intentional
4 % error.
5
6 % Steven L. Eddins
7 % Copyright 2008 The MathWorks, Inc.
8
9 initTestSuite;
10
11 function testData = setUpFcn
12 testData = 5;
13
14 function testA(testData)
15 assertEqual(testData, 5);
16
17 function testB(testData)
18 assertEqual(testData, 5);
19
20 function tearDownFcn(testData)
21 % This assertion is expected to error.
22 assertEqual(testData, 20);
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesD.m deleted (index 9c3a7c1..0000000)
1 function test_suite = testFunctionHandlesD
2 %testFunctionHandlesD Test file used by TestFunctionHandlesTest
3 % Contains two passing tests that use a test fixture with no test data.
4
5 % Steven L. Eddins
6 % Copyright 2008 The MathWorks, Inc.
7
8 initTestSuite;
9
10 function setUpFcn
11
12
13 function testA(varargin)
14 assertTrue(isempty(varargin));
15
16 function testB(varargin)
17 assertTrue(isempty(varargin));
18
19 function tearDownFcn(varargin)
20 assertTrue(isempty(varargin));
21
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesE.m deleted (index b35bea5..0000000)
1 function test_suite = testFunctionHandlesA
2 %testFunctionHandlesE Test file used by TestFunctionHandlesTest
3 % Contains one failing test.
4
5 % Steven L. Eddins
6 % Copyright 2008 The MathWorks, Inc.
7
8 initTestSuite;
9
10 function testA
11 error('testFunctionHandlesA:expectedFailure', 'Bogus message');
12
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testFunctionHandlesTeardownNoSetup.m deleted (index b03ab6d..0000000)
1 % Copyright 2013 The MathWorks, Inc.
2
3 function suite = testFunctionHandlesTeardownNoSetup
4 % Verify that test file works if it has a teardown function but no setup
5 % function.
6 initTestSuite;
7
8 function teardown
9 close all
10
11 function test_normalCase
12 assertEqual(1, 1);
13
File data_analysis/unittests/matlab_xunit_3_1_1/tests/helper_classes/testSimple.m deleted (index 466b54b..0000000)
1 function testSimple
2 %testSimple Simple M-file test that passes
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/tests/testAssertEqual.m deleted (index 28979e3..0000000)
1 function test_suite = testAssertEqual
2 %testAssertEqual Unit tests for assertEqual
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testAssertEqualHappyCase
10 assertEqual(5, 5);
11
12 function testAssertEqualWithThreeInputs
13 assertEqual(5, 5, 'Scandinavian Defense');
14
15 function testAssertEqualHappyCaseString
16 assertEqual('foobar', 'foobar');
17
18 function testAssertEqualHappyCaseMatrix
19 assertEqual(magic(3), magic(3))
20
21 function testInfAndInf
22 assertEqual(Inf, Inf);
23
24 function testMinusInfAndMinusInf
25 assertEqual(-Inf, -Inf);
26
27 function testOppositeSignInfs
28 assertExceptionThrown(@() assertEqual(-Inf, Inf), 'assertEqual:nonEqual');
29
30 function testFiniteAndInf
31 assertExceptionThrown(@() assertEqual(1, Inf), 'assertEqual:nonEqual');
32
33 function testFiniteAndNaN
34 assertExceptionThrown(@() assertEqual(1, NaN), 'assertEqual:nonEqual');
35
36 function testInfiniteAndNaN
37 assertExceptionThrown(@() assertEqual(Inf, NaN), 'assertEqual:nonEqual');
38
39 function testAssertEqualNotEqual
40 assertExceptionThrown(@() assertEqual(5, 4), 'assertEqual:nonEqual');
41
42 function testAssertEqualSparsity
43 assertExceptionThrown(@() assertEqual(5, sparse(5)), 'assertEqual:sparsityNotEqual');
44
45 function testAssertEqualNans
46 assertEqual([1 NaN 2], [1 NaN 2]);
47
48 function testAssertEqualClass
49 assertExceptionThrown(@() assertEqual(5, uint8(5)), 'assertEqual:classNotEqual');
File data_analysis/unittests/matlab_xunit_3_1_1/tests/testAssertExceptionThrown.m deleted (index 9ce3938..0000000)
1 function test_suite = testAssertExceptionThrown
2 %testAssertExceptionThrown Unit tests for assertExceptionThrown
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function test_happyCase
10 assertExceptionThrown(...
11 @() error('MyProd:MyFun:MyId', 'my message'), 'MyProd:MyFun:MyId');
12
13 function test_wrongException
14 assertExceptionThrown(@() assertExceptionThrown(...
15 @() error('MyProd:MyFun:MyId', 'my message'), ...
16 'MyProd:MyFun:DifferentId'), 'assertExceptionThrown:wrongException');
17
18 function test_noException
19 assertExceptionThrown(@() assertExceptionThrown(@() sin(pi), 'foobar'), ...
20 'assertExceptionThrown:noException');
21
22
23
File data_analysis/unittests/matlab_xunit_3_1_1/tests/testAssertFalse.m deleted (index 2ba1429..0000000)
1 function test_suite = testAssertFalse
2 %testAssertFalse Unit tests for assertFalse
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testAssertFalseHappyCase
10 assertFalse(false);
11
12 function testAssertFalseHappyCaseWithTwoArgs
13 assertFalse(false, '1.e4 e5 2.Nf3 Nc6');
14
15 function testAssertFalseFailed
16 % Verify exception when false is passed to assertFalse.
17 assertExceptionThrown(@() assertFalse(true), 'assertFalse:trueCondition');
18
19 function testAssertFalseNonscalar
20 % Verify that assertFalse doesn't like nonscalar input.
21 assertExceptionThrown(@() assertFalse(logical([0 0])), 'assertFalse:invalidCondition');
22
23 function testAssertFalseNonlogical
24 % Verify that assertFalse doesn't like nonlogical input.
25 assertExceptionThrown(@() assertFalse(0), 'assertFalse:invalidCondition');
File data_analysis/unittests/matlab_xunit_3_1_1/tests/testAssertTrue.m deleted (index 0f5f34a..0000000)
1 function test_suite = testAssertTrue
2 %testAssertTrue Unit tests for assertTrue
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testAssertTrueHappyCase
10 assertTrue(true);
11
12 function testAssertTrueHappyCaseWithTwoArgs
13 assertTrue(true, '1.e4 e5 2.Nf3 Nc6');
14
15 function testAssertTrueFailed
16 % Verify exception when false is passed to assertTrue.
17 assertExceptionThrown(@() assertTrue(false), 'assertTrue:falseCondition');
18
19 function testAssertTrueNonscalar
20 % Verify that assertTrue doesn't like nonscalar input.
21 assertExceptionThrown(@() assertTrue(logical([1 1])), 'assertTrue:invalidCondition');
22
23 function testAssertTrueNonlogical
24 % Verify that assertTrue doesn't like nonlogical input.
25 assertExceptionThrown(@() assertTrue(5), 'assertTrue:invalidCondition');
File data_analysis/unittests/matlab_xunit_3_1_1/tests/testContainsRegexp.m deleted (index d3b62b2..0000000)
1 function test_suite = testContainsRegexp
2 %testContainsRegexp Unit tests for containsRegexp
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testOneStringContains
10 assertTrue(xunit.utils.containsRegexp('MATLAB is great', '[A-Z]'));
11
12 function testOneStringDoesntContain
13 assertTrue(~ xunit.utils.containsRegexp('no upper-case letters', '[A-Z]'));
14
15 function testCellArray
16 strs = {'MATLAB is great', 'no upper-case letters'};
17 assertEqual(xunit.utils.containsRegexp(strs, '[A-Z]'), [true false]);
18 assertEqual(xunit.utils.containsRegexp(strs', '[A-Z]'), [true; false]);
File data_analysis/unittests/matlab_xunit_3_1_1/tests/testIsSetUpString.m deleted (index 29aeac4..0000000)
1 function test_suite = testIsSetUpString
2 %testIsSetUpString Unit tests for isSetUpString
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testOneStringIs
10 assertTrue(xunit.utils.isSetUpString('setup'));
11 assertTrue(xunit.utils.isSetUpString('setUp_fixture'));
12
13 function testOneStringIsNot
14 assertFalse(xunit.utils.isSetUpString('bogus'));
15
16 function testCellArray
17 strs = {'setup', 'bogus'};
18 assertEqual(xunit.utils.isSetUpString(strs), [true false]);
19 assertEqual(xunit.utils.isSetUpString(strs'), [true; false]);
File data_analysis/unittests/matlab_xunit_3_1_1/tests/testIsTearDownString.m deleted (index ea65aa2..0000000)
1 function test_suite = testIsTearDownString
2 %testIsTearDownString Unit tests for isTearDownString
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testOneStringIs
10 assertTrue(xunit.utils.isTearDownString('teardownfoobar'));
11 assertTrue(xunit.utils.isTearDownString('TearDown_foobar'));
12
13 function testOneStringIsNot
14 assertFalse(xunit.utils.isTearDownString('tEardown'));
15
16 function testCellArray
17 strs = {'teardown', 'tearup'};
18 assertEqual(xunit.utils.isTearDownString(strs), [true false]);
19 assertEqual(xunit.utils.isTearDownString(strs'), [true; false]);
File data_analysis/unittests/matlab_xunit_3_1_1/tests/testIsTestCaseSubclass.m deleted (index 249f414..0000000)
1 function test_suite = testIsTestCaseSubclass
2 %testIsTestCaseSubclass Unit tests for isTestCaseSubclass
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testTestCase
10 assertTrue(xunit.utils.isTestCaseSubclass('TestCase'));
11
12 function testSubclass
13 assertTrue(xunit.utils.isTestCaseSubclass('TestCaseInDir'));
14
15 function testNotASubclass
16 assertFalse(xunit.utils.isTestCaseSubclass('atan2'));
File data_analysis/unittests/matlab_xunit_3_1_1/tests/testIsTestString.m deleted (index e592b0f..0000000)
1 function test_suite = testIsTestString
2 %testIsTestString Unit tests for isTestString
3
4 % Steven L. Eddins
5 % Copyright 2008 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function testOneStringIs
10 assertTrue(xunit.utils.isTestString('testFoobar'));
11 assertTrue(xunit.utils.isTestString('Test_foobar'));
12
13 function testOneStringIsNot
14 assertFalse(xunit.utils.isTestString('foobar'));
15
16 function testCellArray
17 strs = {'testFoobar', 'foobar_test', 'foobar', 'foobar_Test'};
18 assertEqual(xunit.utils.isTestString(strs), [true true false true]);
19 assertEqual(xunit.utils.isTestString(strs'), [true; true; false; true]);
File data_analysis/unittests/matlab_xunit_3_1_1/tests/testRuntestsWithDirectoryName.m deleted (index fc38ae9..0000000)
1 function test_suite = testRuntestsWithDirectoryName
2 %testRuntestsWithDirectoryName Unit test for mtest('dirname') syntax.
3
4 % Copyright 2013 The MathWorks, Inc.
5
6 initTestSuite;
7
8 function testDirName
9 current_dir = pwd;
10 target_dir = fullfile(fileparts(which(mfilename)), 'cwd_test');
11 [T, did_pass] = evalc('runtests(target_dir)');
12 assertFalse(did_pass);
13 assertEqual(current_dir, pwd);
File data_analysis/unittests/matlab_xunit_3_1_1/tests/test_TestSuiteInDir.m deleted (index 7bd169b..0000000)
1 function test_suite = test_TestSuiteInDir
2 %test_TestSuiteInDir Unit test for TestSuiteInDir class.
3
4 % Steven L. Eddins
5 % Copyright 2009 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function test_constructor
10 this_test_path = fileparts(which(mfilename));
11 cwd_test_dir = fullfile(this_test_path, 'cwd_test');
12 suite = TestSuiteInDir(cwd_test_dir);
13
14 assertEqual(suite.Name, 'cwd_test');
15 assertEqual(suite.Location, cwd_test_dir);
16
17 function test_gatherTestCases
18 this_test_path = fileparts(which(mfilename));
19 cwd_test_dir = fullfile(this_test_path, 'cwd_test');
20 suite = TestSuiteInDir(cwd_test_dir);
21 suite.gatherTestCases();
22
23 assertEqual(numel(suite.TestComponents), 3);
24
File data_analysis/unittests/matlab_xunit_3_1_1/tests/test_arrayToString.m deleted (index d0c1818..0000000)
1 function test_suite = test_arrayToString
2 %test_arrayToString Unit test for arrayToString.
3
4 % Steven L. Eddins
5 % Copyright 2009 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function test_smallInput
10 A = [1 2 3];
11 assertEqual(strtrim(xunit.utils.arrayToString(A)), '1 2 3');
12
13 function test_largeInput
14 A = zeros(1000, 1000);
15 assertEqual(xunit.utils.arrayToString(A), '[1000x1000 double]');
16
17 function test_emptyInput
18 assertEqual(xunit.utils.arrayToString(zeros(1,0,2)), '[1x0x2 double]');
File data_analysis/unittests/matlab_xunit_3_1_1/tests/test_assertElementsAlmostEqual.m deleted (index b5b2e20..0000000)
1 function suite = test_assertElementsAlmostEqual
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 initTestSuite;
6
7 %===============================================================================
8 function test_happyCase
9
10 % All code here should execute with no error.
11 assertElementsAlmostEqual(1, 1 + sqrt(eps)/10);
12 assertElementsAlmostEqual(1, 1 + sqrt(eps)/10, 'custom message');
13
14 %===============================================================================
15 function test_failedAssertion
16
17 f = @() assertElementsAlmostEqual(1, 1 + 10*sqrt(eps));
18 assertExceptionThrown(f, 'assertElementsAlmostEqual:tolExceeded');
19
20 %===============================================================================
21 function test_nonFloatInputs()
22 assertExceptionThrown(@() assertElementsAlmostEqual('hello', 'world'), ...
23 'assertElementsAlmostEqual:notFloat');
24
25 %===============================================================================
26 function test_sizeMismatch()
27 assertExceptionThrown(@() assertElementsAlmostEqual(1, [1 2]), ...
28 'assertElementsAlmostEqual:sizeMismatch');
29
30 function test_finiteAndInfinite()
31 assertExceptionThrown(@() assertElementsAlmostEqual(1, Inf), ...
32 'assertElementsAlmostEqual:tolExceeded');
33
34 function test_infiniteAndInfinite()
35 assertElementsAlmostEqual(Inf, Inf);
36
37 function test_finiteAndNaN()
38 assertExceptionThrown(@() assertElementsAlmostEqual(1, NaN), ...
39 'assertElementsAlmostEqual:tolExceeded');
40
41 function test_nanAndNaN()
42 assertElementsAlmostEqual(NaN, NaN);
43
44 function test_plusMinusInfinity()
45 assertExceptionThrown(@() assertElementsAlmostEqual(+Inf, -Inf), ...
46 'assertElementsAlmostEqual:tolExceeded');
47
48 function test_infiniteAndNaN()
49 assertExceptionThrown(@() assertElementsAlmostEqual(Inf, NaN), ...
50 'assertElementsAlmostEqual:tolExceeded');
51
52
53
File data_analysis/unittests/matlab_xunit_3_1_1/tests/test_assertFilesEqual.m deleted (index 5768b88..0000000)
1 function test_suite = test_assertFilesEqual
2 %test_assertFilesEqual Unit test for assertFilesEqual
3
4 % Steven L. Eddins
5 % Copyright 2009 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function test_equal
10 assertFilesEqual('black.tif', 'black.tif');
11
12 function test_differentSize
13 assertExceptionThrown(@() assertFilesEqual('black.tif', 'black.png'), ...
14 'assertFilesEqual:sizeMismatch');
15
16 function test_sameSizeButDifferent
17 assertExceptionThrown(@() assertFilesEqual('black.tif', 'almost_black.tif'), ...
18 'assertFilesEqual:valuesDiffer');
19
20 function test_oneFileEmpty
21 assertExceptionThrown(@() assertFilesEqual('empty_file', 'black.png'), ...
22 'assertFilesEqual:sizeMismatch');
23
24 function test_bothFilesEmpty
25 assertFilesEqual('empty_file', 'empty_file');
26
27 function test_cannotReadFirstFile
28 assertExceptionThrown(@() assertFilesEqual('bogus', 'black.png'), ...
29 'assertFilesEqual:readFailure');
30
31 function test_cannotReadSecondFile
32 assertExceptionThrown(@() assertFilesEqual('black.png', 'bogus'), ...
33 'assertFilesEqual:readFailure');
File data_analysis/unittests/matlab_xunit_3_1_1/tests/test_assertVectorsAlmostEqual.m deleted (index dc215c4..0000000)
1 function suite = test_assertVectorsAlmostEqual
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 initTestSuite;
6
7 %===============================================================================
8 function test_happyCase
9
10 A = [1 1e10];
11 B = [2 1e10];
12 % All code here should execute with no error.
13 assertVectorsAlmostEqual(A, B);
14 assertVectorsAlmostEqual(A, B, 'custom message');
15
16 %===============================================================================
17 function test_failedAssertion
18
19 A = [1 1e6];
20 B = [2 1e6];
21
22 f = @() assertVectorsAlmostEqual(A, B);
23 assertExceptionThrown(f, 'assertVectorsAlmostEqual:tolExceeded');
24
25 %===============================================================================
26 function test_failedAssertionWithCustomMessage
27
28 A = [1 1e6];
29 B = [2 1e6];
30 f = @() assertVectorsAlmostEqual(A, B, 'my message');
31 assertExceptionThrown(f, 'assertVectorsAlmostEqual:tolExceeded');
32
33 %===============================================================================
34 function test_nonFloatInputs()
35 assertExceptionThrown(@() assertVectorsAlmostEqual('hello', 'world'), ...
36 'assertVectorsAlmostEqual:notFloat');
37
38 %===============================================================================
39 function test_sizeMismatch()
40 assertExceptionThrown(@() assertVectorsAlmostEqual(1, [1 2]), ...
41 'assertVectorsAlmostEqual:sizeMismatch');
42
43 %===============================================================================
44 function test_finiteAndInfinite()
45 assertExceptionThrown(@() assertVectorsAlmostEqual([1 2], [1 Inf]), ...
46 'assertVectorsAlmostEqual:tolExceeded');
47
48 %===============================================================================
49 function test_infiniteAndInfinite
50 assertExceptionThrown(@() assertVectorsAlmostEqual([1 Inf], [1 Inf]), ...
51 'assertVectorsAlmostEqual:tolExceeded');
52
53 %===============================================================================
54 function test_finiteAndNaN
55 assertExceptionThrown(@() assertVectorsAlmostEqual([1 2], [1 NaN]), ...
56 'assertVectorsAlmostEqual:tolExceeded');
57
58 %===============================================================================
59 function test_NanAndNan
60 assertExceptionThrown(@() assertVectorsAlmostEqual([1 NaN], [1 NaN]), ...
61 'assertVectorsAlmostEqual:tolExceeded');
62
63 %===============================================================================
64 function test_oppositeSignInfs
65 assertExceptionThrown(@() assertVectorsAlmostEqual([1 Inf], [1 -Inf]), ...
66 'assertVectorsAlmostEqual:tolExceeded');
67
68
File data_analysis/unittests/matlab_xunit_3_1_1/tests/test_compareFloats.m deleted (index dec8732..0000000)
1 function suite = test_compareFloats
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 initTestSuite;
6
7 %===============================================================================
8 function test_elementwiseRelativeTolerance
9
10 tol = 0.1;
11 floor_tol = 0.01;
12
13 assertTrue(xunit.utils.compareFloats([10 20], [11 20], 'elementwise', ...
14 'relative', tol, floor_tol));
15 assertFalse(xunit.utils.compareFloats([10 20], [11.2 20], 'elementwise', ...
16 'relative', tol, floor_tol));
17
18 % Verify floor tolerance
19 assertTrue(xunit.utils.compareFloats([0.001 1], [0.010 1], 'elementwise', ...
20 'relative', tol, floor_tol));
21
22 %===============================================================================
23 function test_elementwiseAbsoluteTolerance
24
25 assertTrue(xunit.utils.compareFloats([10 20], [10.1 20], 'elementwise', ...
26 'absolute', 0.1));
27 assertFalse(xunit.utils.compareFloats([10 20], [10.1001 20], 'elementwise', ...
28 'absolute', 0.1));
29
30 %===============================================================================
31 function test_vectorRelativeTolerance
32
33 % The A-B pair below would fail an elementwise test.
34 A = [1 10];
35 B = [1.5 10];
36 tol = 0.05;
37
38 assertTrue(xunit.utils.compareFloats(A, B, 'vector', 'relative', tol));
39
40 B = [1.6 10];
41 assertFalse(xunit.utils.compareFloats(A, B, 'vector', 'relative', tol));
42
43 %===============================================================================
44 function test_vectorAbsoluteTolerance
45
46 A = [1 10];
47 B = [1.4 10];
48
49 assertTrue(xunit.utils.compareFloats(A, B, 'vector', 'absolute', 0.5));
50 assertFalse(xunit.utils.compareFloats(A, B, 'vector', 'absolute', 0.3));
51
52 %===============================================================================
53 function test_NaNs
54
55 % NaNs in the same spots are OK.
56 A = [1 1 1 NaN 1 1 1 NaN 1];
57 B = [1 1 1 NaN 1 1 1 NaN 1];
58
59 assertTrue(xunit.utils.compareFloats(A, B));
60
61 % NaNs in different spots are not OK.
62 B2 = [1 1 NaN NaN 1 1 1 NaN 1];
63 assertFalse(xunit.utils.compareFloats(A, B2));
64
65 %===============================================================================
66 function test_Infs
67
68 % Infinities in the same locations are OK if they have the same sign.
69 assertTrue(xunit.utils.compareFloats([1 2 3 Inf 4 5], [1 2 3 Inf 4 5]));
70 assertTrue(xunit.utils.compareFloats([1 2 3 -Inf 4 5], [1 2 3 -Inf 4 5]));
71 assertFalse(xunit.utils.compareFloats([1 2 3 Inf 4 5], [1 2 3 -Inf 4 5], ...
72 'elementwise', 'absolute'));
73
74 %===============================================================================
75 function test_complexInput
76
77 % Real and imaginary parts are compared separately.
78 assertTrue(xunit.utils.compareFloats(1, 1+0.09i, 'elementwise', 'absolute', 0.1));
79 assertFalse(xunit.utils.compareFloats(1, 1+0.11i, 'elementwise', 'absolute', 0.1));
80
81 %===============================================================================
82 function test_comparisonTypeSpecified
83
84 % Verify handling of third input argument, the comparison type. The rest of the
85 % input syntax is handled by parseFloatAssertInputs and tested by the unit test
86 % for that function.
87
88 % The A-B pair below fails using elementwise comparison but passes using vector
89 % comparison.
90 A = [1.5 10];
91 B = [1 10];
92 tol = 0.1;
93
94 assertFalse(xunit.utils.compareFloats(A, B, 'elementwise', 'relative', tol));
95 assertTrue(xunit.utils.compareFloats(A, B, 'vector', 'relative', tol));
File data_analysis/unittests/matlab_xunit_3_1_1/tests/test_comparisonMessage.m deleted (index 2bfb9cd..0000000)
1 function test_suite = test_comparisonMessage
2 %test_comparisonMessage Unit test for comparisonMessage.
3
4 % Steven L. Eddins
5 % Copyright 2009 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function test_happyCase
10 s = xunit.utils.comparisonMessage('user message', 'assertion message', ...
11 [1 2 3], 'hello');
12 c = xunit.utils.stringToCellArray(s);
13
14 expected_output = { 'user message'
15 'assertion message'
16 ''
17 'First input:'
18 ' 1 2 3'
19 ''
20 'Second input:'
21 'hello'};
22
23 assertEqual(c, expected_output);
24
25
File data_analysis/unittests/matlab_xunit_3_1_1/tests/test_packageName.m deleted (index 8621674..0000000)
1 function test_suite = test_packageName
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 initTestSuite;
6
7 function test_happyCase
8 suite = TestSuite.fromPackageName('xunit.mocktests');
9 assertEqual(numel(suite.TestComponents), 5);
10
11 assertEqual(numel(suite.TestComponents{1}.TestComponents), 1);
12 assertEqual(suite.TestComponents{1}.Name, 'xunit.mocktests.subpkg');
13
14 assertEqual(numel(suite.TestComponents{2}.TestComponents), 2);
15 assertEqual(suite.TestComponents{2}.Name, 'xunit.mocktests.A');
16
17 assertEqual(numel(suite.TestComponents{3}.TestComponents), 1);
18 assertEqual(suite.TestComponents{3}.Name, 'xunit.mocktests.FooTest');
19
20 assertEqual(numel(suite.TestComponents{4}.TestComponents), 2);
21 assertEqual(suite.TestComponents{4}.Name, 'test_that');
22
23 assertEqual(numel(suite.TestComponents{5}.TestComponents), 1);
24 assertEqual(suite.TestComponents{5}.Name, 'xunit.mocktests.test_this');
25
26 function test_badPackageName
27 assertExceptionThrown(@() TestSuite.fromPackageName('bogus'), ...
28 'xunit:fromPackageName:invalidName');
29
File data_analysis/unittests/matlab_xunit_3_1_1/tests/test_parseFloatAssertInputs.m deleted (index a09a461..0000000)
1 function suite = test_parseFloatAssertInputs
2
3 % Copyright 2013 The MathWorks, Inc.
4
5 initTestSuite;
6
7 %===============================================================================
8 function test_tooFewInputs()
9 assertExceptionThrown(@() xunit.utils.parseFloatAssertInputs(), ...
10 'MATLAB:nargchk:notEnoughInputs');
11
12 %===============================================================================
13 function test_tooManyInputs()
14 assertExceptionThrown(@() xunit.utils.parseFloatAssertInputs(1,2,3,4,5,6,7), ...
15 'MATLAB:nargchk:tooManyInputs');
16
17 %===============================================================================
18 function test_twoInputs()
19 params = xunit.utils.parseFloatAssertInputs(1, 2);
20 assertEqual(params.A, 1);
21 assertEqual(params.B, 2);
22 assertEqual(params.ToleranceType, 'relative');
23 assertEqual(params.Tolerance, sqrt(eps));
24 assertEqual(params.FloorTolerance, sqrt(eps));
25 assertEqual(params.Message, '');
26
27 %===============================================================================
28 function test_threeInputs()
29 expected.A = 1;
30 expected.B = 2;
31 expected.ToleranceType = 'relative';
32 expected.Tolerance = sqrt(eps);
33 expected.FloorTolerance = sqrt(eps);
34 expected.Message = '';
35
36 params = xunit.utils.parseFloatAssertInputs(1, 2, 'relative');
37 assertEqual(params, expected);
38
39 params = xunit.utils.parseFloatAssertInputs(1, 2, 'absolute');
40 expected.ToleranceType = 'absolute';
41 assertEqual(params, expected);
42
43 params = xunit.utils.parseFloatAssertInputs(1, 2, 'message');
44 expected.ToleranceType = 'relative';
45 expected.Message = 'message';
46 assertEqual(params, expected);
47
48 %===============================================================================
49 function test_fourInputs()
50 expected.A = 1;
51 expected.B = 2;
52 expected.ToleranceType = 'absolute';
53 expected.Tolerance = sqrt(eps);
54 expected.FloorTolerance = sqrt(eps);
55 expected.Message = '';
56
57 params = xunit.utils.parseFloatAssertInputs(1, 2, 'absolute', 0.1);
58 expected.Tolerance = 0.1;
59 assertEqual(params, expected);
60
61 params = xunit.utils.parseFloatAssertInputs(1, 2, 'absolute', 'message');
62 expected.Tolerance = sqrt(eps);
63 expected.Message = 'message';
64 assertEqual(params, expected);
65
66 %===============================================================================
67 function test_fiveInputs()
68 expected.A = 1;
69 expected.B = 2;
70 expected.ToleranceType = 'absolute';
71 expected.Tolerance = 0.1;
72 expected.FloorTolerance = 0.05;
73 expected.Message = '';
74
75 params = xunit.utils.parseFloatAssertInputs(1, 2, 'absolute', 0.1, 0.05);
76 assertEqual(params, expected);
77
78 params = xunit.utils.parseFloatAssertInputs(1, 2, 'absolute', 0.1, 'message');
79 expected.FloorTolerance = sqrt(eps);
80 expected.Message = 'message';
81 assertEqual(params, expected);
82
83 %===============================================================================
84 function test_sixInputs()
85 expected.A = 1;
86 expected.B = 2;
87 expected.ToleranceType = 'absolute';
88 expected.Tolerance = 0.1;
89 expected.FloorTolerance = 0.05;
90 expected.Message = 'message';
91
92 params = xunit.utils.parseFloatAssertInputs(1, 2, 'absolute', 0.1, 0.05, 'message');
93 assertEqual(params, expected);
94
95 %===============================================================================
96 function test_twoSingleInputs()
97 expected.A = 1;
98 expected.B = 2;
99 expected.ToleranceType = 'relative';
100 expected.Tolerance = sqrt(eps('single'));
101 expected.FloorTolerance = sqrt(eps('single'));
102 expected.Message = '';
103
104 params = xunit.utils.parseFloatAssertInputs(single(1), single(2));
105 assertEqual(params, expected);
106
107 %===============================================================================
108 function test_twoSingleAndDoubleInputs()
109 expected.A = 1;
110 expected.B = 2;
111 expected.ToleranceType = 'relative';
112 expected.Tolerance = sqrt(eps('single'));
113 expected.FloorTolerance = sqrt(eps('single'));
114 expected.Message = '';
115
116 params = xunit.utils.parseFloatAssertInputs(single(1), double(2));
117 assertEqual(params, expected);
118
119
File data_analysis/unittests/matlab_xunit_3_1_1/tests/test_stringToCellArray.m deleted (index 8a14a03..0000000)
1 function test_suite = test_stringToCellArray
2 %test_stringToCellArray Unit test for stringToCellArray
3
4 % Steven L. Eddins
5 % Copyright 2009 The MathWorks, Inc.
6
7 initTestSuite;
8
9 function test_happyCase
10 s = sprintf('Hello\nWorld');
11 assertEqual(xunit.utils.stringToCellArray(s), {'Hello' ; 'World'});
12
13 function test_emptyInput
14 assertEqual(xunit.utils.stringToCellArray(''), cell(0, 1));
15
16 function test_spacesInFront
17 s = sprintf(' Hello\n World\n');
18 assertEqual(xunit.utils.stringToCellArray(s), {' Hello' ; ' World'});
19
20 function test_spacesAtEnd
21 s = sprintf('Hello \nWorld ');
22 assertEqual(xunit.utils.stringToCellArray(s), {'Hello ' ; 'World '});
23
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/Contents.m deleted (index 7b0f017..0000000)
1 % UTILS Utility package for MATLAB xUnit Test Framework
2 %
3 % Array Comparison
4 % compareFloats - Compare floating-point arrays using tolerance
5 %
6 % Test Case Discovery Functions
7 % isTestCaseSubclass - True for name of TestCase subclass
8 %
9 % String Functions
10 % arrayToString - Convert array to string for display
11 % comparisonMessage - Assertion message string for comparing two arrays
12 % containsRegexp - True if string contains regular expression
13 % isSetUpString - True for string that looks like a setup function
14 % isTearDownString - True for string that looks like teardown function
15 % isTestString - True for string that looks like a test function
16 % stringToCellArray - Convert string to cell array of strings
17 %
18 % Miscellaneous Functions
19 % generateDoc - Publish test scripts in mtest/doc
20 % parseFloatAssertInputs - Common input-parsing logic for several functions
21
22 % Steven L. Eddins
23 % Copyright 2008-2009 The MathWorks, Inc.
24
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/arrayToString.m deleted (index 87bad51..0000000)
1 function s = arrayToString(A)
2 %arrayToString Convert array to string for display.
3 % S = arrayToString(A) converts the array A into a string suitable for
4 % including in assertion messages. Small arrays are converted using disp(A).
5 % Large arrays are displayed similar to the way structure field values display
6 % using disp.
7
8 % Steven L. Eddins
9 % Copyright 2009 The MathWorks, Inc.
10
11 if isTooBigToDisp(A)
12 s = dispAsStructField(A);
13 else
14 s = dispAsArray(A);
15 end
16
17 %===============================================================================
18 function tf = isTooBigToDisp(A)
19 % Use a heuristic to determine if the array is to convert to a string using
20 % disp. The heuristic is based on the size of the array in bytes, as reported
21 % by the whos function.
22
23 whos_output = whos('A');
24 byte_threshold = 1000;
25 tf = whos_output.bytes > byte_threshold;
26
27 %===============================================================================
28 function s = dispAsArray(A)
29 % Convert A to a string using disp. Remove leading and trailing blank lines.
30
31 s = evalc('disp(A)');
32 if isempty(s)
33 % disp displays nothing for some kinds of empty arrays.
34 s = dispAsStructField(A);
35 else
36 s = postprocessDisp(s);
37 end
38
39 %===============================================================================
40 function s = dispAsStructField(A)
41 % Convert A to a string using structure field display.
42
43 b.A = A;
44 s = evalc('disp(b)');
45 s = postprocessStructDisp(s);
46
47 %===============================================================================
48 function out = postprocessDisp(in)
49 % Remove leading and trailing blank lines from input string. Don't include a
50 % newline at the end.
51
52 lines = xunit.utils.stringToCellArray(in);
53
54 % Remove leading blank lines.
55 lines = removeLeadingBlankLines(lines);
56
57 % Remove trailing blank lines.
58 while ~isempty(lines) && isBlankLine(lines{end})
59 lines(end) = [];
60 end
61
62 % Convert cell of strings to single string with newlines. Don't put a newline
63 % at the end.
64 out = sprintf('%s\n', lines{1:end-1});
65 out = [out, lines{end}];
66
67 %===============================================================================
68 function out = postprocessStructDisp(in)
69 % Return the portion of the display string to the right of the colon in the
70 % output of the first structure field. Input is a string.
71
72 lines = xunit.utils.stringToCellArray(in);
73
74 % Remove leading blank lines
75 lines = removeLeadingBlankLines(lines);
76
77 line = lines{1};
78 idx = find(line == ':');
79 out = line((idx+2):end); % struct fields display with blank space following colon
80
81 %===============================================================================
82 function out = removeLeadingBlankLines(in)
83 % Input and output are cell arrays of strings.
84
85 out = in;
86 while ~isempty(out) && isBlankLine(out{1})
87 out(1) = [];
88 end
89
90 %===============================================================================
91 function tf = isBlankLine(line)
92 % Input is a string.
93
94 tf = all(isspace(line));
95
96
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/compareFloats.m deleted (index f4ec111..0000000)
1 function result = compareFloats(varargin)
2 %compareFloats Compare floating-point arrays using tolerance.
3 % result = compareFloats(A, B, compare_type, tol_type, tol, floor_tol)
4 % compares the floating-point arrays A and B using a tolerance. compare_type
5 % is either 'elementwise' or 'vector'. tol_type is either 'relative' or
6 % 'absolute'. tol and floor_tol are the scalar tolerance values.
7 %
8 % There are four different tolerance tests used, depending on the comparison
9 % type and the tolerance type:
10 %
11 % 1. Comparison type: 'elementwise' Tolerance type: 'relative'
12 %
13 % all( abs(A(:) - B(:)) <= tol * max(abs(A(:)), abs(B(:))) + floor_tol )
14 %
15 % 2. Comparison type: 'elementwise' Tolerance type: 'absolute'
16 %
17 % all( abs(A(:) - B(:) <= tol )
18 %
19 % 3. Comparison type: 'vector' Tolerance type: 'relative'
20 %
21 % norm(A(:) - B(:) <= tol * max(norm(A(:)), norm(B(:))) + floor_tol
22 %
23 % 4. Comparison type: 'vector' Tolerance type: 'absolute'
24 %
25 % norm(A(:) - B(:)) <= tol
26 %
27 % Note that floor_tol is not used when the tolerance type is 'absolute'.
28 %
29 % compare_type, tol_type, tol, and floor_tol are all optional inputs. The
30 % default value for compare_type is 'elementwise'. The default value for
31 % tol_type is 'relative'. If both A and B are double, then the default value
32 % for tol is sqrt(eps), and the default value for floor_tol is eps. If either
33 % A or B is single, then the default value for tol is sqrt(eps('single')), and
34 % the default value for floor_tol is eps('single').
35 %
36 % If A or B is complex, then the tolerance test is applied independently to
37 % the real and imaginary parts.
38 %
39 % For elementwise comparisons, compareFloats returns true for two elements
40 % that are both NaN, or for two infinite elements that have the same sign.
41 % For vector comparisons, compareFloats returns false if any input elements
42 % are infinite or NaN.
43
44 % Steven L. Eddins
45 % Copyright 2008-2009 The MathWorks, Inc.
46
47 if nargin >= 3
48 % compare_type specified. Grab it and then use parseFloatAssertInputs to
49 % process the remaining input arguments.
50 compare_type = varargin{3};
51 varargin(3) = [];
52 if isempty(strcmp(compare_type, {'elementwise', 'vector'}))
53 error('compareFloats:unrecognizedCompareType', ...
54 'COMPARE_TYPE must be ''elementwise'' or ''vector''.');
55 end
56 else
57 compare_type = 'elementwise';
58 end
59
60 params = xunit.utils.parseFloatAssertInputs(varargin{:});
61
62 A = params.A(:);
63 B = params.B(:);
64
65 switch compare_type
66 case 'elementwise'
67 magFcn = @abs;
68
69 case 'vector'
70 magFcn = @norm;
71
72 otherwise
73 error('compareFloats:unrecognizedCompareType', ...
74 'COMPARE_TYPE must be ''elementwise'' or ''vector''.');
75 end
76
77 switch params.ToleranceType
78 case 'relative'
79 coreCompareFcn = @(A, B) magFcn(A - B) <= ...
80 params.Tolerance * max(magFcn(A), magFcn(B)) + ...
81 params.FloorTolerance;
82
83 case 'absolute'
84 coreCompareFcn = @(A, B) magFcn(A - B) <= params.Tolerance;
85
86 otherwise
87 error('compareFloats:unrecognizedToleranceType', ...
88 'TOL_TYPE must be ''relative'' or ''absolute''.');
89 end
90
91 if strcmp(compare_type, 'elementwise')
92 compareFcn = @(A, B) ( coreCompareFcn(A, B) | bothNaN(A, B) | sameSignInfs(A, B) ) & ...
93 ~oppositeSignInfs(A, B) & ...
94 ~finiteAndInfinite(A, B);
95 else
96 compareFcn = @(A, B) coreCompareFcn(A, B) & ...
97 isfinite(magFcn(A)) & ...
98 isfinite(magFcn(B));
99 end
100
101 if isreal(A) && isreal(B)
102 result = compareFcn(A, B);
103 else
104 result = compareFcn(real(A), real(B)) & compareFcn(imag(A), imag(B));
105 end
106
107 result = all(result);
108
109 %===============================================================================
110 function out = bothNaN(A, B)
111
112 out = isnan(A) & isnan(B);
113
114 %===============================================================================
115 function out = oppositeSignInfs(A, B)
116
117 out = isinf(A) & isinf(B) & (sign(A) ~= sign(B));
118
119 %===============================================================================
120 function out = sameSignInfs(A, B)
121
122 out = isinf(A) & isinf(B) & (sign(A) == sign(B));
123
124 %===============================================================================
125 function out = finiteAndInfinite(A, B)
126
127 out = xor(isinf(A), isinf(B));
128
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/comparisonMessage.m deleted (index 68e9a52..0000000)
1 function msg = comparisonMessage(user_message, assertion_message, A, B)
2 %comparisonMessage Generate assertion message when comparing two arrays.
3 % msg = comparisonMessage(user_message, assertion_message, A, B) returns a
4 % string appropriate to use in a call to throw inside an assertion function
5 % that compares two arrays A and B.
6 %
7 % The string returned has the following form:
8 %
9 % <user_message>
10 % <assertion_message>
11 %
12 % First input:
13 % <string representation of value of A>
14 %
15 % Second input:
16 % <string representation of value of B>
17 %
18 % user_message can be the empty string, '', in which case user_message is
19 % skipped.
20
21 % Steven L. Eddins
22 % Copyright 2009 The MathWorks, Inc.
23
24 msg = sprintf('%s\n\n%s\n%s\n\n%s\n%s', ...
25 assertion_message, ...
26 'First input:', ...
27 xunit.utils.arrayToString(A), ...
28 'Second input:', ...
29 xunit.utils.arrayToString(B));
30
31 if ~isempty(user_message)
32 msg = sprintf('%s\n%s', user_message, msg);
33 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/containsRegexp.m deleted (index efbc51b..0000000)
1 function tf = containsRegexp(str, exp)
2 %containsRegexp True if string contains regular expression
3 % TF = containsRegexp(str, exp) returns true if the string str contains the
4 % regular expression exp. If str is a cell array of strings, then
5 % containsRegexp tests each string in the cell array, returning the results in
6 % a logical array with the same size as str.
7
8 % Steven L. Eddins
9 % Copyright 2008-2009 The MathWorks, Inc.
10
11 % Convert to canonical input form: A cell array of strings.
12 if ~iscell(str)
13 str = {str};
14 end
15
16 matches = regexp(str, exp);
17 tf = ~cellfun('isempty', matches);
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/generateDoc.m deleted (index 6a9959a..0000000)
1 function generateDoc
2 %generateDoc Publish the example scripts in the doc directory
3
4 % Steven L. Eddins
5 % Copyright 2008-2009 The MathWorks, Inc.
6
7 doc_dir = fullfile(fileparts(which('runtests')), '..', 'doc');
8 addpath(doc_dir);
9 cd(doc_dir)
10 mfiles = dir('*.m');
11 for k = 1:numel(mfiles)
12 publish(mfiles(k).name);
13 cd(doc_dir)
14 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/isAlmostEqual.m deleted (index 7ad4393..0000000)
1 function same = isAlmostEqual(A, B, reltol)
2 %isAlmostEqual Equality test using relative tolerance
3 % same = isAlmostEqual(A, B, reltol), for two floating-point arrays A and B,
4 % tests A and B for equality using the specified relative tolerance.
5 % isAlmostEqual returns true if the following relationship is satisfied for
6 % all values in A and B:
7 %
8 % abs(A - B) ./ max(abs(A), abs(B)) <= reltol
9 %
10 % same = isAlmostEqual(A, B) uses the following value for the relative
11 % tolerance:
12 %
13 % 100 * max(eps(class(A)), eps(class(B)))
14 %
15 % If either A or B is not a floating-point array, then isAlmostEqual returns
16 % the result of isequal(A, B).
17
18 % Steven L. Eddins
19 % Copyright 2008-2009 The MathWorks, Inc.
20
21 if ~isfloat(A) || ~isfloat(B)
22 same = isequal(A, B);
23 return
24 end
25
26 if nargin < 3
27 reltol = 100 * max(eps(class(A)), eps(class(B)));
28 end
29
30 if ~isequal(size(A), size(B))
31 same = false;
32 return
33 end
34
35 A = A(:);
36 B = B(:);
37
38 delta = abs(A - B) ./ max(max(abs(A), abs(B)), 1);
39
40 % Some floating-point values require special handling.
41 delta((A == 0) & (B == 0)) = 0;
42 delta(isnan(A) & isnan(B)) = 0;
43 delta((A == Inf) & (B == Inf)) = 0;
44 delta((A == -Inf) & (B == -Inf)) = 0;
45
46 same = all(delta <= reltol);
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/isSetUpString.m deleted (index e3204fb..0000000)
1 function tf = isSetUpString(str)
2 %isSetUpString True if string looks like the name of a setup function
3 % tf = isSetUpString(str) returns true if the string str looks like the name
4 % of a setup function. If str is a cell array of strings, then isSetUpString
5 % tests each string in the cell array, returning the results in a logical
6 % array with the same size as str.
7
8 % Steven L. Eddins
9 % Copyright 2008-2009 The MathWorks, Inc.
10
11 setup_exp = '^[sS]et[uU]p';
12 tf = xunit.utils.containsRegexp(str, setup_exp);
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/isTearDownString.m deleted (index 6077a81..0000000)
1 function tf = isTearDownString(str)
2 %isTearDownString True if string looks like the name of a teardown function
3 % tf = isTearDownString(str) returns true if the string str looks like the
4 % name of a teardown function. If str is a cell array of strings, then
5 % isTearDownString tests each string in the cell array, returning the results
6 % in a logical array with the same size as str.
7
8 % Steven L. Eddins
9 % Copyright 2008-2009 The MathWorks, Inc.
10
11 setup_exp = '^[tT]ear[dD]own';
12 tf = xunit.utils.containsRegexp(str, setup_exp);
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/isTestCaseSubclass.m deleted (index 4df0c7f..0000000)
1 function tf = isTestCaseSubclass(name)
2 %isTestCaseSubclass True for name of a TestCase subclass
3 % tf = isTestCaseSubclass(name) returns true if the string name is the name of
4 % a TestCase subclass on the MATLAB path.
5
6 % Steven L. Eddins
7 % Copyright 2008-2009 The MathWorks, Inc.
8
9 tf = false;
10
11 class_meta = meta.class.fromName(name);
12 if isempty(class_meta)
13 % Not the name of a class
14 return;
15 end
16
17 if strcmp(class_meta.Name, 'TestCase')
18 tf = true;
19 else
20 tf = isMetaTestCaseSubclass(class_meta);
21 end
22
23 function tf = isMetaTestCaseSubclass(class_meta)
24
25 tf = false;
26
27 if strcmp(class_meta.Name, 'TestCase')
28 tf = true;
29 else
30 % Invoke function recursively on parent classes.
31 super_classes = class_meta.SuperClasses;
32 for k = 1:numel(super_classes)
33 if isMetaTestCaseSubclass(super_classes{k})
34 tf = true;
35 break;
36 end
37 end
38 end
39
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/isTestString.m deleted (index e7053d4..0000000)
1 function tf = isTestString(str)
2 %isTestString True if string looks like the name of a test
3 % tf = isTestString(str) returns true if the string str looks like the name of
4 % a test. If str is a cell array of strings, then isTestString tests each
5 % string in the cell array, returning the results in a logical array with the
6 % same size as str.
7
8 % Steven L. Eddins
9 % Copyright 2008-2009 The MathWorks, Inc.
10
11 test_at_beginning = '^[tT]est';
12 test_at_end = '[tT]est$';
13
14 tf = xunit.utils.containsRegexp(str, test_at_beginning) | ...
15 xunit.utils.containsRegexp(str, test_at_end);
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/parseFloatAssertInputs.m deleted (index b36366e..0000000)
1 function params = parseFloatAssertInputs(varargin)
2 %parseFloatAssertInputs Parse inputs for floating-point assertion functions.
3 % params = parseFloatAssertInputs(varargin) parses the input arguments for
4 % assertElementsAlmostEqual, assertVectorsAlmostEqual, and compareFcn. It
5 % returns a parameter struct containing the fields:
6 %
7 % A B Message ToleranceType Tolerance FloorTolerance
8
9 % Steven L. Eddins
10 % Copyright 2008-2009 The MathWorks, Inc.
11
12 error(nargchk(2, 6, nargin, 'struct'));
13
14 params = struct('A', {[]}, 'B', {[]}, 'ToleranceType', {[]}, ...
15 'Tolerance', {[]}, 'FloorTolerance', {[]}, 'Message', {''});
16
17 % The first two input arguments are always A and B.
18 params.A = varargin{1};
19 params.B = varargin{2};
20 varargin(1:2) = [];
21
22 % If the last argument is a message string, process it and remove it from the list.
23 if (numel(varargin) >= 1) && ischar(varargin{end}) && ...
24 ~any(strcmp(varargin{end}, {'relative', 'absolute'}))
25 params.Message = varargin{end};
26 varargin(end) = [];
27 else
28 params.Message = '';
29 end
30
31 try
32 epsilon = max(eps(class(params.A)), eps(class(params.B)));
33 catch
34 epsilon = eps;
35 end
36
37 if numel(varargin) < 3
38 % floor_tol not specified; set default.
39 params.FloorTolerance = sqrt(epsilon);
40 else
41 params.FloorTolerance = varargin{3};
42 end
43
44 if numel(varargin) < 2
45 % tol not specified; set default.
46 params.Tolerance = sqrt(epsilon);
47 else
48 params.Tolerance = varargin{2};
49 end
50
51 if numel(varargin) < 1
52 % tol_type not specified; set default.
53 params.ToleranceType = 'relative';
54 else
55 params.ToleranceType = varargin{1};
56 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/+xunit/+utils/stringToCellArray.m deleted (index e2025aa..0000000)
1 function c = stringToCellArray(s)
2 %stringToCellArray Convert string with newlines to cell array of strings.
3 % C = stringToCellArray(S) converts the input string S to a cell array of
4 % strings, breaking up S at new lines.
5
6 % Steven L. Eddins
7 % Copyright 2009 The MathWorks, Inc.
8
9 if isempty(s)
10 c = cell(0, 1);
11 else
12 c = textscan(s, '%s', 'Delimiter', '\n', 'Whitespace', '');
13 c = c{1};
14 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/CommandWindowTestRunDisplay.m deleted (index 0167631..0000000)
1 classdef CommandWindowTestRunDisplay < TestRunDisplay
2 %CommandWindowTestRunDisplay Print test suite execution results to Command Window.
3 % CommandWindowTestRunDisplay is a subclass of TestRunMonitor. If a
4 % CommandWindowTestRunDisplay object is passed to the run method of a
5 % TestComponent, such as a TestSuite or a TestCase, it will print information
6 % to the Command Window as the test run proceeds.
7 %
8 % CommandWindowTestRunDisplay methods:
9 % testComponentStarted - Update Command Window display
10 % testComponentFinished - Update Command Window display
11 % testCaseFailure - Log test failure information
12 % testCaseError - Log test error information
13 %
14 % CommandWindowTestRunDisplay properties:
15 % TestCaseCount - Number of test cases executed
16 % Faults - Struct array of test fault info
17 %
18 % See also TestRunLogger, TestRunMonitor, TestSuite
19
20 % Steven L. Eddins
21 % Copyright 2008-2010 The MathWorks, Inc.
22
23 methods
24 function self = CommandWindowTestRunDisplay
25 self = self@TestRunDisplay(1);
26 end
27 end
28
29 end
30
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/Contents.m deleted (index ad13820..0000000)
1 % MATLAB xUnit Test Framework
2 % Version 3.1.1 (R2013a) 10-Jul-2013
3 %
4 % Running Unit Tests
5 % runtests - Run unit tests
6 %
7 % Writing Unit Tests
8 % assertElementsAlmostEqual - Assert floating-point array elements almost equal
9 % assertEqual - Assert that inputs are equal
10 % assertFilesEqual - Assert that two files have the same content
11 % assertExceptionThrown - Assert that specified exception is thrown
12 % assertFalse - Assert that input condition is false
13 % assertTrue - Assert that input condition is true
14 % assertVectorsAlmostEqual - Assert floating-point vectors almost equal in norm sense
15 % initTestSuite - Utility script used for subfunction-based tests
16 %
17 % Framework Classes
18 % CommandWindowTestRunDisplay - Print test suite results to command window
19 % FunctionHandleTestCase - Test case based on a function handle
20 % TestCase - Class defining interface for test cases
21 % TestCaseInDir - Test case requiring temporary directory change
22 % TestCaseWithAddPath - Test case requiring temporary path modification
23 % TestComponent - Abstract base class for TestCase and TestSuite
24 % TestComponentInDir - Test component requiring temporary directory change
25 % TestLogger - Collect data (silently) from running test suite
26 % TestRunDisplay - Print test suite execution results
27 % TestRunMonitor - Abstract base class for monitoring test suite
28 % TestSuite - Collection of TestComponent objects
29 % TestSuiteInDir - Test suite requiring temporary directory change
30 % %VerboseTestRunDisplay - Print test suite execution results
31
32 % Steven L. Eddins
33 % Copyright 2008-2013 The MathWorks, Inc.
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/FunctionHandleTestCase.m deleted (index 7f8028c..0000000)
1 classdef FunctionHandleTestCase < TestCase
2 %FunctionHandleTestCase Test case based on a function handle
3 % FunctionHandleTestCase is a TestCase subclass. It defines a test case object
4 % that executes by running a function handle instead of by running a method of
5 % the TestCase subclass.
6 %
7 % FunctionHandleTestCase methods:
8 % FunctionHandleTestCase - Constructor
9 % runTestCase - Run function handle test
10 % setUp - Run test-fixture setup function
11 % tearDown - Run test-fixture teardown function
12 %
13 % FunctionHandleTestCase properties:
14 % TestFcn - Function handle of test function
15 % SetupFcn - Function handle of setup function
16 % TeardownFcn - Function handle of teardown function
17 % TestData - Data needed by test function or teardown function
18 %
19 % See also TestCase, TestSuite
20
21 % Steven L. Eddins
22 % Copyright 2008-2009 The MathWorks, Inc.
23
24 properties (SetAccess = protected, GetAccess = protected, Hidden = true)
25 %TestFcn - Function handle of test function
26 % If SetupFcn has one or more output arguments, then TestFcn is
27 % called with this syntax:
28 %
29 % TestFcn(data)
30 %
31 % where data is the return value from SetupFcn. Otherwise, TestFcn is
32 % called with no input and no output arguments.
33 TestFcn;
34
35 %SetupFcn - Function handle of setup function
36 % If SetupFcn has one or more output arguments, then SetupFcn is
37 % called with this syntax:
38 %
39 % data = SetupFcn()
40 %
41 % and data will be saved in the TestData property. Otherwise, SetupFcn
42 % is called with no input and no output arguments.
43 SetupFcn;
44
45 %TeardownFcn - Function handle of teardown function
46 % If SetupFcn has one or more output arguments, then TeardownFcn is
47 % called with this syntax:
48 %
49 % TeardownFcn(data)
50 %
51 % were data is the return value from SetupFcn. Otherwise, TeardownFcn
52 % is called with no input and no output arguments.
53 TeardownFcn;
54
55 %TestData - Data needed by test function or teardown function.
56 TestData;
57 end
58
59 methods
60 function self = FunctionHandleTestCase(testFcn, setupFcn, teardownFcn)
61 %FunctionHandleTestCase Constructor
62 % FunctionHandleTestCase(testFcn, setupFcn, teardownFcn) creates a
63 % TestCase object that executes by running the function handle
64 % TestFcn. setupFcn is a function handle that will be executed
65 % before testFcn, and teardownFcn is a function handle that will
66 % be executed after TestFcn. Either setupFcn or teardownFcn can
67 % be empty.
68 %
69 % If setupFcn is function handle that has one output argument,
70 % then the three test functions will be called using these
71 % syntaxes:
72 %
73 % testData = setupFcn();
74 % testFcn(testData);
75 % teardownFcn(testData);
76 %
77 % Otherwise, the three test functions are all called with no input
78 % arguments:
79 %
80 % setupFcn();
81 % TestFcn();
82 % teardownFcn();
83
84 % Call the base class constructor. Give it the name of the
85 % FunctionHandleTestCase method that executes TestFcn.
86 self = self@TestCase('runTestCase');
87
88 self.TestFcn = testFcn;
89 self.SetupFcn = setupFcn;
90 self.TeardownFcn = teardownFcn;
91
92 % Determine the name and M-file location of the function handle.
93 functionHandleInfo = functions(testFcn);
94 self.Name = functionHandleInfo.function;
95 if strcmp(functionHandleInfo.type, 'anonymous')
96 % Anonymous function handles don't have an M-file location.
97 self.Location = '';
98 else
99 self.Location = functionHandleInfo.file;
100 end
101 end
102
103 function runTestCase(self)
104 %runTestCase Run function handle test
105 % test_case.run() calls the test function handle. If a nonempty
106 % SetupFcn was provided and it has at least one output argument,
107 % pass self.TestData to the test function. Otherwise, call the
108 % test function with no input arguments.
109 if ~isempty(self.SetupFcn) && nargout(self.SetupFcn) > 0
110 self.TestFcn(self.TestData);
111 else
112 self.TestFcn();
113 end
114 end
115
116 function setUp(self)
117 %setUp Run test-fixture setup function
118 % If a nonempty SetupFcn was provided, run it. If the SetupFcn
119 % has at least one output argument, capture the first output
120 % argument in instance data (TestData).
121 if ~isempty(self.SetupFcn)
122 if nargout(self.SetupFcn) > 0
123 if nargout(self.SetupFcn) > 1
124 message = sprintf(['A test fixture setup function returns more than one output argument. ', ...
125 'The test harness only calls the setup function with one output argument. ', ...
126 'Return a struct or a cell array from your setup function if you need to bundle several parts together.', ...
127 '\nTest name: %s\nTest location: %s'], ...
128 self.Name, self.Location);
129 warning('xunit:FunctionHandleTestCase:TooManySetupOutputs', ...
130 '%s', message);
131 end
132 self.TestData = self.SetupFcn();
133 else
134 self.SetupFcn();
135 end
136 end
137 end
138
139 function tearDown(self)
140 %tearDown Run test-fixture teardown function
141 % If a nonempty TeardownFcn was provided, run it. If there is
142 % TestData (the output of the SetupFcn), then pass it to
143 % TeardownFcn. Otherwise, call TeardownFcn with no input
144 % arguments.
145 if ~isempty(self.TeardownFcn)
146 if ~isempty(self.SetupFcn) && (nargout(self.SetupFcn) > 0)
147 self.TeardownFcn(self.TestData);
148 else
149 self.TeardownFcn();
150 end
151 end
152 end
153 end
154 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestCase.m deleted (index 8b09ff8..0000000)
1 %TestCase Class defining interface for test cases
2 % The TestCase class defines an individual test case.
3 %
4 % Normally a test writer will create their own test class that is a subclass
5 % of TestCase. Each instance of the TestCase subclass that gets created will
6 % be associated with a single test method.
7 %
8 % If a test fixture is needed, override the setUp() and tearDown() methods.
9 %
10 % TestSuite(subclass_name), where subclass_name is the name of a TestCase
11 % subclass, creates a test suite containing one TestCase instance per test
12 % method contained in the subclass.
13 %
14 % A simpler test-writing alternative to use subfunction-based M-file tests.
15 % See the MATLAB xUnit documentation.
16 %
17 % TestCase methods:
18 % TestCase - Constructor
19 % run - Execute the test case
20 %
21 % TestCase properties:
22 % Location - Location of M-file containing the test case
23 % Name - Name of test case
24 %
25 % See also TestComponent, TestSuite
26
27 % Steven L. Eddins
28 % Copyright 2008-2010 The MathWorks, Inc.
29
30 classdef TestCase < TestComponent
31
32 properties
33 MethodName
34 end
35
36 methods
37 function self = TestCase(testMethod)
38 %TestCase Constructor
39 % TestCase(methodName) constructs a TestCase object using the
40 % specified testMethod (a string).
41
42 self.MethodName = testMethod;
43 self.Name = testMethod;
44 self.Location = which(class(self));
45 end
46
47 function did_pass = run(self, monitor)
48 %run Execute the test case
49 % test_case.run(monitor) calls the TestCase object's setUp()
50 % method, then the test method, then the tearDown() method.
51 % observer is a TestRunObserver object. The testStarted(),
52 % testFailure(), testError(), and testFinished() methods of
53 % observer are called at the appropriate times. monitor is a
54 % TestRunMonitor object. Typically it is either a TestRunLogger
55 % subclass or a CommandWindowTestRunDisplay subclass.
56 %
57 % test_case.run() automatically uses a
58 % CommandWindowTestRunDisplay object in order to print test
59 % suite execution information to the Command Window.
60
61 if nargin < 2
62 monitor = CommandWindowTestRunDisplay();
63 end
64
65 did_pass = true;
66 monitor.testComponentStarted(self);
67
68 try
69 self.setUp();
70 f = str2func(self.MethodName);
71
72 try
73 % Call the test method.
74 f(self);
75 catch failureException
76 monitor.testCaseFailure(self, failureException);
77 did_pass = false;
78 end
79
80 self.tearDown();
81
82 catch errorException
83 monitor.testCaseError(self, errorException);
84 did_pass = false;
85 end
86
87 monitor.testComponentFinished(self, did_pass);
88 end
89
90 function num = numTestCases(self)
91 num = 1;
92 end
93
94 function print(self, numLeadingBlanks)
95 if nargin < 2
96 numLeadingBlanks = 0;
97 end
98 fprintf('%s%s\n', blanks(numLeadingBlanks), self.Name);
99 end
100
101 end
102
103 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestCaseInDir.m deleted (index 8c80f2a..0000000)
1 %TestCaseInDir Test case requiring temporary directory change
2 % The TestCaseInDir class defines a test case that has to be run by first
3 % changing to a specified directory.
4 %
5 % The setUp method adds the starting directory to the path and then uses cd to
6 % change into the specified directory. The tearDown method restores the
7 % original path and directory.
8 %
9 % TestCaseInDir is used by MATLAB xUnit's own test suite in order to test itself.
10 %
11 % TestCaseInDir methods:
12 % TestCaseInDir - Constructor
13 %
14 % See also TestCase, TestCaseWithAddPath, TestComponent
15
16 % Steven L. Eddins
17 % Copyright 2008-2009 The MathWorks, Inc.
18
19 classdef TestCaseInDir < TestCase & TestComponentInDir
20
21 methods
22 function self = TestCaseInDir(methodName, testDirectory)
23 %TestCaseInDir Constructor
24 % TestCaseInDir(testName, testDirectory) constructs a test case
25 % using the specified name and located in the specified directory.
26 self = self@TestCase(methodName);
27 self = self@TestComponentInDir(testDirectory);
28 end
29 end
30 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestCaseWithAddPath.m deleted (index 0f0e9f6..0000000)
1 %TestCaseInDir Test case requiring temporary path modification
2 % The TestCaseInDir class defines a test case that has to be run by first
3 % adding a specific directory to the path.
4 %
5 % The setUp method adds the directory to the path, and the tearDown method
6 % restores the original path.
7 %
8 % TestCaseWithAddPath is used by MATLAB xUnit's own test suite in order to test
9 % itself.
10 %
11 % TestCaseWithAddPath methods:
12 % TestCaseWithAddPath - Constructor
13 % setUp - Add test directory to MATLAB path
14 % tearDown - Restore original MATLAB path
15 %
16 % See also TestCase, TestCaseInDir
17
18 % Steven L. Eddins
19 % Copyright 2008-2009 The MathWorks, Inc.
20
21 classdef TestCaseWithAddPath < TestCase
22 properties (SetAccess = private, GetAccess = private)
23 %TestDirectory - Directory to be added to the path
24 TestDirectory
25
26 %OriginalPath - Path prior to adding the test directory
27 OriginalPath
28 end
29
30 methods
31 function self = TestCaseWithAddPath(methodName, testDirectory)
32 %TestCaseInDir Constructor
33 % TestCaseInDir(testName, testDirectory) constructs a test case
34 % using the specified name and located in the specified directory.
35 self = self@TestCase(methodName);
36 self.TestDirectory = testDirectory;
37 end
38
39 function setUp(self)
40 %setUp Add test directory to MATLAB path.
41 % test_case.setUp() saves the current path in the OriginalPath
42 % property and then adds the TestDirectory to the MATLAB path.
43 self.OriginalPath = path;
44 addpath(self.TestDirectory);
45 end
46
47 function tearDown(self)
48 %tearDown Restore original MATLAB path
49 % test_case.tearDown() restores the saved MATLAB path.
50 path(self.OriginalPath);
51 end
52 end
53 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestComponent.m deleted (index e68b5b5..0000000)
1 classdef TestComponent < handle
2 %TestComponent Abstract base class for TestCase and TestSuite
3 %
4 % TestComponent methods:
5 % run - Run all test cases in test component
6 % print - Display summary of test component to Command Window
7 % numTestCases - Number of test cases in test component
8 % setUp - Initialize test fixture
9 % tearDown - Clean up text fixture
10 %
11 % TestComponent properties:
12 % Name - Name of test component
13 % Location - Directory where test component is defined
14 %
15 % See TestCase, TestSuite
16
17 % Steven L. Eddins
18 % Copyright 2008-2009 The MathWorks, Inc.
19
20 properties
21 Name = '';
22 Location = '';
23 end
24
25 properties (Access = 'protected')
26 PrintIndentationSize = 4
27 end
28
29 methods (Abstract)
30 print()
31 %print Display summary of test component to Command Window
32 % obj.print() displays information about the test component to the
33 % Command Window.
34
35 run()
36 %run Execute test cases
37 % obj.run() executes all the test cases in the test component
38
39 numTestCases()
40 %numTestCases Number of test cases in test component
41 end
42
43 methods
44 function setUp(self)
45 %setUp Set up test fixture
46 % test_component.setUp() is called at the beginning of the run()
47 % method. Test writers can override setUp if necessary to
48 % initialize a test fixture.
49 end
50
51 function tearDown(self)
52 %tearDown Tear down test fixture
53 % test_component.tearDown() is at the end of the method. Test
54 % writers can override tearDown if necessary to clean up a test
55 % fixture.
56 end
57
58 end
59 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestComponentInDir.m deleted (index d1193c6..0000000)
1 %TestComponentInDir Test component requiring temporary directory change
2 % The TestComponentInDir class defines a test component that has to be run by
3 % first changing to a specified directory.
4 %
5 % The setUp method adds the starting directory to the path and then uses cd to
6 % change into the specified directory. The tearDown method restores the
7 % original path and directory.
8 %
9 % TestComponentInDir methods:
10 % TestComponentInDir - Constructor
11 % setUp - Add test directory to MATLAB path
12 % tearDown - Restore original MATLAB path
13 %
14 % See also TestComponent
15
16 % Steven L. Eddins
17 % Copyright 2008-2009 The MathWorks, Inc.
18
19 classdef TestComponentInDir < TestComponent
20 properties (SetAccess = private, GetAccess = protected)
21 %TestDirectory - Directory to change to in the test fixture
22 TestDirectory
23
24 %OriginalPath - Path prior to adding the starting directory
25 OriginalPath
26
27 %OriginalDirectory - Starting directory
28 OriginalDirectory
29 end
30
31 methods
32 function self = TestComponentInDir(testDirectory)
33 %TestCaseInDir Constructor
34 % TestCaseInDir(testName, testDirectory) constructs a test case
35 % using the specified name and located in the specified directory.
36 self.TestDirectory = testDirectory;
37 end
38
39 function setUp(self)
40 %setUp Add test directory to MATLAB path
41 % test_case.setUp() saves the current directory in the
42 % OriginalDirectory property, saves the current path in the
43 % OriginalPath property, and then uses cd to change into the test
44 % directory.
45 self.OriginalDirectory = pwd;
46 self.OriginalPath = path;
47 addpath(pwd);
48 cd(self.TestDirectory);
49 end
50
51 function tearDown(self)
52 %tearDown Restore original MATLAB path and directory
53 % test_case.tearDown() restores the original path and directory.
54 cd(self.OriginalDirectory);
55 path(self.OriginalPath);
56 end
57 end
58 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestRunDisplay.m deleted (index 127fcc6..0000000)
1 classdef TestRunDisplay < TestRunMonitor
2 %TestRunDisplay Print test suite execution results.
3 % TestRunDisplay is a subclass of TestRunMonitor. If a TestRunDisplay
4 % object is passed to the run method of a TestComponent, such as a
5 % TestSuite or a TestCase, it will print information to the Command
6 % Window (or specified file handle) as the test run proceeds.
7 %
8 % TestRunDisplay methods:
9 % testComponentStarted - Update Command Window display
10 % testComponentFinished - Update Command Window display
11 % testCaseFailure - Log test failure information
12 % testCaseError - Log test error information
13 %
14 % TestRunDisplay properties:
15 % TestCaseCount - Number of test cases executed
16 % Faults - Struct array of test fault info
17 %
18 % See also TestRunLogger, TestRunMonitor, TestSuite
19
20 % Steven L. Eddins
21 % Copyright 2008-2010 The MathWorks, Inc.
22
23 properties (SetAccess = private)
24 %TestCaseCount - Number of test cases executed
25 TestCaseCount
26
27 %Faults - Struct array of test fault info
28 % Faults is a struct array with these fields:
29 % Type - either 'failure' or 'error'
30 % TestCase - the TestCase object that suffered the fault
31 % Exception - the MException thrown when the fault occurred
32 Faults = struct('Type', {}, 'TestCase', {}, 'Exception', {});
33
34 end
35
36 properties (SetAccess = private, GetAccess = private)
37 %InitialTic - Out of tic at beginning of test run
38 InitialTic
39
40 %InitialComponent First test component executed
41 % InitialComponent is set to the first test component executed in the
42 % test run. This component is saved so that the end of the test run
43 % can be identified.
44 InitialComponent = []
45
46 end
47
48 properties (Access = protected)
49 %FileHandle - Handle used by fprintf for displaying results.
50 % Default value of 1 displays to Command Window.
51 FileHandle = 1
52 end
53
54
55 methods
56 function self = TestRunDisplay(output)
57 if nargin > 0
58 if ischar(output)
59 self.FileHandle = fopen(output, 'w');
60 if self.FileHandle < 0
61 error('xunit:TestRunDisplay:FileOpenError', ...
62 'Could not open file "%s" for writing.', ...
63 filename);
64 end
65 else
66 self.FileHandle = output;
67 end
68 end
69 end
70
71 function testComponentStarted(self, component)
72 %testComponentStarted Update Command Window display
73 % If the InitialComponent property is not yet set,
74 % obj.testComponentStarted(component) sets the property and calls
75 % obj.testRunStarted(component).
76
77 if isempty(self.InitialComponent)
78 self.InitialComponent = component;
79 self.testRunStarted(component);
80 end
81 end
82
83 function testComponentFinished(self, component, did_pass)
84 %testComponentFinished Update Command Window display
85 % If component is a TestCase object, then
86 % obj.testComponentFinished(component, did_pass) prints pass/fail
87 % information to the Command Window.
88 %
89 % If component is the InitialComponent, then
90 % obj.testRunFinished(did_pass) is called.
91
92 if isa(component, 'TestCase')
93 self.TestCaseCount = self.TestCaseCount + 1;
94 if did_pass
95 fprintf(self.FileHandle, '.');
96 else
97 fprintf(self.FileHandle, 'F');
98 end
99 line_length = 20;
100 if mod(self.TestCaseCount, line_length) == 0
101 fprintf(self.FileHandle, '\n');
102 end
103 end
104
105 if isequal(component, self.InitialComponent)
106 self.testRunFinished(did_pass);
107 end
108 end
109
110 function testCaseFailure(self, test_case, failure_exception)
111 %testCaseFailure Log test failure information
112 % obj.testCaseFailure(test_case, failure_exception) logs the test
113 % case failure information.
114
115 self.logFault('failure', test_case, ...
116 failure_exception);
117 end
118
119 function testCaseError(self, test_case, error_exception)
120 %testCaseError Log test error information
121 % obj.testCaseError(test_case, error_exception) logs the test
122 % case error information.
123
124 self.logFault('error', test_case, ...
125 error_exception);
126 end
127
128 end
129
130 methods (Access = protected)
131 function testRunStarted(self, component)
132 %testRunStarted Update Command Window display
133 % obj.testRunStarted(component) displays information about the test
134 % run to the Command Window.
135
136 self.InitialTic = tic;
137 self.TestCaseCount = 0;
138 num_cases = component.numTestCases();
139 if num_cases == 1
140 str = 'case';
141 else
142 str = 'cases';
143 end
144 fprintf(self.FileHandle, 'Starting test run with %d test %s.\n', ...
145 num_cases, str);
146 end
147
148 function testRunFinished(self, did_pass)
149 %testRunFinished Update Command Window display
150 % obj.testRunFinished(component) displays information about the test
151 % run results, including any test failures, to the Command Window.
152
153 if did_pass
154 result = 'PASSED';
155 else
156 result = 'FAILED';
157 end
158
159 fprintf(self.FileHandle, '\n%s in %.3f seconds.\n', result, toc(self.InitialTic));
160
161 self.displayFaults();
162 end
163
164
165
166 function logFault(self, type, test_case, exception)
167 %logFault Log test fault information
168 % obj.logFault(type, test_case, exception) logs test fault
169 % information. type is either 'failure' or 'error'. test_case is a
170 % TestCase object. exception is an MException object.
171
172 self.Faults(end + 1).Type = type;
173 self.Faults(end).TestCase = test_case;
174 self.Faults(end).Exception = exception;
175 end
176
177 function displayFaults(self)
178 %displayFaults Display test fault info to Command Window
179 % obj.displayFaults() displays a summary of each test failure and
180 % test error to the command window.
181 for k = 1:numel(self.Faults)
182 faultData = self.Faults(k);
183 if strcmp(faultData.Type, 'failure')
184 str = 'Failure';
185 else
186 str = 'Error';
187 end
188 fprintf(self.FileHandle, '\n===== Test Case %s =====\nLocation: %s\nName: %s\n\n', str, ...
189 faultData.TestCase.Location, faultData.TestCase.Name);
190 displayStack(filterStack(faultData.Exception.stack), ...
191 self.FileHandle);
192 fprintf(self.FileHandle, '\n%s\n', faultData.Exception.message);
193
194 fprintf(self.FileHandle, '\n');
195 end
196 end
197
198 end
199
200 end
201
202 function displayStack(stack, file_handle)
203 %displayStack Display stack trace from MException instance
204 % displayStack(stack) prints information about an exception stack to the
205 % command window.
206
207 for k = 1:numel(stack)
208 filename = stack(k).file;
209 linenumber = stack(k).line;
210 linux_shell=true;
211 if linux_shell
212 fprintf(file_handle, '%s at line %d\n', filename, linenumber);
213 else
214 href = sprintf('matlab: opentoline(''%s'',%d)', filename, linenumber);
215 fprintf(file_handle, '%s at <a href="%s">line %d</a>\n', filename, href, linenumber);
216 end
217 end
218 end
219
220 function new_stack = filterStack(stack)
221 %filterStack Remove unmeaningful stack trace calls
222 % new_stack = filterStack(stack) removes from the input stack trace calls
223 % that are framework functions and methods that are not likely to be
224 % meaningful to the user.
225
226 % Testing stack traces follow this common pattern:
227 %
228 % 1. The first function call in the trace is often one of the assert functions
229 % in the framework directory. This is useful to see.
230 %
231 % 2. The next function calls are in the user-written test functions/methods and
232 % the user-written code under test. These calls are useful to see.
233 %
234 % 3. The final set of function calls are methods in the various framework
235 % classes. There are usually several of these calls, which clutter up the
236 % stack display without being that useful.
237 %
238 % The pattern above suggests the following stack filtering strategy: Once the
239 % stack trace has left the framework directory, do not follow the stack trace back
240 % into the framework directory.
241
242 mtest_directory = fileparts(which('runtests'));
243 last_keeper = numel(stack);
244 have_left_mtest_directory = false;
245 for k = 1:numel(stack)
246 directory = fileparts(stack(k).file);
247 if have_left_mtest_directory
248 if strcmp(directory, mtest_directory)
249 % Stack trace has reentered mtest directory.
250 last_keeper = k - 1;
251 break;
252 end
253 else
254 if ~strcmp(directory, mtest_directory)
255 have_left_mtest_directory = true;
256 end
257 end
258 end
259
260 new_stack = stack(1:last_keeper);
261
262 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestRunLogger.m deleted (index 2a82978..0000000)
1 %TestRunLogger Collect data (silently) from running test suite
2 % TestRunLogger is a subclass of TestRunMonitor uses to collect information
3 % from an executing test component (either a test case or a test suite).
4 % It maintains a record of event notifications received, as well as any test
5 % failures or test errors.
6 %
7 % TestRunLogger methods:
8 % testComponentStarted - Log test component started
9 % testComponentFinished - Log test component finished
10 % testCaseFailure - Log test case failure
11 % testCaseError - Log test case error
12 %
13 % TestRunLogger properties:
14 % Log - Cell array of test notification strings
15 % NumFailures - Number of test failures during execution
16 % NumErrors - Number of test errors during execution
17 % NumTestCases - Total number of test cases executed
18 % Faults - Struct array of test fault information
19 %
20 % See also CommandWindowTestRunDisplay, TestRunMonitor, TestSuite
21
22 % Steven L. Eddins
23 % Copyright 2008-2009 The MathWorks, Inc.
24
25 classdef TestRunLogger < TestRunMonitor
26
27 properties (SetAccess = protected)
28 %Log Cell array of test notification strings
29 % Test notification strings include 'TestRunStarted',
30 % 'TestRunFinished', 'TestComponentStarted', 'TestComponentFinished',
31 % 'TestCaseFailure', and 'TestCaseError'.
32 Log
33
34 %NumFailures Number of test failures during execution
35 NumFailures = 0
36
37 %NumErrors Number of test errors during execution
38 NumErrors = 0
39
40 %NumTestCases Total number of test cases executed
41 NumTestCases = 0
42
43 %Faults Struct array of test fault information
44 % Faults is a struct array with the fields Type, TestCase, and
45 % Exception. Type is either 'failure' or 'error'. TestCase is the
46 % test case object that triggered the fault. Exception is the
47 % MException object thrown during the fault.
48 Faults = struct('Type', {}, 'TestCase', {}, 'Exception', {});
49 end
50
51 properties (SetAccess = private, GetAccess = private)
52 InitialTestComponent = []
53 end
54
55 methods
56
57 function testComponentStarted(self, component)
58 if isempty(self.InitialTestComponent)
59 self.InitialTestComponent = component;
60 self.appendToLog('TestRunStarted');
61 end
62
63 self.appendToLog('TestComponentStarted');
64
65 if isa(component, 'TestCase')
66 self.NumTestCases = self.NumTestCases + 1;
67 end
68 end
69
70 function testComponentFinished(self, component, did_pass)
71 self.appendToLog('TestComponentFinished');
72
73 if isequal(component, self.InitialTestComponent)
74 self.appendToLog('TestRunFinished');
75 end
76 end
77
78 function testCaseFailure(self, test_case, failure_exception)
79 self.appendToLog('TestCaseFailure');
80 self.NumFailures = self.NumFailures + 1;
81 self.logFault('failure', test_case, ...
82 failure_exception);
83 end
84
85 function testCaseError(self, test_case, error_exception)
86 self.appendToLog('TestCaseError');
87 self.NumErrors = self.NumErrors + 1;
88 self.logFault('error', test_case, ...
89 error_exception);
90 end
91 end
92
93 methods (Access = private)
94 function appendToLog(self, item)
95 self.Log{end+1} = item;
96 end
97
98 function logFault(self, type, test_case, exception)
99 self.Faults(end + 1).Type = type;
100 self.Faults(end).TestCase = test_case;
101 self.Faults(end).Exception = exception;
102 end
103 end
104 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestRunMonitor.m deleted (index 4af7490..0000000)
1 %TestRunMonitor Abstract base class for monitoring a running test suite
2 % The abstract TestRunMonitor class defines an object that can observe and
3 % record the results of running a test suite. The run() method of a
4 % TestComponent object takes a TestRunMonitor object as an input argument.
5 %
6 % Different test suite logging or reporting functionality can be achieved by
7 % subclassing TestRunMonitor. For example, see the TestRunLogger and the
8 % CommandWindowTestRunDisplay classes.
9 %
10 % TestRunMonitor methods:
11 % TestRunMonitor - Constructor
12 % testComponentStarted - Called at beginning of test component run
13 % testComponentFinished - Called when test component run finished
14 % testCaseFailure - Called when a test case fails
15 % testCaseError - Called when a test case causes an error
16 %
17 % See also CommandWindowTestRunDisplay, TestRunLogger, TestCase, TestSuite
18
19 % Steven L. Eddins
20 % Copyright 2008-2009 The MathWorks, Inc.
21
22 classdef TestRunMonitor < handle
23
24 methods (Abstract)
25
26 testComponentStarted(self, component)
27
28 testComponentFinished(self, component, did_pass)
29
30 testCaseFailure(self, test_case, failure_exception)
31
32 testCaseError(self, test_case, error_exception)
33
34 end
35 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestSuite.m deleted (index a55d919..0000000)
1 %TestSuite Collection of TestComponent objects
2 % The TestSuite class defines a collection of TestComponent objects.
3 %
4 % TestSuite methods:
5 % TestSuite - Constructor
6 % add - Add test component to test suite
7 % print - Display test suite summary to Command Window
8 % run - Run the test suite
9 % keepMatchingTestCase - Keep only the named test component
10 % fromName - Construct test suite from directory or MATLAB function file name
11 % fromTestCaseClassName - Construct test suite from TestCase class name
12 % fromPackageName - Construct test suite from package name
13 % fromPwd - Construct test suite from present directory
14 %
15 % TestSuite properties:
16 % TestComponents - Cell array of TestComponent objects
17 %
18 % Examples
19 % --------
20 % Run all the test cases in the SampleTests1 class. Display test suite
21 % progress and a summary of results in the Command Window.
22 %
23 % TestSuite('SampleTests1').run()
24 %
25 % Construct a test suite from all test components found in the current
26 % directory.
27 %
28 % suite = TestSuite.fromPwd();
29 %
30 % Construct a test suite from all test components found in the package
31 % 'mytool.tests'. (Note that the "+" character at the beginning of the package
32 % folder name on disk is not part of the package name.)
33 %
34 % suite = TestSuite.fromPackageName('mytool.tests');
35 %
36 % Run all the test cases in the SampleTests class. Display no output to the
37 % Command Window. Upon completion, query the number of test failures and test
38 % errors.
39 %
40 % logger = TestRunLogger();
41 % TestSuite('SampleTests1').run(logger);
42 % numFailures = logger.NumFailures
43 % numErrors = logger.NumErrors
44 %
45 % See also CommandWindowTestRunDisplay, TestCase, TestComponent, TestRunLogger
46
47 % Steven L. Eddins
48 % Copyright 2008-2010 The MathWorks, Inc.
49
50 classdef TestSuite < TestComponent
51
52 properties (SetAccess = protected)
53 TestComponents = {};
54 end
55
56 methods
57
58 function self = TestSuite(name)
59 %TestSuite Constructor
60 % suite = TestSuite constructs an empty test suite. suite =
61 % TestSuite(name) constructs a test suite by searching for test
62 % cases defined in an M-file with the specified name.
63
64 if nargin >= 1
65 self = TestSuite.fromName(name);
66 end
67 end
68
69 function did_pass_out = run(self, monitor)
70 %run Execute test cases in test suite
71 % did_pass = suite.run() executes all test cases in the test
72 % suite, returning a logical value indicating whether or not all
73 % test cases passed.
74
75 if nargin < 2
76 monitor = CommandWindowTestRunDisplay();
77 end
78
79 monitor.testComponentStarted(self);
80 did_pass = true;
81
82 self.setUp();
83
84 for k = 1:numel(self.TestComponents)
85 this_component_passed = self.TestComponents{k}.run(monitor);
86 did_pass = did_pass && this_component_passed;
87 end
88
89 self.tearDown();
90
91 monitor.testComponentFinished(self, did_pass);
92
93 if nargout > 0
94 did_pass_out = did_pass;
95 end
96 end
97
98 function num = numTestCases(self)
99 %numTestCases Number of test cases in test suite
100
101 num = 0;
102 for k = 1:numel(self.TestComponents)
103 component_k = self.TestComponents{k};
104 num = num + component_k.numTestCases();
105 end
106 end
107
108 function print(self, numLeadingBlanks)
109 %print Display test suite summary to Command Window
110 % test_suite.print() displays a summary of the test suite to the
111 % Command Window.
112
113 if nargin < 2
114 numLeadingBlanks = 0;
115 end
116 fprintf('%s%s\n', blanks(numLeadingBlanks), self.Name);
117 for k = 1:numel(self.TestComponents)
118 self.TestComponents{k}.print(numLeadingBlanks + ...
119 self.PrintIndentationSize);
120 end
121 end
122
123 function add(self, component)
124 %add Add test component to test suite
125 % test_suite.add(component) adds the TestComponent object to the
126 % test suite.
127
128 if iscell(component)
129 self.TestComponents((1:numel(component)) + end) = component;
130 else
131 self.TestComponents{end + 1} = component;
132 end
133 end
134
135 function keepMatchingTestCase(self, name)
136 %keepMatchingTestCase Keep only the named test component
137 % test_suite.keepMatchingTestCase(name) keeps only the test
138 % component with a matching name and discards the rest.
139
140 idx = [];
141 for k = 1:numel(self.TestComponents)
142 if strcmp(self.TestComponents{k}.Name, name)
143 idx = k;
144 break;
145 end
146 end
147 if isempty(idx)
148 self.TestComponents = {};
149 else
150 self.TestComponents = self.TestComponents(idx);
151 end
152 end
153
154 end
155
156 methods (Static)
157 function suite = fromTestCaseClassName(class_name)
158 %fromTestCaseClassName Construct test suite from TestCase class name
159 % suite = TestSuite.fromTestCaseClassName(name) constructs a
160 % TestSuite object from the name of a TestCase subclass.
161
162 if ~xunit.utils.isTestCaseSubclass(class_name)
163 error('xunit:fromTestCaseClassName', ...
164 'Input string "%s" is not the name of a TestCase class.', ...
165 class_name);
166 end
167
168 suite = TestSuite;
169 suite.Name = class_name;
170 suite.Location = which(class_name);
171
172 methods = getClassMethods(class_name);
173 for k = 1:numel(methods)
174 if methodIsConstructor(methods{k})
175 continue
176 end
177
178 method_name = methods{k}.Name;
179 if xunit.utils.isTestString(method_name)
180 suite.add(feval(class_name, method_name));
181 end
182 end
183
184 end
185
186 function suite = fromName(name)
187 %fromName Construct test suite from M-file name
188 % test_suite = TestSuite.fromName(name) constructs a TestSuite
189 % object from an M-file with the given name. The name can be of a
190 % directory, a TestCase subclass, or an M-file containing a simple
191 % test or containing subfunction-based tests.
192 %
193 % Optionally, name can contain a colon (':') followed by filter
194 % string. The filter string is used to select a particular named
195 % test case. For example, TestSuite.fromName('MyTests:testA')
196 % constructs a TestSuite object containing only the test case
197 % named 'testA' found in the TestCase subclass MyTests.
198
199 if isdir(name)
200 suite = TestSuiteInDir(name);
201 suite.gatherTestCases();
202 return;
203 end
204
205 [name, filter_string] = strtok(name, ':');
206 if ~isempty(filter_string)
207 filter_string = filter_string(2:end);
208 end
209
210 if xunit.utils.isTestCaseSubclass(name)
211 suite = TestSuite.fromTestCaseClassName(name);
212
213 elseif ~isempty(meta.class.fromName(name))
214 % Input is the name of a class that is not a TestCase subclass.
215 % Return an empty test suite.
216 suite = TestSuite();
217 suite.Name = name;
218
219 elseif isPackage(name)
220 suite = TestSuite.fromPackageName(name);
221
222 else
223
224 try
225 if nargout(name) == 0
226 suite = TestSuite();
227 suite.Name = name;
228 suite.add(FunctionHandleTestCase(str2func(name), [], []));
229 suite.Location = which(name);
230
231 else
232 suite = feval(name);
233 if ~isa(suite, 'TestSuite')
234 error('Function did not return a TestSuite object.');
235 end
236 end
237
238 catch
239 % Ordinary function does not appear to contain tests.
240 % Return an empty test suite.
241 suite = TestSuite();
242 suite.Name = name;
243 end
244 end
245
246 if ~isempty(filter_string)
247 suite.keepMatchingTestCase(filter_string);
248 end
249 end
250
251 function test_suite = fromPwd()
252 %fromPwd Construct test suite from present directory
253 % test_suite = TestSuite.fromPwd() constructs a TestSuite object
254 % from all the test components in the present working directory.
255 % all TestCase subclasses will be found, as well as simple and
256 % subfunction-based M-file tests beginning with the string 'test'
257 % or 'Test'.
258
259 test_suite = TestSuite();
260 test_suite.Name = pwd;
261 test_suite.Location = pwd;
262
263 mfiles = dir(fullfile('.', '*.m'));
264 for k = 1:numel(mfiles)
265 [path, name] = fileparts(mfiles(k).name);
266 if xunit.utils.isTestCaseSubclass(name)
267 test_suite.add(TestSuite.fromTestCaseClassName(name));
268 elseif xunit.utils.isTestString(name)
269 suite_k = TestSuite.fromName(name);
270 if ~isempty(suite_k.TestComponents)
271 test_suite.add(suite_k);
272 end
273 end
274 end
275 end
276
277 function test_suite = fromPackageName(name)
278 %fromPackageName Construct test suite from package name
279 % test_suite = TestSuite.fromPackageName(name) constructs a
280 % TestSuite object from all the test components found in the
281 % specified package.
282
283 package_info = meta.package.fromName(name);
284 if isempty(package_info)
285 error('xunit:fromPackageName:invalidName', ...
286 'Input string "%s" is not the name of a package.', ...
287 name);
288 end
289 test_suite = TestSuite();
290 test_suite.Name = name;
291 test_suite.Location = 'Package';
292
293 for k = 1:numel(package_info.Packages)
294 pkg_name = package_info.Packages{k}.Name;
295 pkg_suite = TestSuite.fromPackageName(pkg_name);
296 if ~isempty(pkg_suite.TestComponents)
297 test_suite.add(TestSuite.fromPackageName(pkg_name));
298 end
299 end
300
301 class_names = cell(1, numel(package_info.Classes));
302 for k = 1:numel(package_info.Classes)
303 class_name = package_info.Classes{k}.Name;
304 class_names{k} = class_name;
305 if xunit.utils.isTestCaseSubclass(class_name)
306 test_suite.add(TestSuite.fromTestCaseClassName(class_name));
307 end
308 end
309
310 for k = 1:numel(package_info.Functions)
311 function_name = package_info.Functions{k}.Name;
312 if xunit.utils.isTestString(function_name)
313 full_function_name = [package_info.Name '.' package_info.Functions{k}.Name];
314 if ~ismember(full_function_name, class_names)
315 suite_k = TestSuite.fromName(full_function_name);
316 if ~isempty(suite_k.TestComponents)
317 test_suite.add(suite_k);
318 end
319 end
320 end
321 end
322 end
323 end
324 end
325
326 function tf = isPackage(name)
327 tf = ~isempty(meta.package.fromName(name));
328 end
329
330 function methods = getClassMethods(class_name)
331 class_meta = meta.class.fromName(class_name);
332 methods = class_meta.Methods;
333 end
334
335 function result = methodIsConstructor(method)
336 method_name = method.Name;
337 if ~isempty(method.DefiningClass.ContainingPackage)
338 method_name = [method.DefiningClass.ContainingPackage.Name, '.', ...
339 method_name];
340 end
341 result = strcmp(method_name, method.DefiningClass.Name);
342 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/TestSuiteInDir.m deleted (index e83ef5e..0000000)
1 %TestSuiteInDir Test suite requiring temporary directory change
2 % The TestSuiteInDir class defines a test suite that has to be run by first
3 % changing to a specified directory.
4 %
5 % The setUp method adds the starting directory to the path and then uses cd to
6 % change into the specified directory. The tearDown method restores the
7 % original path and directory.
8 %
9 % TestSuiteInDir methods:
10 % TestSuiteInDir - Constructor
11 % gatherTestCases - Add test cases found in the target directory
12 %
13 % See also TestSuite
14
15 % Steven L. Eddins
16 % Copyright 2009 The MathWorks, Inc.
17
18 classdef TestSuiteInDir < TestSuite & TestComponentInDir
19
20 methods
21 function self = TestSuiteInDir(testDirectory)
22 %TestCaseInDir Constructor
23 % TestCaseInDir(testName, testDirectory) constructs a test case
24 % using the specified name and located in the specified directory.
25 self = self@TestComponentInDir(testDirectory);
26
27 if strcmp(testDirectory, '.')
28 self.Name = pwd;
29 self.Location = pwd;
30 else
31 [pathstr, name] = fileparts(testDirectory);
32 self.Name = name;
33 self.Location = testDirectory;
34 end
35 end
36
37 function gatherTestCases(self)
38 %gatherTestCases Add test cases found in the target directory
39 % suite.gatherTestCases() automaticall finds all the test cases in
40 % the directory specified in the constructor call and adds them to
41 % the suite.
42 current_dir = pwd;
43 c = onCleanup(@() cd(current_dir));
44
45 cd(self.TestDirectory);
46 tmp = TestSuite.fromPwd();
47 self.TestComponents = tmp.TestComponents;
48 end
49 end
50 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/VerboseTestRunDisplay.m deleted (index 18e85b1..0000000)
1 classdef VerboseTestRunDisplay < TestRunDisplay
2 %VerboseTestRunDisplay Print test suite execution results.
3 % VerboseTestRunDisplay is a subclass of
4 % TestRunDisplay. It supports the -verbose option of runtests.
5 %
6 % Overriddent methods:
7 % testComponentStarted - Update Command Window display
8 % testComponentFinished - Update Command Window display
9 % testRunFinished - Update Command Window display at end of run
10 %
11 % See also TestRunDisplay, TestRunLogger, TestRunMonitor, TestSuite
12
13 % Steven L. Eddins
14 % Copyright 2010 The MathWorks, Inc.
15
16 properties (SetAccess = private, GetAccess = private)
17 TicStack = uint64([])
18 end
19
20 methods
21 function self = VerboseTestRunDisplay(output)
22 if nargin < 1
23 output = 1;
24 end
25
26 self = self@TestRunDisplay(output);
27 end
28
29 function testComponentStarted(self, component)
30 %testComponentStarted Update Command Window display
31
32 self.pushTic();
33
34 if ~isa(component, 'TestCase')
35 fprintf(self.FileHandle, '\n');
36 end
37
38 fprintf(self.FileHandle, '%s%s', self.indentationSpaces(), component.Name);
39
40 if ~isa(component, 'TestCase')
41 fprintf(self.FileHandle, '\n');
42 else
43 fprintf(self.FileHandle, ' %s ', self.leaderDots(component.Name));
44 end
45 end
46
47 function testComponentFinished(self, component, did_pass)
48 %testComponentFinished Update Command Window display
49
50 if ~isa(component, 'TestCase')
51 fprintf(self.FileHandle, '%s%s %s ', self.indentationSpaces(), component.Name, ...
52 self.leaderDots(component.Name));
53 end
54
55 component_run_time = toc(self.popTic());
56
57 if did_pass
58 fprintf(self.FileHandle, 'passed in %12.6f seconds\n', component_run_time);
59 else
60 fprintf(self.FileHandle, 'FAILED in %12.6f seconds\n', component_run_time);
61 end
62
63 if ~isa(component, 'TestCase')
64 fprintf(self.FileHandle, '\n');
65 end
66
67 if isempty(self.TicStack)
68 self.testRunFinished();
69 end
70
71 end
72
73 end
74
75 methods (Access = protected)
76 function testRunFinished(self)
77 %testRunFinished Update Command Window display
78 % obj.testRunFinished(component) displays information about the test
79 % run results, including any test failures, to the Command
80 % Window.
81
82 self.displayFaults();
83 end
84 end
85
86 methods (Access = private)
87 function pushTic(self)
88 self.TicStack(end+1) = tic;
89 end
90
91 function t1 = popTic(self)
92 t1 = self.TicStack(end);
93 self.TicStack(end) = [];
94 end
95
96 function str = indentationSpaces(self)
97 str = repmat(' ', 1, self.numIndentationSpaces());
98 end
99
100 function n = numIndentationSpaces(self)
101 indent_level = numel(self.TicStack) - 1;
102 n = 3 * indent_level;
103 end
104
105 function str = leaderDots(self, name)
106 num_dots = max(0, 60 - self.numIndentationSpaces() - numel(name));
107 str = repmat('.', 1, num_dots);
108 end
109
110 end
111
112 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertElementsAlmostEqual.m deleted (index 3ac2ba6..0000000)
1 function assertElementsAlmostEqual(varargin)
2 %assertElementsAlmostEqual Assert floating-point array elements almost equal.
3 % assertElementsAlmostEqual(A, B, tol_type, tol, floor_tol) asserts that all
4 % elements of floating-point arrays A and B are equal within some tolerance.
5 % tol_type can be 'relative' or 'absolute'. tol and floor_tol are scalar
6 % tolerance values.
7 %
8 % If the tolerance type is 'relative', then the tolerance test used is:
9 %
10 % all( abs(A(:) - B(:)) <= tol * max(abs(A(:)), abs(B(:))) + floor_tol )
11 %
12 % If the tolerance type is 'absolute', then the tolerance test used is:
13 %
14 % all( abs(A(:) - B(:)) <= tol )
15 %
16 % tol_type, tol, and floor_tol are all optional. The default value for
17 % tol_type is 'relative'. If both A and B are double, then the default value
18 % for tol and floor_tol is sqrt(eps). If either A or B is single, then the
19 % default value for tol and floor_tol is sqrt(eps('single')).
20 %
21 % If A or B is complex, then the tolerance test is applied independently to
22 % the real and imaginary parts.
23 %
24 % Corresponding elements in A and B that are both NaN, or are both infinite
25 % with the same sign, are considered to pass the tolerance test.
26 %
27 % assertElementsAlmostEqual(A, B, ..., msg) prepends the string msg to the
28 % output message if A and B fail the tolerance test.
29
30 % Steven L. Eddins
31 % Copyright 2008-2010 The MathWorks, Inc.
32
33 params = xunit.utils.parseFloatAssertInputs(varargin{:});
34
35 if ~isequal(size(params.A), size(params.B))
36 message = xunit.utils.comparisonMessage(params.Message, ...
37 'Inputs are not the same size.', ...
38 params.A, params.B);
39 throwAsCaller(MException('assertElementsAlmostEqual:sizeMismatch', ...
40 '%s', message));
41 end
42
43 if ~(isfloat(params.A) && isfloat(params.B))
44 message = xunit.utils.comparisonMessage(params.Message, ...
45 'Inputs are not both floating-point.', ...
46 params.A, params.B);
47 throwAsCaller(MException('assertElementsAlmostEqual:notFloat', ...
48 '%s', message));
49 end
50
51 if ~xunit.utils.compareFloats(params.A, params.B, 'elementwise', ...
52 params.ToleranceType, params.Tolerance, params.FloorTolerance)
53
54 tolerance_message = sprintf('Input elements are not all equal within %s tolerance: %g', ...
55 params.ToleranceType, params.Tolerance);
56 message = xunit.utils.comparisonMessage(params.Message, tolerance_message, ...
57 params.A, params.B);
58
59 throwAsCaller(MException('assertElementsAlmostEqual:tolExceeded', ...
60 '%s', message));
61 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertEqual.m deleted (index 72349cd..0000000)
1 function assertEqual(A, B, custom_message)
2 %assertEqual Assert that inputs are equal
3 % assertEqual(A, B) throws an exception if A and B are not equal. A and B
4 % must have the same class and sparsity to be considered equal.
5 %
6 % assertEqual(A, B, MESSAGE) prepends the string MESSAGE to the assertion
7 % message if A and B are not equal.
8 %
9 % Examples
10 % --------
11 % % This call returns silently.
12 % assertEqual([1 NaN 2], [1 NaN 2]);
13 %
14 % % This call throws an error.
15 % assertEqual({'A', 'B', 'C'}, {'A', 'foo', 'C'});
16 %
17 % See also assertElementsAlmostEqual, assertVectorsAlmostEqual
18
19 % Steven L. Eddins
20 % Copyright 2008-2010 The MathWorks, Inc.
21
22 if nargin < 3
23 custom_message = '';
24 end
25
26 if ~ (issparse(A) == issparse(B))
27 message = xunit.utils.comparisonMessage(custom_message, ...
28 'One input is sparse and the other is not.', A, B);
29 throwAsCaller(MException('assertEqual:sparsityNotEqual', '%s', message));
30 end
31
32 if ~strcmp(class(A), class(B))
33 message = xunit.utils.comparisonMessage(custom_message, ...
34 'The inputs differ in class.', A, B);
35 throwAsCaller(MException('assertEqual:classNotEqual', '%s', message));
36 end
37
38 if ~isequalwithequalnans(A, B)
39 message = xunit.utils.comparisonMessage(custom_message, ...
40 'Inputs are not equal.', A, B);
41 throwAsCaller(MException('assertEqual:nonEqual', '%s', message));
42 end
43
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertExceptionThrown.m deleted (index bbe6b72..0000000)
1 function assertExceptionThrown(f, expectedId, custom_message)
2 %assertExceptionThrown Assert that specified exception is thrown
3 % assertExceptionThrown(F, expectedId) calls the function handle F with no
4 % input arguments. If the result is a thrown exception whose identifier is
5 % expectedId, then assertExceptionThrown returns silently. If no exception is
6 % thrown, then assertExceptionThrown throws an exception with identifier equal
7 % to 'assertExceptionThrown:noException'. If a different exception is thrown,
8 % then assertExceptionThrown throws an exception identifier equal to
9 % 'assertExceptionThrown:wrongException'.
10 %
11 % assertExceptionThrown(F, expectedId, msg) prepends the string msg to the
12 % assertion message.
13 %
14 % Example
15 % -------
16 % % This call returns silently.
17 % f = @() error('a:b:c', 'error message');
18 % assertExceptionThrown(f, 'a:b:c');
19 %
20 % % This call returns silently.
21 % assertExceptionThrown(@() sin, 'MATLAB:minrhs');
22 %
23 % % This call throws an error because calling sin(pi) does not error.
24 % assertExceptionThrown(@() sin(pi), 'MATLAB:foo');
25
26 % Steven L. Eddins
27 % Copyright 2008-2010 The MathWorks, Inc.
28
29 noException = false;
30 try
31 f();
32 noException = true;
33
34 catch exception
35 if ~strcmp(exception.identifier, expectedId)
36 message = sprintf('Expected exception %s but got exception %s.', ...
37 expectedId, exception.identifier);
38 if nargin >= 3
39 message = sprintf('%s\n%s', custom_message, message);
40 end
41 throwAsCaller(MException('assertExceptionThrown:wrongException', ...
42 '%s', message));
43 end
44 end
45
46 if noException
47 message = sprintf('Expected exception "%s", but none thrown.', ...
48 expectedId);
49 if nargin >= 3
50 message = sprintf('%s\n%s', custom_message, message);
51 end
52 throwAsCaller(MException('assertExceptionThrown:noException', '%s', message));
53 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertFalse.m deleted (index 7bc3e84..0000000)
1 function assertFalse(condition, message)
2 %assertFalse Assert that input condition is false
3 % assertFalse(CONDITION, MESSAGE) throws an exception containing the string
4 % MESSAGE if CONDITION is not false.
5 %
6 % MESSAGE is optional.
7 %
8 % Examples
9 % --------
10 % assertFalse(isreal(sqrt(-1)))
11 %
12 % assertFalse(isreal(sqrt(-1)), ...
13 % 'Expected isreal(sqrt(-1)) to be false.')
14 %
15 % See also assertTrue
16
17 % Steven L. Eddins
18 % Copyright 2008-2010 The MathWorks, Inc.
19
20 if nargin < 2
21 message = 'Asserted condition is not false.';
22 end
23
24 if ~isscalar(condition) || ~islogical(condition)
25 throwAsCaller(MException('assertFalse:invalidCondition', ...
26 'CONDITION must be a scalar logical value.'));
27 end
28
29 if condition
30 throwAsCaller(MException('assertFalse:trueCondition', '%s', message));
31 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertFilesEqual.m deleted (index d1cfc51..0000000)
1 function assertFilesEqual(filename1, filename2, user_message)
2 %assertFilesEqual Assert that files contain the same contents.
3 % assertFilesEqual(filename1, filename2) throws an exception if the two
4 % specified files do not contain the same contents.
5 %
6 % assertFilesEqual(filename1, filename2, message) prepends the specified
7 % message string to the assertion message.
8
9 % Steven L. Eddins
10 % Copyright 2009-2010 The MathWorks, Inc.
11
12 if nargin < 3
13 user_message = '';
14 end
15
16 fid1 = fopen(filename1, 'r');
17 if (fid1 < 0)
18 message = sprintf('%s\nCould not open file for reading: %s', ...
19 user_message, filename1);
20 throwAsCaller(MException('assertFilesEqual:readFailure', ...
21 '%s', message));
22 else
23 c1 = onCleanup(@() fclose(fid1));
24 end
25
26 fid2 = fopen(filename2, 'r');
27 if (fid2 < 0)
28 message = sprintf('%s\nCould not open file for reading: %s', ...
29 user_message, filename2);
30 throwAsCaller(MException('assertFilesEqual:readFailure', '%s', message));
31 else
32 c2 = onCleanup(@() fclose(fid2));
33 end
34
35 block_size = 100000;
36 num_blocks = 0;
37 done = false;
38 while ~done
39 block_from_file1 = fread(fid1, block_size, '*uint8');
40 block_from_file2 = fread(fid2, block_size, '*uint8');
41
42 if numel(block_from_file1) ~= numel(block_from_file2)
43 fseek(fid1, 0, 'eof');
44 fseek(fid2, 0, 'eof');
45 message = sprintf('The two files are not the same size. File "%s" has %d bytes and file "%s" has %d bytes', ...
46 filename1, ftell(fid1), filename2, ftell(fid2));
47 if ~isempty(user_message)
48 message = sprintf('%s\n%s', user_message, message);
49 end
50 throwAsCaller(MException('assertFilesEqual:sizeMismatch', '%s', message));
51 end
52
53 if ~isequal(block_from_file1, block_from_file2)
54 first_difference_in_block = find(block_from_file1 ~= block_from_file2);
55 first_difference = num_blocks * block_size + first_difference_in_block;
56
57 message = sprintf('Files are not equal. First difference is at byte %d, where file "%s" contains 0x%X and file "%s" contains 0x%X', ...
58 first_difference, filename1, block_from_file1(first_difference_in_block), ...
59 filename2, block_from_file2(first_difference_in_block));
60 if ~isempty(user_message)
61 message = sprintf('%s\n%s', user_message, message);
62 end
63 throwAsCaller(MException('assertFilesEqual:valuesDiffer', '%s', message));
64 end
65
66 done = numel(block_from_file1) < block_size;
67 num_blocks = num_blocks + 1;
68 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertTrue.m deleted (index 52787a6..0000000)
1 function assertTrue(condition, message)
2 %assertTrue Assert that input condition is true
3 % assertTrue(CONDITION, MESSAGE) throws an exception containing the string
4 % MESSAGE if CONDITION is not true.
5 %
6 % MESSAGE is optional.
7 %
8 % Examples
9 % --------
10 % % This call returns silently.
11 % assertTrue(rand < 1, 'Expected output of rand to be less than 1')
12 %
13 % % This call throws an error.
14 % assertTrue(sum(sum(magic(3))) == 0, ...
15 % 'Expected sum of elements of magic(3) to be 0')
16 %
17 % See also assertEqual, assertFalse
18
19 % Steven L. Eddins
20 % Copyright 2008-2010 The MathWorks, Inc.
21
22 if nargin < 2
23 message = 'Asserted condition is not true.';
24 end
25
26 if ~isscalar(condition) || ~islogical(condition)
27 throwAsCaller(MException('assertTrue:invalidCondition', ...
28 'CONDITION must be a scalar logical value.'));
29 end
30
31 if ~condition
32 throwAsCaller(MException('assertTrue:falseCondition', '%s', message));
33 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/assertVectorsAlmostEqual.m deleted (index e4f1034..0000000)
1 function assertVectorsAlmostEqual(varargin)
2 %assertVectorsAlmostEqual Assert floating-point vectors almost equal in norm sense.
3 % assertVectorsAlmostEqual(A, B, tol_type, tol, floor_tol) asserts that the
4 % vectors A and B are equal, in the L2-norm sense and within some tolerance.
5 % tol_type can be 'relative' or 'absolute'. tol and floor_tol are scalar
6 % tolerance values.
7 %
8 % If the tolerance type is 'relative', then the tolerance test used is:
9 %
10 % all( norm(A - B) <= tol * max(norm(A), norm(B)) + floor_tol )
11 %
12 % If the tolerance type is 'absolute', then the tolerance test used is:
13 %
14 % all( norm(A - B) <= tol )
15 %
16 % tol_type, tol, and floor_tol are all optional. The default value for
17 % tol_type is 'relative'. If both A and B are double, then the default value
18 % for tol and floor_tol is sqrt(eps). If either A or B is single, then the
19 % default value for tol and floor_tol is sqrt(eps('single')).
20 %
21 % If A or B is complex, then the tolerance test is applied independently to
22 % the real and imaginary parts.
23 %
24 % Any infinite or NaN element of A or B will cause an assertion failure.
25 %
26 % assertVectorsAlmostEqual(A, B, ..., msg) prepends the string msg to the
27 % assertion message if A and B fail the tolerance test.
28
29 % Steven L. Eddins
30 % Copyright 2008-2010 The MathWorks, Inc.
31
32 params = xunit.utils.parseFloatAssertInputs(varargin{:});
33
34 if ~isequal(size(params.A), size(params.B))
35 message = xunit.utils.comparisonMessage(params.Message, ...
36 'Inputs are not the same size.', ...
37 params.A, params.B);
38 throwAsCaller(MException('assertVectorsAlmostEqual:sizeMismatch', ...
39 '%s', message));
40 end
41
42 if ~(isfloat(params.A) && isfloat(params.B))
43 message = xunit.utils.comparisonMessage(params.Message, ...
44 'Inputs are not both floating-point.', ...
45 params.A, params.B);
46 throwAsCaller(MException('assertVectorsAlmostEqual:notFloat', ...
47 '%s', message));
48 end
49
50 if ~xunit.utils.compareFloats(params.A, params.B, 'vector', ...
51 params.ToleranceType, params.Tolerance, params.FloorTolerance)
52
53 tolerance_message = sprintf('Inputs are not equal within %s vector tolerance: %g', ...
54 params.ToleranceType, params.Tolerance);
55 message = xunit.utils.comparisonMessage(params.Message, tolerance_message, ...
56 params.A, params.B);
57 throwAsCaller(MException('assertVectorsAlmostEqual:tolExceeded', ...
58 '%s', message));
59 end
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/info.xml deleted (index e1cdece..0000000)
1 <!--
2 Copyright 2013 The MathWorks, Inc.
3 -->
4 <productinfo
5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6 xsi:noNamespaceSchemaLocation="optional">
7 <?xml-stylesheet type="text/xsl" href="optional"?>
8
9 <matlabrelease>R2009a</matlabrelease>
10 <name>MATLAB xUnit Test Framework</name>
11 <type>Other</type>
12 <icon>$toolbox/matlab/icons/matlabicon.gif</icon>
13 <help_location>../doc/</help_location>
14
15 <list>
16
17 <listitem>
18 <label>Help</label>
19 <callback>doc xunit</callback>
20 <icon>$toolbox/matlab/icons/book_mat.gif</icon>
21 </listitem>
22
23 <listitem>
24 <label>Web Page (File Exchange)</label>
25 <callback>web http://www.mathworks.com/matlabcentral/fileexchange/22846 -browser;</callback>
26 <icon>$toolbox/matlab/icons/webicon.gif</icon>
27 </listitem>
28
29 </list>
30
31 </productinfo>
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/initTestSuite.m deleted (index 5b978ec..0000000)
1 %findSubfunctionTests Utility script used for subfunction-based tests
2 % This file is a script that is called at the top of M-files containing
3 % subfunction-based tests.
4 %
5 % The top of a typical M-file using this script looks like this:
6 %
7 % function test_suite = testFeatureA
8 %
9 % findSubfunctionTests;
10 %
11 % IMPORTANT NOTE
12 % --------------
13 % The output variable name for an M-file using this script must be test_suite.
14
15 % Steven L. Eddins
16 % Copyright 2008-2009 The MathWorks, Inc.
17
18 [ST,I] = dbstack('-completenames');
19 caller_name = ST(I + 1).name;
20 caller_file = ST(I + 1).file;
21 subFcns = which('-subfun', caller_file);
22
23 setup_fcn_name = subFcns(xunit.utils.isSetUpString(subFcns));
24 if numel(setup_fcn_name) > 1
25 error('findSubfunctionTests:tooManySetupFcns', ...
26 'Found more than one setup subfunction.')
27 elseif isempty(setup_fcn_name)
28 setup_fcn = [];
29 else
30 setup_fcn = str2func(setup_fcn_name{1});
31 end
32
33 teardown_fcn_name = subFcns(xunit.utils.isTearDownString(subFcns));
34 if numel(teardown_fcn_name) > 1
35 error('findSubfunctionTests:tooManyTeardownFcns', ...
36 'Found more than one teardown subfunction.')
37 elseif isempty(teardown_fcn_name)
38 teardown_fcn = [];
39 else
40 teardown_fcn = str2func(teardown_fcn_name{1});
41 end
42
43 test_fcns = cellfun(@str2func, subFcns(xunit.utils.isTestString(subFcns)), ...
44 'UniformOutput', false);
45
46 suite = TestSuite;
47 suite.Name = caller_name;
48 suite.Location = which(caller_file);
49 for k = 1:numel(test_fcns)
50 suite.add(FunctionHandleTestCase(test_fcns{k}, setup_fcn, teardown_fcn));
51 end
52
53 test_suite = suite;
54
55
File data_analysis/unittests/matlab_xunit_3_1_1/xunit/runtests.m deleted (index 74a2414..0000000)
1 function out = runtests(varargin)
2 %runtests Run unit tests
3 % runtests runs all the test cases that can be found in the current directory
4 % and summarizes the results in the Command Window.
5 %
6 % Test cases can be found in the following places in the current directory:
7 %
8 % * An M-file function whose name starts or ends with "test" or
9 % "Test" and that returns no output arguments.
10 %
11 % * An M-file function whose name starts or ends with "test" or
12 % "Test" and that contains subfunction tests and uses the
13 % initTestSuite script to return a TestSuite object.
14 %
15 % * An M-file defining a subclass of TestCase.
16 %
17 % runtests(dirname) runs all the test cases found in the specified directory.
18 %
19 % runtests(packagename) runs all the test cases found in the specified
20 % package. (This option requires R2009a or later).
21 %
22 % runtests(mfilename) runs test cases found in the specified function or class
23 % name. The function or class needs to be in the current directory or on the
24 % MATLAB path.
25 %
26 % runtests('mfilename:testname') runs the specific test case named 'testname'
27 % found in the function or class 'name'.
28 %
29 % Multiple directories or file names can be specified by passing multiple
30 % names to runtests, as in runtests(name1, name2, ...) or
31 % runtests({name1, name2, ...}, ...)
32 %
33 % runtests(..., '-verbose') displays the name and result, result, and time
34 % taken for each test case to the Command Window.
35 %
36 % runtests(..., '-logfile', filename) directs the output of runtests to
37 % the specified log file instead of to the Command Window.
38 %
39 % out = runtests(...) returns a logical value that is true if all the
40 % tests passed.
41 %
42 % Examples
43 % --------
44 % Find and run all the test cases in the current directory.
45 %
46 % runtests
47 %
48 % Find and run all the test cases in the current directory. Display more
49 % detailed information to the Command Window as the test cases are run.
50 %
51 % runtests -verbose
52 %
53 % Save verbose runtests output to a log file.
54 %
55 % runtests -verbose -logfile my_test_log.txt
56 %
57 % Find and run all the test cases contained in the M-file myfunc.
58 %
59 % runtests myfunc
60 %
61 % Find and run all the test cases contained in the TestCase subclass
62 % MyTestCase.
63 %
64 % runtests MyTestCase
65 %
66 % Run the test case named 'testFeature' contained in the M-file myfunc.
67 %
68 % runtests myfunc:testFeature
69 %
70 % Run all the tests in a specific directory.
71 %
72 % runtests c:\Work\MyProject\tests
73 %
74 % Run all the tests in two directories.
75 %
76 % runtests c:\Work\MyProject\tests c:\Work\Book\tests
77
78 % Steven L. Eddins
79 % Copyright 2009-2010 The MathWorks, Inc.
80
81 verbose = false;
82 logfile = '';
83 if nargin < 1
84 suite = TestSuite.fromPwd();
85 else
86 [name_list, verbose, logfile] = getInputNames(varargin{:});
87 if numel(name_list) == 0
88 suite = TestSuite.fromPwd();
89 elseif numel(name_list) == 1
90 suite = TestSuite.fromName(name_list{1});
91 else
92 suite = TestSuite();
93 for k = 1:numel(name_list)
94 suite.add(TestSuite.fromName(name_list{k}));
95 end
96 end
97 end
98
99 if isempty(suite.TestComponents)
100 error('xunit:runtests:noTestCasesFound', 'No test cases found.');
101 end
102
103 if isempty(logfile)
104 logfile_handle = 1; % File handle corresponding to Command Window
105 else
106 logfile_handle = fopen(logfile, 'w');
107 if logfile_handle < 0
108 error('xunit:runtests:FileOpenFailed', ...
109 'Could not open "%s" for writing.', logfile);
110 else
111 cleanup = onCleanup(@() fclose(logfile_handle));
112 end
113 end
114
115 fprintf(logfile_handle, 'Test suite: %s\n', suite.Name);
116 if ~strcmp(suite.Name, suite.Location)
117 fprintf(logfile_handle, 'Test suite location: %s\n', suite.Location);
118 end
119 fprintf(logfile_handle, '%s\n\n', datestr(now));
120
121 if verbose
122 monitor = VerboseTestRunDisplay(logfile_handle);
123 else
124 monitor = TestRunDisplay(logfile_handle);
125 end
126 did_pass = suite.run(monitor);
127
128 if nargout > 0
129 out = did_pass;
130 end
131
132 function [name_list, verbose, logfile] = getInputNames(varargin)
133 name_list = {};
134 verbose = false;
135 logfile = '';
136 k = 1;
137 while k <= numel(varargin)
138 arg = varargin{k};
139 if iscell(arg)
140 name_list = [name_list; arg];
141 elseif ~isempty(arg) && (arg(1) == '-')
142 if strcmp(arg, '-verbose')
143 verbose = true;
144 elseif strcmp(arg, '-logfile')
145 if k == numel(varargin)
146 error('xunit:runtests:MissingLogfile', ...
147 'The option -logfile must be followed by a filename.');
148 else
149 logfile = varargin{k+1};
150 k = k + 1;
151 end
152 else
153 warning('runtests:unrecognizedOption', 'Unrecognized option: %s', arg);
154 end
155 else
156 name_list{end+1} = arg;
157 end
158 k = k + 1;
159 end
160
File data_analysis/unittests/permute_data_test.m changed (mode: 100644) (index 58a00b0..e50ef92)
1 1 function test_suite = permute_data_test %#ok<STOUT> function test_suite = permute_data_test %#ok<STOUT>
2 initTestSuite;
2 localFunctionHandles = cellfun(@str2func,...
3 which('-subfun', mfilename('fullpath')), 'UniformOutput', false);
4 test_suite = buildFunctionHandleTestSuite(localFunctionHandles);
3 5
4 6 function shared = setup function shared = setup
5 7 sample_no = 2; sample_no = 2;
 
... ... function permute_data_1mode_test(shared)
56 58 assertEqual(permute_data(invariant_data), invariant_data); assertEqual(permute_data(invariant_data), invariant_data);
57 59
58 60 invariant_data = shared.data_singlemode; invariant_data = shared.data_singlemode;
59 assertEqual(permute_data(invariant_data), invariant_data);
61 assertEqual(permute_data(invariant_data), invariant_data);
File data_analysis/unittests/pseudo_hash_test.m changed (mode: 100644) (index 11190d5..de5e52f)
1 1 function test_suite = pseudo_hash_test %#ok<STOUT> function test_suite = pseudo_hash_test %#ok<STOUT>
2 initTestSuite;
3
2 localFunctionHandles = cellfun(@str2func,...
3 which('-subfun', mfilename('fullpath')), 'UniformOutput', false);
4 test_suite = buildFunctionHandleTestSuite(localFunctionHandles);
5
4 6 function shared = setup function shared = setup
5 7 shared.sample_no = 1e3; shared.sample_no = 1e3;
6 8 shared.data = randn(shared.sample_no, 1); shared.data = randn(shared.sample_no, 1);
File data_analysis/unittests/read_permute_write_data_test.m changed (mode: 100644) (index 8c77486..5322ed6)
1 1 function test_suite = read_permute_write_data_test %#ok<STOUT> function test_suite = read_permute_write_data_test %#ok<STOUT>
2 initTestSuite;
2 localFunctionHandles = cellfun(@str2func,...
3 which('-subfun', mfilename('fullpath')), 'UniformOutput', false);
4 test_suite = buildFunctionHandleTestSuite(localFunctionHandles);
3 5
4 6 function shared = setup function shared = setup
5 7 shared.folder = tempname; shared.folder = tempname;
 
... ... function read_permute_write_data_3modes_CM_test(shared)
47 49 % CM_ordered(1:2,1:2) % CM_ordered(1:2,1:2)
48 50 % cm2 = cov(shared.data_ordered); % cm2 = cov(shared.data_ordered);
49 51 % cm2(1:2,1:2) % cm2(1:2,1:2)
50 assertAlmostEqual(CM_ordered, cov(shared.data_ordered), shared.precision);
52 assertElementsAlmostEqual(CM_ordered, cov(shared.data_ordered), 'absolute', shared.precision);
51 53 delete(permuted_data_CM_file) delete(permuted_data_CM_file)
File data_analysis/unittests/timetrace_test.m changed (mode: 100644) (index c80bc83..bf09b37)
1 1 function test_suite = timetrace_test %#ok<STOUT> function test_suite = timetrace_test %#ok<STOUT>
2 clc; close all
3 initTestSuite;
2 localFunctionHandles = cellfun(@str2func,...
3 which('-subfun', mfilename('fullpath')), 'UniformOutput', false);
4 test_suite = buildFunctionHandleTestSuite(localFunctionHandles);
4 5
5 6 function shared = setup function shared = setup
6 7 shared.show_plots = false; shared.show_plots = false;
 
... ... function ht = timetrace_NPS_test(shared)
65 66 set(gca, 'xscale','log') set(gca, 'xscale','log')
66 67 end end
67 68 relTol = 1e-2; relTol = 1e-2;
68 assertAlmostEqual(ht.spectrum.peaks.freq, shared.mech_freq, relTol);
69 assertElementsAlmostEqual(ht.spectrum.peaks.freq, shared.mech_freq, 'relative', relTol);
69 70
70 71
71 72 function ht = timetrace_properties_test(shared) function ht = timetrace_properties_test(shared)
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/gutc61/Membrane

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/gutc61/Membrane

Clone this repository using git:
git clone git://git.rocketgit.com/user/gutc61/Membrane

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main