iutest  1.17.99.14
printto.cpp
//======================================================================
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//======================================================================
#include "../include/iutest.hpp"
/* ---------------------------------------------------
* PrintTo
*//*--------------------------------------------------*/
#if IUTEST_HAS_PRINT_TO
struct Bar
{
int x, y, z;
bool operator == (const Bar& rhs) const
{
return x == rhs.x && y == rhs.y && z == rhs.z;
}
};
::iutest::iu_ostream& operator << (::iutest::iu_ostream& os, const Bar& bar)
{
return os << "X:" << bar.x << " Y:" << bar.y << " Z:" << bar.z;
}
void PrintTo(const Bar& bar, ::iutest::iu_ostream* os)
{
*os << "x:" << bar.x << " y:" << bar.y << " z:" << bar.z;
}
IUTEST(PrintToTest, Test1)
{
::std::vector<int> a;
for( int i = 0; i < 10; ++i )
{
a.push_back(i);
}
int* pi=NULL;
void* p=NULL;
Bar bar = {0, 1, 2};
}
IUTEST(PrintToTest, Test2)
{
Bar bar1 = {0, 1, 2};
Bar bar2 = {0, 1, 2};
IUTEST_ASSERT_EQ(bar1, bar2);
}
IUTEST(PrintToTest, RawArray)
{
{
unsigned char a[3] = {0, 1, 2};
const unsigned char b[3] = {0, 1, 2};
const volatile unsigned char c[3] = {0, 1, 2};
volatile unsigned char d[3] = {0, 1, 2};
}
{
char a[3] = {0, 1, 2};
const char b[3] = {0, 1, 2};
const volatile char c[3] = {0, 1, 2};
volatile char d[3] = {0, 1, 2};
}
}
#if IUTEST_HAS_TYPED_TEST
template<typename T>
class TypedPrintToTest : public ::iutest::Test {};
typedef ::iutest::Types<char, unsigned char
, short, unsigned short
, int, unsigned int
, long, unsigned long
, int*> PrintStringTestTypes;
IUTEST_TYPED_TEST_SUITE(TypedPrintToTest, PrintStringTestTypes);
IUTEST_TYPED_TEST(TypedPrintToTest, Print)
{
TypeParam a = 0;
TypeParam& b = a;
const TypeParam c = a;
const volatile TypeParam d = a;
}
#if IUTEST_HAS_CHAR16_T
IUTEST(PrintToTest, U16String)
{
}
#endif
#if IUTEST_HAS_CHAR32_T
IUTEST(PrintToTest, U32String)
{
}
#endif
#endif
#endif
テストベース
Definition: iutest_body.hpp:44
#define IUTEST_ASSERT_EQ(expected, actual)
== テスト
Definition: iutest.hpp:308
#define IUTEST_SUCCEED()
明示的な成功
Definition: iutest.hpp:202
#define IUTEST(testsuite_, testname_)
テスト関数定義マクロ
Definition: iutest.hpp:72
#define IUTEST_TYPED_TEST(testsuite_, testname_)
型付けテスト関数定義マクロ
Definition: iutest_typed_tests.hpp:57
#define IUTEST_TYPED_TEST_SUITE(testsuite_,...)
型付けTestSuite の登録
Definition: iutest_typed_tests.hpp:45
std::string PrintToString(const T &v)
文字列化
Definition: iutest_printers.hpp:767