2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2020-09-27 03:10:11 -04:00
|
|
|
|
2021-06-06 16:13:58 -07:00
|
|
|
#include <string_view>
|
|
|
|
|
|
2023-08-28 15:13:34 -07:00
|
|
|
#include <gtest/gtest.h>
|
2020-09-27 03:10:11 -04:00
|
|
|
#include <wpi/SmallString.h>
|
2021-06-06 16:13:58 -07:00
|
|
|
#include <wpi/StringExtras.h>
|
2020-09-27 03:10:11 -04:00
|
|
|
#include <wpi/raw_ostream.h>
|
|
|
|
|
|
|
|
|
|
#include "frc/ScopedTracer.h"
|
2020-12-29 10:30:23 -08:00
|
|
|
#include "frc/simulation/SimHooks.h"
|
2020-09-27 03:10:11 -04:00
|
|
|
|
|
|
|
|
TEST(ScopedTracerTest, Timing) {
|
2021-06-06 16:13:58 -07:00
|
|
|
wpi::SmallString<128> buf;
|
|
|
|
|
wpi::raw_svector_ostream os(buf);
|
|
|
|
|
|
2020-12-29 10:30:23 -08:00
|
|
|
frc::sim::PauseTiming();
|
2020-09-27 03:10:11 -04:00
|
|
|
{
|
|
|
|
|
frc::ScopedTracer tracer("timing_test", os);
|
2020-12-29 10:30:23 -08:00
|
|
|
frc::sim::StepTiming(1.5_s);
|
2020-09-27 03:10:11 -04:00
|
|
|
}
|
2020-12-29 10:30:23 -08:00
|
|
|
frc::sim::ResumeTiming();
|
2020-09-27 03:10:11 -04:00
|
|
|
|
2021-06-06 16:13:58 -07:00
|
|
|
std::string_view out = os.str();
|
|
|
|
|
EXPECT_TRUE(wpi::starts_with(out, " timing_test: 1.5"));
|
2020-09-27 03:10:11 -04:00
|
|
|
}
|