iutest  1.17.1.0
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_CASE(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
iutest::Test
テストベース
Definition: iutest_body.hpp:43
IUTEST_TYPED_TEST_CASE
#define IUTEST_TYPED_TEST_CASE(testcase_,...)
型付けテストケースの登録
Definition: iutest_typed_tests.hpp:43
IUTEST_SUCCEED
#define IUTEST_SUCCEED()
明示的な成功
Definition: iutest.hpp:175
iutest::PrintToString
std::string PrintToString(const T &v)
文字列化
Definition: iutest_printers.hpp:678
IUTEST_TYPED_TEST
#define IUTEST_TYPED_TEST(testcase_, testname_)
型付けテスト関数定義マクロ
Definition: iutest_typed_tests.hpp:55
IUTEST_ASSERT_EQ
#define IUTEST_ASSERT_EQ(expected, actual)
== テスト
Definition: iutest.hpp:281
IUTEST
#define IUTEST(testcase_, testname_)
テスト関数定義マクロ
Definition: iutest.hpp:66