![]()  | 
  
    Qore QUnit Module Reference 0.4.3
    
   | 
 
Base class representing a simple test, implements an implicit main() function and all utility functions for testing. More...
#include <QUnit.qm.dox.h>
Public Member Methods | |
| addTestCase (QUnit::TestCase tc) | |
| adds a test case to run  More... | |
| addTestCase (string name, code call, *softlist< auto > args) | |
| adds a test case to run  More... | |
| assertEq (auto expected, auto actual, *string name) | |
| Tests a value for equality to an expected value with hard comparisons (types and values must be identical)  More... | |
| assertEqSoft (auto expected, auto actual, *string name) | |
| Tests a value for equality to an expected value with soft comparisons (types may differ)  More... | |
| assertFalse (auto actual, *string name) | |
| Tests a boolean value.  More... | |
| assertFloatEq (float expected, float actual, float epsilon=DEFAULT_EPSILON, *string name) | |
| Tests a float value for equality to an expected value with an allowed error.  More... | |
| assertGe (auto expected, auto actual, *string name) | |
| Tests that a value is greater than or equal to an expected value with hard comparisons (types may not differ)  More... | |
| assertGeSoft (auto expected, auto actual, *string name) | |
| Tests that a value is greater than or equal to than an expected value with soft comparisons (types may differ)  More... | |
| assertGt (auto expected, auto actual, *string name) | |
| Tests that a value is greater than an expected value with hard comparisons (types may not differ)  More... | |
| assertGtSoft (auto expected, auto actual, *string name) | |
| Tests that a value is greater than an expected value with soft comparisons (types may differ)  More... | |
| assertionOk (*string name) | |
| process an ok assertion  | |
| assertLe (auto expected, auto actual, *string name) | |
| Tests that a value is less than or equal to an expected value with hard comparisons (types may not differ)  More... | |
| assertLeSoft (auto expected, auto actual, *string name) | |
| Tests that a value is less than or equal to than an expected value with soft comparisons (types may differ)  More... | |
| assertLt (auto expected, auto actual, *string name) | |
| Tests that a value is less than an expected value with hard comparisons (types may not differ)  More... | |
| assertLtSoft (auto expected, auto actual, *string name) | |
| Tests that a value is less than an expected value with soft comparisons (types may differ)  More... | |
| assertNeq (auto expected, auto actual, *string name) | |
| Tests a value for inequality to an expected value with hard comparisons (types and values must be identical)  More... | |
| assertNeqSoft (auto expected, auto actual, *string name) | |
| Tests a value for inequality to an expected value with soft comparisons (types may differ)  More... | |
| assertNothing (auto actual, *string name) | |
| Tests for no value.  More... | |
| assertNRegex (string regex_pattern, string actual, *string name) | |
| Tests that a test value does not pass a regular expression match.  More... | |
| assertNumberEq (number expected, number actual, number epsilon=DEFAULT_EPSILON, *string name) | |
| Tests a number value for equality to an expected value with an allowed error.  More... | |
| assertRegex (string regex_pattern, string actual, *string name) | |
| Tests that a test value passes a regular expression match.  More... | |
| assertSkip (*string name) | |
| Skips assertion on purpose.  More... | |
| public | assertThrows (string expectedErr, *string expectedDesc, *hash< auto > arg, code theCode, *softlist< auto > args, *string name) | 
| Tests that a piece of code throws an exception with given description and exception arg keys.  More... | |
| assertThrows (string expectedErr, *string expectedDesc, code theCode, *softlist< auto > args, *string name) | |
| Tests that a piece of code throws an exception with given description.  More... | |
| assertThrows (string expectedErr, code theCode, *softlist< auto > args, *string name) | |
| Tests that a piece of code throws an exception.  More... | |
| assertTrue (auto actual, *string name) | |
| Tests a boolean value.  More... | |
| constructor (string name, string version, *list< auto > p_argv, *hash< auto > opts) | |
| creates the object and sets the name of the test  | |
| constructor (string name, string version, reference< list< string > > p_argv, *hash< auto > opts) | |
| creates the object and sets the name of the test  | |
| bool | equals (auto a, auto b) | 
| Compare two values for equality.  More... | |
| bool | equalsIterated (AbstractIterator a, AbstractIterator b) | 
| Compare two iterables, item by item, for equality of each index.  More... | |
| fail (*string msg) | |
| Fails the test unconditionally.  More... | |
| *string | getEnv (string key, *string def) | 
| facade for the system environment variables  | |
| TestCase | getTestCase (string meth) | 
| returns the current test case  | |
| globalSetUp () | |
| global setup; will be called once before tests are run  | |
| globalTearDown () | |
| global tear down; will be called once after all tests are run  | |
| int | main () | 
| Run the whole suite, report results.  | |
| bool | notEquals (auto a, auto b) | 
| Compare two values for inequality.  More... | |
| string | printUnexpectedData (auto exp, auto act, *bool neg, *bool soft_comparisons, *string comparitor) | 
| Helper function for printing out human-readable comparison of two values.  | |
| bool | regexpMatches (string s, string regexp) | 
| Compare a string for match against a regexp.  More... | |
| setUp () | |
| Prototype function for setting up test environment. It will be called for each test individually.  | |
| tearDown () | |
| Prototype function for cleaning up test environemnt. It will be called after each test has executed.  | |
| auto | testAssertion (string name, code condition, *softlist< auto > args, binary expectedResultValue) | 
| Tests for a single assertion for a call returning a binary value and returns the value generated.  More... | |
| auto | testAssertion (string name, code condition, *softlist< auto > args, bool expectedResultValue) | 
| Tests for a single assertion for a call returning a boolean value and returns the value generated.  More... | |
| auto | testAssertion (string name, code condition, *softlist< auto > args, date expectedResultValue) | 
| Tests for a single assertion for a call returning a date value and returns the value generated.  More... | |
| auto | testAssertion (string name, code condition, *softlist< auto > args, float expectedResultValue) | 
| Tests for a single assertion for a call returning a floating-point value and returns the value generated.  More... | |
| auto | testAssertion (string name, code condition, *softlist< auto > args, hash< auto > expectedResultValue) | 
| Tests for a single assertion for a call returning a hash value and returns the value generated.  More... | |
| auto | testAssertion (string name, code condition, *softlist< auto > args, int expectedResultValue) | 
| Tests for a single assertion for a call returning an integer value and returns the value generated.  More... | |
| auto | testAssertion (string name, code condition, *softlist< auto > args, list< auto > expectedResultValue) | 
| Tests for a single assertion for a call returning a list value and returns the value generated.  More... | |
| auto | testAssertion (string name, code condition, *softlist< auto > args, number expectedResultValue) | 
| Tests for a single assertion for a call returning an arbitrary-precision numeric value and returns the value generated.  More... | |
| auto | testAssertion (string name, code condition, *softlist< auto > args, QUnit::AbstractTestResult expectedResult=new QUnit::TestResultSuccess()) | 
| Tests for a single assertion and returns the value generated.  More... | |
| auto | testAssertion (string name, code condition, *softlist< auto > args, string expectedResultValue) | 
| Tests for a single assertion for a call returning a string value and returns the value generated.  More... | |
| auto | testAssertionValue (*string name, auto actual, auto expected) | 
| Tests a value for equality to an expected value.  More... | |
| auto | testAssertionValue (*string name, float actual, float expected, float epsilon=DEFAULT_EPSILON) | 
| Tests a value for equality to an expected value of float type.  More... | |
| auto | testAssertionValue (*string name, number actual, number expected, number epsilon=DEFAULT_EPSILON) | 
| Tests a value for equality to an expected value of number type.  More... | |
| testNullAssertion (string name, code condition, *softlist< auto > args) | |
| Tests for a single assertion for a call returning no value (for example, to ensure that the call does not throw an exception)  More... | |
| testSkip (string reason) | |
| Skips a given test, eg. because it may be missing some dependencies.  More... | |
  Public Member Methods inherited from QUnit::TestReporter | |
