Studio:Test Unit Template: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Following is an example of NaturalDocs commenting on a test class. It should be used as a template for such commenting.
Please put NaturalDocs comments in .h files.
<source lang="cpp">
#pragma once
#include <srtest.h>
namespace Basic {
    /*
    Class: Constructors
    Demonstrates passing constructor arguments to a test unit
    */
    class Constructors {
    public:
        /*
        Constructor: Constructors
        Constructor that sets internal values
        Parameters:
            val_1 - first argument
            val_2 - second argument
        */
        Constructors(int val_1, int val_2);
        /*
        Function: TestValuePositive
        Tests whether both values passed to the constructor are positive (e.g. greater than zero)
        Returns:
            true if both values are positive, false otherwise
        */
        bool TestValuesPositive();
        /*
        Enum: CounterMode
        Example enumeration
        NORMAL - Causes the counter to increment normally.
        ODD    - Causes the counter to only increment in odd numbers.
        EVEN  - Causes the counter to only increment in even numbers.
        */
        enum Mode { NORMAL, ODD, EVEN };
        // Constant: szLINK_TO_TEST_SPEC
        // wiki link that gets put into the test suite description
        static const char* szLINK_TO_TEST_SPEC;
    private:
        int value_1;
        int value_2;
    };
}
#ifdef _SCL
#pragma scl_test_class(Basic::Constructors)
#endif
</source>
[[Category:Documentation]]
[[Category:Documentation]]
[[Category:Practice]]
[[Category:Practice]]

Revision as of 01:39, 10 December 2008

Following is an example of NaturalDocs commenting on a test class. It should be used as a template for such commenting.

Please put NaturalDocs comments in .h files.

#pragma once
#include <srtest.h>

namespace Basic {
    /*
    Class: Constructors
    Demonstrates passing constructor arguments to a test unit
    */
    class Constructors {
    public:
        /*
        Constructor: Constructors
        Constructor that sets internal values

        Parameters:
            val_1 - first argument
            val_2 - second argument
        */
        Constructors(int val_1, int val_2);
        /*
        Function: TestValuePositive

        Tests whether both values passed to the constructor are positive (e.g. greater than zero)

        Returns:
            true if both values are positive, false otherwise
        */
        bool TestValuesPositive();
        /*
        Enum: CounterMode
        Example enumeration

        NORMAL - Causes the counter to increment normally.
        ODD    - Causes the counter to only increment in odd numbers.
        EVEN   - Causes the counter to only increment in even numbers.
        */
        enum Mode { NORMAL, ODD, EVEN };

        // Constant: szLINK_TO_TEST_SPEC
        // wiki link that gets put into the test suite description
        static const char* szLINK_TO_TEST_SPEC;
    private:
        int value_1;
        int value_2;
    };
}

#ifdef _SCL
#pragma scl_test_class(Basic::Constructors)
#endif