Lhaz
読み取り中…
検索中…
一致する文字列を見つけられません
マクロ定義
Assert Macros and Functions

マクロ定義

#define WIN_ASSERT_EQUAL(expected, actual, ...)   WinUnit::Assert::AreEqual(TSTRING(expected), expected, TSTRING(actual), actual, __TFILE__, __LINE__, __VA_ARGS__)
 
#define WIN_ASSERT_NOT_EQUAL(notExpected, actual, ...)   WinUnit::Assert::AreNotEqual(TSTRING(notExpected), notExpected, TSTRING(actual), actual, __TFILE__, __LINE__, __VA_ARGS__)
 
#define WIN_ASSERT_STRING_EQUAL(expected, actual, ...)   WinUnit::Assert::StringEqual(expected, actual, __TFILE__, __LINE__, __VA_ARGS__)
 
#define WIN_ASSERT_ZERO(zeroExpression, ...)   WinUnit::Assert::IsZero(TSTRING(zeroExpression), zeroExpression, __TFILE__, __LINE__, __VA_ARGS__)
 
#define WIN_ASSERT_NOT_ZERO(nonzeroExpression, ...)   WinUnit::Assert::IsNotZero(TSTRING(nonzeroExpression), nonzeroExpression, __TFILE__, __LINE__, __VA_ARGS__)
 
#define WIN_ASSERT_NULL(nullExpression, ...)   WinUnit::Assert::IsNull(TSTRING(nullExpression), nullExpression, __TFILE__, __LINE__, __VA_ARGS__)
 
#define WIN_ASSERT_NOT_NULL(notNullExpression, ...)   WinUnit::Assert::IsNotNull(TSTRING(notNullExpression), notNullExpression, __TFILE__, __LINE__, __VA_ARGS__)
 
#define WIN_ASSERT_FAIL(message, ...)   WinUnit::Assert::Fail(__TFILE__, __LINE__, message, __VA_ARGS__)
 
#define WIN_ASSERT_TRUE(trueExpression, ...)   WinUnit::Assert::IsTrue(TSTRING(trueExpression), (trueExpression ? true : false), __TFILE__, __LINE__, __VA_ARGS__)
 
#define WIN_ASSERT_FALSE(falseExpression, ...)   WinUnit::Assert::IsFalse(TSTRING(falseExpression), (falseExpression ? true : false), __TFILE__, __LINE__, __VA_ARGS__)
 
#define WIN_ASSERT_WINAPI_SUCCESS(trueExpression, ...)   WinUnit::Assert::WinapiSucceeded(TSTRING(trueExpression), (trueExpression ? true : false), __TFILE__, __LINE__, __VA_ARGS__)
 
#define WIN_ASSERT_THROWS(expression, exceptionType, ...)   ¥
 

詳解

These are the "asserts" you will use to verify conditions which, if not true, indicate a test failure.

The WIN_ASSERT_* macros call similarly named Assert::* functions. While the Assert::* functions can be called without using the macros, the macros add value by including the file and line number and sometimes a string depiction of the expression(s) passed in.

The WIN_ASSERT_* macros all allow for an optional printf-style format string and parameters to be tacked on to the condition part of the assert. The Assert::* functions require at least one message string.

注釈
The error messages sometimes include the expression that was passed in as a string. If the type of the expression does not have a ToString implementation, [OBJECT] will be displayed.

マクロ定義詳解

◆ WIN_ASSERT_EQUAL

#define WIN_ASSERT_EQUAL (   expected,
  actual,
  ... 
)    WinUnit::Assert::AreEqual(TSTRING(expected), expected, TSTRING(actual), actual, __TFILE__, __LINE__, __VA_ARGS__)

The operator== is used to compare expected and actual; the test has failed if they are shown to be not equal.

引数
expectedThe expected value.
actualThe actual value, to be compared with expected.
...An optional printf-style format string and arguments.
注釈
If there is no operator== for the two types, a compiler error will occur.
You can write your own operator== for custom types. See http://msdn2.microsoft.com/en-us/library/09ka8bxx(VS.80).aspx for arithmetic conversions that occur when using a binary operator such as ==.

◆ WIN_ASSERT_FAIL

#define WIN_ASSERT_FAIL (   message,
  ... 
)    WinUnit::Assert::Fail(__TFILE__, __LINE__, message, __VA_ARGS__)

This "test" always fails, displaying the given message.

引数
messageA printf-style format string (required).
...Optional parameters for the format string.

◆ WIN_ASSERT_FALSE

#define WIN_ASSERT_FALSE (   falseExpression,
  ... 
)    WinUnit::Assert::IsFalse(TSTRING(falseExpression), (falseExpression ? true : false), __TFILE__, __LINE__, __VA_ARGS__)

The test fails if falseExpression evaluates to true.

引数
falseExpressionExpression expected to be false.
...An optional printf-style format string and arguments.

◆ WIN_ASSERT_NOT_EQUAL

