Beispiel #1
0
static void
test_bson_oid_get_time_t (void)
{
   bson_context_t context;
   bson_oid_t oid;
   bson_oid_t oid2;

   /*
    * Test that the bson time_t matches the current time. This can race, but
    * i dont think that matters much.
    */
   bson_context_init(&context, BSON_CONTEXT_NONE);
   bson_oid_init(&oid, &context);
   bson_oid_init(&oid2, &context);
   assert(bson_oid_get_time_t(&oid) == bson_oid_get_time_t(&oid2));
   assert(time(NULL) == bson_oid_get_time_t(&oid2));
}
Beispiel #2
0
static void
test_bson_oid_get_time_t (void)
{
   bson_context_t *context;
   bson_oid_t oid;
   bson_oid_t oid2;

   /*
    * Test that the bson time_t matches the current time. This can race, but
    * i dont think that matters much.
    */
   context = bson_context_new (BSON_CONTEXT_NONE);
   bson_oid_init (&oid, context);
   bson_oid_init (&oid2, context);
   BSON_ASSERT (bson_oid_get_time_t (&oid) == bson_oid_get_time_t (&oid2));
   BSON_ASSERT (time (NULL) == bson_oid_get_time_t (&oid2));
   bson_context_destroy (context);
}
Beispiel #3
0
std::time_t oid::get_time_t() const {
    bson_oid_t oid;
    std::memcpy(oid.bytes, _bytes, sizeof(oid.bytes));

    return bson_oid_get_time_t(&oid);
}