| constructor (string name, string version, *list< auto > p_argv, hash< auto > opts=Opts) | |
| creates the object from the arguments  More... | |
| constructor (string name, string version, reference< list< string > > p_argv, hash< auto > opts=Opts) | |
| creates the object from the arguments  More... | |
Private Member Methods | |
| list< TestCase > | testCases () | 
| list of test cases  | |
  Private Member Methods inherited from QUnit::TestReporter | |
| addTestResult (TestCase tc, int success, *string error, *string pos, *string detail) | |
| adds a test result  | |
| int | errors () | 
| returns the number of errors encountered during test execution  | |
| init (string name, string version, reference< list< string > > p_argv, hash< auto > opts=Opts) | |
| common constructor code  | |
| int | skipped () | 
| returns the number of tests skipped  | |
| int | testCount () | 
| returns the total number of test results  | |
Additional Inherited Members | |
  Public Attributes inherited from QUnit::TestReporter | |
| const | Opts = ... | 
| default options for Qore::GetOpt::constructor()  | |
  Private Attributes inherited from QUnit::TestReporter | |
| string | m_name | 
| test case name  | |
| hash< auto > | m_options | 
| the result of parsing command-line options with Qore::GetOpt::parse2()  More... | |
| hash< string, hash< string, code > > | m_printMethods | 
| A map of print methods, categorised into three types: header, summary, testreport.  | |
| string | m_version | 
| test case version  | |
| *list< auto > | new_argv | 
| new ARGV for languages that don't support lvalue references  | |
| int | num_asserts = 0 | 
| total number of assertions in script  | |
| int | num_asserts_ok = 0 | 
| total number of successful assertions in script  | |
| int | num_asserts_skip = 0 | 
| total number of skipped assertions in script  | |
| const | OffsetColumn = 20 | 
| the default column offset for printing options used in printOption() and usageIntern()  | |
Base class representing a simple test, implements an implicit main() function and all utility functions for testing.
| QUnit::Test::addTestCase | ( | QUnit::TestCase | tc | ) | 
adds a test case to run
| tc | the test case object | 
| QUnit::Test::addTestCase | ( | string | name, | 
| code | call, | ||
| *softlist< auto > | args | ||
| ) | 
adds a test case to run
| name | the name of the test case | 
| call | the code to call that executes the test case | 
| args | any optional arguments to the test case call | 
| QUnit::Test::assertEq | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests a value for equality to an expected value with hard comparisons (types and values must be identical)
| expected | the expected value | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertEqSoft | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests a value for equality to an expected value with soft comparisons (types may differ)
| expected | the expected value | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertFalse | ( | auto | actual, | 
| *string | name | ||
| ) | 
Tests a boolean value.
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertFloatEq | ( | float | expected, | 
| float | actual, | ||
| float | epsilon = DEFAULT_EPSILON,  | 
        ||
| *string | name | ||
| ) | 
Tests a float value for equality to an expected value with an allowed error.
| expected | the expected value | 
| actual | the value generated by the test | 
| epsilon | the allowed error | 
| name | the name or description of the assertion | 
| QUnit::Test::assertGe | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests that a value is greater than or equal to an expected value with hard comparisons (types may not differ)
| expected | a value that should be less than or equal to actual | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertGeSoft | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests that a value is greater than or equal to than an expected value with soft comparisons (types may differ)
| expected | a value that should be less than or equal to actual | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertGt | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests that a value is greater than an expected value with hard comparisons (types may not differ)
| expected | a value that should be less than actual | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertGtSoft | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests that a value is greater than an expected value with soft comparisons (types may differ)
| expected | a value that should be less than actual | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertLe | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests that a value is less than or equal to an expected value with hard comparisons (types may not differ)
| expected | a value that should be greater than or equal to actual | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertLeSoft | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests that a value is less than or equal to than an expected value with soft comparisons (types may differ)
| expected | a value that should be greater than or equal to actual | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertLt | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests that a value is less than an expected value with hard comparisons (types may not differ)
| expected | a value that should be greater than actual | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertLtSoft | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests that a value is less than an expected value with soft comparisons (types may differ)
| expected | a value that should be greater than actual | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertNeq | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests a value for inequality to an expected value with hard comparisons (types and values must be identical)
| expected | the value that should not be equal to the test value with a hard comparison | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertNeqSoft | ( | auto | expected, | 
| auto | actual, | ||
| *string | name | ||
| ) | 
Tests a value for inequality to an expected value with soft comparisons (types may differ)
| expected | the value that should not be equal to the test value with a soft comparison | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertNothing | ( | auto | actual, | 
| *string | name | ||
| ) | 
Tests for no value.
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertNRegex | ( | string | regex_pattern, | 
| string | actual, | ||
| *string | name | ||
| ) | 
Tests that a test value does not pass a regular expression match.
| regex_pattern | the regular expression pattern string that the test value should not match | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertNumberEq | ( | number | expected, | 
| number | actual, | ||
| number | epsilon = DEFAULT_EPSILON,  | 
        ||
| *string | name | ||
| ) | 
Tests a number value for equality to an expected value with an allowed error.
| expected | the expected value | 
| actual | the value generated by the test | 
| epsilon | the allowed error | 
| name | the name or description of the assertion | 
| QUnit::Test::assertRegex | ( | string | regex_pattern, | 
| string | actual, | ||
| *string | name | ||
| ) | 
Tests that a test value passes a regular expression match.
| regex_pattern | the regular expression pattern string that the test value should match | 
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| QUnit::Test::assertSkip | ( | *string | name | ) | 
Skips assertion on purpose.
| name | the name or description of the assertion | 
      
  | 
  inline | 