#define WIN_ASSERT_NOT_EQUAL (   notExpected,
  actual,
  ... 
)    WinUnit::Assert::AreNotEqual(TSTRING(notExpected), notExpected, TSTRING(actual), actual, __TFILE__, __LINE__, __VA_ARGS__)

The operator!= is used to compare notExpected and actual; the test has failed if they are shown to be equal.

引数
notExpectedThe value not expected.
actualThe actual value, to be compared with notExpected.
...An optional printf-style format string and arguments.
注釈
If there is no operator!= for the two types, a compiler error will occur.
You can write your own operator!= for custom types. See http://msdn2.microsoft.com/en-us/library/09ka8bxx(VS.80).aspx for arithmetic conversions that occur when using a binary operator such as !=.

◆ WIN_ASSERT_NOT_NULL

#define WIN_ASSERT_NOT_NULL (   notNullExpression,
  ... 
)    WinUnit::Assert::IsNotNull(TSTRING(notNullExpression), notNullExpression, __TFILE__, __LINE__, __VA_ARGS__)

The test fails if notNullExpression evaluates to NULL.

引数
notNullExpressionThe expression that is expected to evaluate to a non-NULL value.
...An optional printf-style format string and arguments.
注釈
A compiler error will occur if notNullExpression does not evaluate to a pointer type.

◆ WIN_ASSERT_NOT_ZERO

#define WIN_ASSERT_NOT_ZERO (   nonzeroExpression,
  ... 
)    WinUnit::Assert::IsNotZero(TSTRING(nonzeroExpression), nonzeroExpression, __TFILE__, __LINE__, __VA_ARGS__)

The test fails if nonzeroExpression evaluates to 0.

引数
nonzeroExpressionThe expression that is expected to evaluate to a non-zero value.
...An optional printf-style format string and arguments.

◆ WIN_ASSERT_NULL

#define WIN_ASSERT_NULL (   nullExpression,
  ... 
)    WinUnit::Assert::IsNull(TSTRING(nullExpression), nullExpression, __TFILE__, __LINE__, __VA_ARGS__)

The test fails if nullExpression is not NULL.

引数
nullExpressionThe expression that is expected to evaluate to NULL.
...An optional printf-style format string and arguments.
注釈
A compiler error will occur if nullExpression does not evaluate to a pointer type.

◆ WIN_ASSERT_STRING_EQUAL

#define WIN_ASSERT_STRING_EQUAL (   expected,
  actual,
  ... 
)    WinUnit::Assert::StringEqual(expected, actual, __TFILE__, __LINE__, __VA_ARGS__)

A string-compare function (wcscmp or strcmp) is used to do a case-sensitive comparison of the two given strings (up to the first null character); the test has failed if they are not equal.

引数
expectedThe expected string.
actualThe actual string, to be compared with expected.
..An optional printf-style format string and arguments.
注釈
Either both strings must be wide-character, or both strings must be ANSI. The format string + arguments at the end are expected to be of character type TCHAR (i.e. Unicode if _UNICODE is defined; ANSI otherwise), regardless of which character type expected and actual are.

◆ WIN_ASSERT_THROWS

#define WIN_ASSERT_THROWS (   expression,
  exceptionType,
  ... 
)    ¥

The test fails if expression does not throw an exception of type exceptionType.

引数
expressionExpression expected to throw exception.
exceptionTypeThe exception type expected to be thrown.
...An optional printf-style format string and arguments
注釈
The exceptionType parameter is simply the name of the exception type– the macro uses it in a catch block.

◆ WIN_ASSERT_TRUE

#define WIN_ASSERT_TRUE (   trueExpression,
  ... 
)    WinUnit::Assert::IsTrue(TSTRING(trueExpression), (trueExpression ? true : false), __TFILE__, __LINE__, __VA_ARGS__)

The test fails if trueExpression does not evaluate to true.

引数
trueExpressionExpression expected to be true.
...An optional printf-style format string and arguments.

◆ WIN_ASSERT_WINAPI_SUCCESS

#define WIN_ASSERT_WINAPI_SUCCESS (   trueExpression,
  ... 
)    WinUnit::Assert::WinapiSucceeded(TSTRING(trueExpression), (trueExpression ? true : false), __TFILE__, __LINE__, __VA_ARGS__)

This assert is for testing for success of Windows API functions that require GetLastError() to be called for more information. Because the return value indicating success is not always the same for system functions, the value passed in should be an expression that evaluates to true if successful. Example: WIN_ASSERT_WINAPI_SUCCESS(0 != ::DeleteFile(_T("Foo"))); The string associated with the GetLastError() code is included in the exception message.

引数
trueExpressionExpression that should be true.
...An optional printf-style format string and arguments.

◆ WIN_ASSERT_ZERO

#define WIN_ASSERT_ZERO (   zeroExpression,
  ... 
)    WinUnit::Assert::IsZero(TSTRING(zeroExpression), zeroExpression, __TFILE__, __LINE__, __VA_ARGS__)

The test fails if zeroExpression does not evaluate to 0.

引数
zeroExpressionThe expression that is expected to evaluate to zero.
...An optional printf-style format string and arguments.