Exemple #1
0
/// Formats a test's timing information for recording in stderr.
///
/// \param start_time The start time of the test.
/// \param end_time The end time of the test.
///
/// \return A string with the timing information that can be prepended to the
/// original test's stderr.
std::string
drivers::junit_timing(const datetime::timestamp& start_time,
                      const datetime::timestamp& end_time)
{
    std::ostringstream output;
    output << junit_timing_header;
    output << F("Start time: %s\n") % start_time.to_iso8601_in_utc();
    output << F("End time:   %s\n") % end_time.to_iso8601_in_utc();
    output << F("Duration:   %ss\n") % junit_duration(end_time - start_time);
    return output.str();
}
Exemple #2
0
/// Calculates the delta between two timestamps.
///
/// \param other The subtrahend.
///
/// \return The difference between this object and the other object.
///
/// \throw std::runtime_error If the subtraction would result in a negative time
///     delta, which are currently not supported.
datetime::delta
datetime::timestamp::operator-(const datetime::timestamp& other) const
{
    if ((*this) < other) {
        throw std::runtime_error(
            F("Cannot subtract %s from %s as it would result in a negative "
              "datetime::delta, which are not supported") % other % (*this));
    }
    return datetime::delta::from_microseconds(to_microseconds() -
                                              other.to_microseconds());
}
Exemple #3
0
/// Calculates the delta between two timestamps.
///
/// \param other The subtrahend.
///
/// \return The difference between this object and the other object.
datetime::delta
datetime::timestamp::operator-(const datetime::timestamp& other) const
{
    return datetime::delta::from_microseconds(to_microseconds() -
                                              other.to_microseconds());
}
Exemple #4
0
/// Binds a timestamp to a statement parameter.
///
/// \param stmt The statement to which to bind the parameter.
/// \param field The name of the parameter; must exist.
/// \param timestamp The value to bind.
void
store::bind_timestamp(sqlite::statement& stmt, const char* field,
                      const datetime::timestamp& timestamp)
{
    stmt.bind(field, timestamp.to_microseconds());
}
Exemple #5
0
/// Checks if a timestamp is after or equal to another.
///
/// \param other The object to compare to.
///
/// \return True if this timestamp comes after other or is equal to it;
/// false otherwise.
bool
datetime::timestamp::operator>=(const datetime::timestamp& other) const
{
    return to_microseconds() >= other.to_microseconds();
}