Tests that a piece of code throws an exception with given description and exception arg keys.
| expectedErr | the expected exception type | 
| expectedDesc | the expected exception detail as a regex pattern (desc field); ignored if NOTHING | 
| expectedArg | the expected keys in the exception arg hash; ignored if NOTHING  | 
| theCode | the code to execute | 
| args | optional arguments to the code | 
| name | an optional label for the assertion | 
| QUnit::Test::assertThrows | ( | string | expectedErr, | 
| *string | expectedDesc, | ||
| code | theCode, | ||
| *softlist< auto > | args, | ||
| *string | name | ||
| ) | 
Tests that a piece of code throws an exception with given description.
| expectedErr | the expected exception type | 
| expectedDesc | the expected exception detail as a regex pattern (desc field); ignored if NOTHING | 
| theCode | the code to execute | 
| args | optional arguments to the code | 
| name | an optional label for the assertion | 
| QUnit::Test::assertThrows | ( | string | expectedErr, | 
| code | theCode, | ||
| *softlist< auto > | args, | ||
| *string | name | ||
| ) | 
Tests that a piece of code throws an exception.
| expectedErr | the expected exception type | 
| theCode | the code to execute | 
| args | optional arguments to the code | 
| name | an optional label for the assertion | 
| QUnit::Test::assertTrue | ( | auto | actual, | 
| *string | name | ||
| ) | 
Tests a boolean value.
| actual | the value generated by the test | 
| name | the name or description of the assertion | 
| bool QUnit::Test::equals | ( | auto | a, | 
| auto | b | ||
| ) | 
Compare two values for equality.
| a | Argument 1 | 
| b | Argument 2 | 
| bool QUnit::Test::equalsIterated | ( | AbstractIterator | a, | 
| AbstractIterator | b | ||
| ) | 
Compare two iterables, item by item, for equality of each index.
| a | Iterable 1 | 
| b | Iterable 2 | 
| QUnit::Test::fail | ( | *string | msg | ) | 
Fails the test unconditionally.
| msg | the failure message | 
| bool QUnit::Test::notEquals | ( | auto | a, | 
| auto | b | ||
| ) | 
Compare two values for inequality.
| a | Argument 1 | 
| b | Argument 2 | 
| bool QUnit::Test::regexpMatches | ( | string | s, | 
| string | regexp | ||
| ) | 
Compare a string for match against a regexp.
| s | String to match | 
| regexp | Regular expression to match against | 
| auto QUnit::Test::testAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args, | ||
| binary | expectedResultValue | ||
| ) | 
Tests for a single assertion for a call returning a binary value and returns the value generated.
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| expectedResultValue | a binary value | 
| auto QUnit::Test::testAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args, | ||
| bool | expectedResultValue | ||
| ) | 
Tests for a single assertion for a call returning a boolean value and returns the value generated.
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| expectedResultValue | a boolean value | 
| auto QUnit::Test::testAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args, | ||
| date | expectedResultValue | ||
| ) | 
Tests for a single assertion for a call returning a date value and returns the value generated.
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| expectedResultValue | a date value | 
| auto QUnit::Test::testAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args, | ||
| float | expectedResultValue | ||
| ) | 
Tests for a single assertion for a call returning a floating-point value and returns the value generated.
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| expectedResultValue | a floating-point value | 
| auto QUnit::Test::testAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args, | ||
| hash< auto > | expectedResultValue | ||
| ) | 
Tests for a single assertion for a call returning a hash value and returns the value generated.
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| expectedResultValue | a hash value | 
| auto QUnit::Test::testAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args, | ||
| int | expectedResultValue | ||
| ) | 
Tests for a single assertion for a call returning an integer value and returns the value generated.
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| expectedResultValue | an integer value | 
| auto QUnit::Test::testAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args, | ||
| list< auto > | expectedResultValue | ||
| ) | 
Tests for a single assertion for a call returning a list value and returns the value generated.
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| expectedResultValue | a list value | 
| auto QUnit::Test::testAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args, | ||
| number | expectedResultValue | ||
| ) | 
Tests for a single assertion for a call returning an arbitrary-precision numeric value and returns the value generated.
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| expectedResultValue | an arbitrary-precision numeric value | 
| auto QUnit::Test::testAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args, | ||
| QUnit::AbstractTestResult | expectedResult = new QUnit::TestResultSuccess()  | 
        ||
