Пример #1
0
static void
test_homo_copy_ctor ()
{
    rw_info (0, __FILE__, __LINE__,
             "copy constructor (homogenous tuples)");

    std::tuple<> et1, et2 (et1);
    _RWSTD_UNUSED (et2);

    const int ci = std::rand ();
    const std::tuple<int> it1 (ci);
    std::tuple<int> it2 (it1);
    test (__LINE__, it2, ci);

    const std::tuple<const int>& ct1 = it1; // same as copy ctor
    std::tuple<const int> ct2 (ct1);
    test (__LINE__, ct2, ci);

    int i = ci;
    const std::tuple<int&> rt1 (i);
    std::tuple<int&> rt2 (rt1);
    test (__LINE__, rt2, ci);

    const std::tuple<std::tuple<int> > nt1 (it1);
    std::tuple<std::tuple<int> > nt2 (nt1);
    test (__LINE__, nt2, it1);

    const std::tuple<long, const char*> pt1 (1234567890L, "string");
    std::tuple<long, const char*> pt2 (pt1);
    test (__LINE__, pt2, 1234567890L, (const char*) "string");

    UserDefined ud (ci);
    const std::tuple<UserDefined> ut1 (ud);
    UserDefined::reset ();
    std::tuple<UserDefined> ut2 (ut1);
    ++UserDefined::expect.copy_ctor;
    test (__LINE__, ut2, ud);

    const std::tuple<bool, char, int, double, void*, UserDefined>
        bt1 (true, 'a', ci, 3.14159, (void* const) &i, ud);
    ++UserDefined::expect.move_ctor; // moved ud to bt1
    std::tuple<bool, char, int, double, void*, UserDefined> bt2 (bt1);
    ++UserDefined::expect.copy_ctor; // copied to bt2
    test (__LINE__, bt2, true, 'a', ci, 3.14159, (void* const) &i, ud);
}
/* ****************************************************************************
*
* check
*/
TEST(EntityTypeVector, check)
{
  utInit();

  EntityType et1("myType");
  EntityType et2("");

  // EntityTypeVector with a EntityType that will not fail
  EntityTypeVector etV1;
  etV1.push_back(&et1);

  // EntityTypeVector with a EntityType that will fail
  EntityTypeVector etV2;
  etV2.push_back(&et2);

  EXPECT_EQ("OK", etV1.check(V1, ""));

  EXPECT_EQ("foo", etV1.check(V1, "foo"));

  EXPECT_EQ("Empty Type", etV2.check(V1, ""));

  utExit();
}