TEST(fatal_debug, fieldG_field1) {
  auto pod = test_data();
  pod.fieldG.field1 = "should mismatch";
  TEST_IMPL(pod, "<root>.fieldG.field1");
  pod.fieldG.field1 = "hello, world";
  TEST_IMPL(pod);
}
TEST(fatal_debug, fieldG_field2) {
  auto pod = test_data();
  pod.fieldG.field2 = enum1::field1;
  TEST_IMPL(pod, "<root>.fieldG.field2");
  pod.fieldG.field2 = enum1::field2;
  TEST_IMPL(pod);
}
TEST(fatal_debug, fieldC) {
  auto pod = test_data();
  pod.fieldC = enum1::field2;
  TEST_IMPL(pod, "<root>.fieldC");
  pod.fieldC = enum1::field0;
  TEST_IMPL(pod);
}
TEST(fatal_debug, fieldG_field0) {
  auto pod = test_data();
  pod.fieldG.field0 = 12;
  TEST_IMPL(pod, "<root>.fieldG.field0");
  pod.fieldG.field0 = 98;
  TEST_IMPL(pod);
}
TEST(fatal_debug, fieldH) {
  auto pod = test_data();
  pod.fieldH.set_ui_2(3);
  TEST_IMPL(pod, "<root>.fieldH");
  pod.fieldH.__clear();
  TEST_IMPL(pod);
}
TEST(fatal_debug, fieldB) {
  auto pod = test_data();
  pod.fieldB = "should mismatch";
  TEST_IMPL(pod, "<root>.fieldB");
  pod.fieldB = "this is a test";
  TEST_IMPL(pod);
}
TEST(fatal_debug, fieldA) {
  auto pod = test_data();
  pod.fieldA = 90;
  TEST_IMPL(pod, "<root>.fieldA");
  pod.fieldA = 141;
  TEST_IMPL(pod);
}
Ejemplo n.º 8
0
FATAL_TEST(make_ptr, sanity_check) {
# define TEST_IMPL(PtrClass, ...) \
  do { \
    value = 12; \
    using selector = pointer_selector<pointer_class::PtrClass, __VA_ARGS__>; \
    { \
      auto p = make_ptr<pointer_class::PtrClass, __VA_ARGS__>(value); \
      FATAL_ASSERT_NE(nullptr, selector::get(p)); \
      FATAL_EXPECT_EQ(99, value); \
      if (!selector::managed::value) { \
        selector::destroy(p); \
      } \
    } \
    FATAL_EXPECT_EQ(55, value); \
    \
    value = 22; \
    auto p = make_ptr<pointer_class::PtrClass, __VA_ARGS__>(value); \
    FATAL_ASSERT_NE(nullptr, selector::get(p)); \
    FATAL_EXPECT_EQ(99, value); \
    selector::destroy(p); \
    if (selector::managed::value) { \
      FATAL_EXPECT_EQ(nullptr, selector::get(p)); \
    } \
    FATAL_EXPECT_EQ(55, value); \
  } while (false)

  int value = 0;

  TEST_IMPL(raw, pointer_selector_tester);
  TEST_IMPL(unique, pointer_selector_tester);
  TEST_IMPL(unique, pointer_selector_tester, test_deleter);
  TEST_IMPL(shared, pointer_selector_tester);

# undef TEST_IMPL
}
TEST(fatal_debug, fieldG_field5) {
  auto pod = test_data();
  pod.fieldG.field5.set_ui_2(5);
  TEST_IMPL(pod, "<root>.fieldG.field5");
  pod.fieldG.field5.__clear();
  TEST_IMPL(pod, "<root>.fieldG.field5");
  pod.fieldG.field5.set_ue_2(enum1::field0);
  TEST_IMPL(pod, "<root>.fieldG.field5.ue_2");
  pod.fieldG.field5.set_ue_2(enum1::field1);
  TEST_IMPL(pod);
}
TEST(fatal_debug, fieldE) {
  auto pod = test_data();
  pod.fieldE.set_ui(5);
  TEST_IMPL(pod, "<root>.fieldE");
  pod.fieldE.__clear();
  TEST_IMPL(pod, "<root>.fieldE");
  pod.fieldE.set_ud(4);
  TEST_IMPL(pod, "<root>.fieldE.ud");
  pod.fieldE.set_ud(5.6);
  TEST_IMPL(pod);
}
TEST(fatal_debug, fieldM) {
  auto pod = test_data();
  pod.fieldM.clear();
  TEST_IMPL(pod, "<root>.fieldM");
  pod.fieldM.insert(11);
  pod.fieldM.insert(12);
  pod.fieldM.insert(13);
  pod.fieldM.insert(14);
  TEST_IMPL(pod, "<root>.fieldM.0");
  pod.fieldM = test_data().fieldM;
  TEST_IMPL(pod);
}
TEST(fatal_debug, fieldI) {
  auto pod = test_data();
  pod.fieldI[0] = 4;
  TEST_IMPL(pod, "<root>.fieldI.0");
  pod.fieldI[0] = 3;
  TEST_IMPL(pod);
  pod.fieldI[2] = 10;
  TEST_IMPL(pod, "<root>.fieldI.2");
  pod.fieldI.push_back(11);
  TEST_IMPL(pod, "<root>.fieldI");
  pod.fieldI.clear();
  TEST_IMPL(pod, "<root>.fieldI");
}
TEST(fatal_debug, fieldQ) {
  auto pod = test_data();
  pod.fieldQ.clear();
  TEST_IMPL(pod, "<root>.fieldQ");
  structA a1;
  a1.a = 1;
  a1.b = "1";
  structA a2;
  a2.a = 2;
  a2.b = "2";
  structA a3;
  a3.a = 3;
  a3.b = "3";
  pod.fieldQ["A1"] = a1;
  pod.fieldQ["A2"] = a2;
  pod.fieldQ["A3"] = a3;
  TEST_IMPL(pod, "<root>.fieldQ.0");
  pod.fieldQ = test_data().fieldQ;
  TEST_IMPL(pod);
}
Ejemplo n.º 14
0
FATAL_TEST(traits, as_integral) {
# define TEST_IMPL(ExpectedValue, ExpectedType, Value) \
  do { \
    FATAL_EXPECT_SAME<ExpectedType, decltype(as_integral(Value))>(); \
    FATAL_EXPECT_EQ(ExpectedValue, as_integral(Value)); \
  } while (false)

  {
    int v = 10;
    TEST_IMPL(10, int, v);

    int const c = 10;
    TEST_IMPL(10, int, c);
  }

  {
    long long v = 20;
    TEST_IMPL(20, long long, v);

    long long const c = 20;
    TEST_IMPL(20, long long, c);
  }

  TEST_IMPL(5, std::underlying_type<Ell>::type, Ell::a);

# undef TEST_IMPL

  as_integral_constant_test<bool, true, false>();

  as_integral_constant_test<char, ' ', 'h', 'e', 'l', 'o'>();
  as_integral_constant_test<unsigned char, ' ', 'h', 'e', 'l', 'o'>();

  as_integral_constant_test<std::size_t, 0, 1, 2, 3, 5, 8, 13, 21, 1000>();
  as_integral_constant_test<unsigned short, 0, 1, 2, 3, 5, 8, 13, 21, 1000>();
  as_integral_constant_test<unsigned, 0, 1, 2, 3, 5, 8, 13, 21, 1000>();
  as_integral_constant_test<unsigned long, 0, 1, 2, 3, 5, 8, 13, 21, 1000>();
  as_integral_constant_test<
    unsigned long long, 0, 1, 2, 3, 5, 8, 13, 21, 1000
  >();

  as_integral_constant_test<
    short,
    0, 1, 2, 3, 5, 8, 13, 21, 1000,
    -1, -2, -3, -5, -8, -13, -21, -1000
  >();
  as_integral_constant_test<
    int,
    0, 1, 2, 3, 5, 8, 13, 21, 1000,
    -1, -2, -3, -5, -8, -13, -21, -1000
  >();
  as_integral_constant_test<
    long,
    0, 1, 2, 3, 5, 8, 13, 21, 1000,
    -1, -2, -3, -5, -8, -13, -21, -1000
  >();
  as_integral_constant_test<
    long long,
    0, 1, 2, 3, 5, 8, 13, 21, 1000,
    -1, -2, -3, -5, -8, -13, -21, -1000
  >();
}
TEST(fatal_debug, equal) {
  TEST_IMPL(test_data());
}