| ) | 
Tests for a single assertion and returns the value generated.
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| expectedResult | A class describing the expected result of condition; the default is QUnit::TestResultSuccess | 
| auto QUnit::Test::testAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args, | ||
| string | expectedResultValue | ||
| ) | 
Tests for a single assertion for a call returning a string value and returns the value generated.
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| expectedResultValue | a string value | 
| auto QUnit::Test::testAssertionValue | ( | *string | name, | 
| auto | actual, | ||
| auto | expected | ||
| ) | 
Tests a value for equality to an expected value.
| name | the name or description of the assertion | 
| actual | the value generated by the test | 
| expected | the expected value | 
| auto QUnit::Test::testAssertionValue | ( | *string | name, | 
| float | actual, | ||
| float | expected, | ||
| float | epsilon = DEFAULT_EPSILON  | 
        ||
| ) | 
Tests a value for equality to an expected value of float type.
| name | the name or description of the assertion | 
| actual | the value generated by the test | 
| expected | the expected value | 
| epsilon | accepted difference | 
| auto QUnit::Test::testAssertionValue | ( | *string | name, | 
| number | actual, | ||
| number | expected, | ||
| number | epsilon = DEFAULT_EPSILON  | 
        ||
| ) | 
Tests a value for equality to an expected value of number type.
| name | the name or description of the assertion | 
| actual | the value generated by the test | 
| expected | the expected value | 
| epsilon | accepted difference | 
| QUnit::Test::testNullAssertion | ( | string | name, | 
| code | condition, | ||
| *softlist< auto > | args | ||
| ) | 
Tests for a single assertion for a call returning no value (for example, to ensure that the call does not throw an exception)
| name | the name or description of the assertion | 
| condition | A test function whose result we are asserting | 
| args | Arguments passed to condition | 
| QUnit::Test::testSkip | ( | string | reason | ) | 
Skips a given test, eg. because it may be missing some dependencies.
| reason | The reason for the test skip; used as the format argument with vsprintf() with any remaining arguments |