Files
allwpilib/wpilibc/src/test/native/cpp/ScopedTracerTest.cpp
Tyler Veness 1705b2d61c Upgrade wpiformat and use clang-format's include sorting (#8350)
This PR also uses the newly added -default-branch flag to generate the list of changed files with respect to the correct branch (2027).
2025-11-11 18:05:12 -08:00

30 lines
799 B
C++

// 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.
#include "wpi/system/ScopedTracer.hpp"
#include <string_view>
#include <gtest/gtest.h>
#include "wpi/simulation/SimHooks.hpp"
#include "wpi/util/SmallString.hpp"
#include "wpi/util/StringExtras.hpp"
#include "wpi/util/raw_ostream.hpp"
TEST(ScopedTracerTest, Timing) {
wpi::util::SmallString<128> buf;
wpi::util::raw_svector_ostream os(buf);
wpi::sim::PauseTiming();
{
wpi::ScopedTracer tracer("timing_test", os);
wpi::sim::StepTiming(1.5_s);
}
wpi::sim::ResumeTiming();
std::string_view out = os.str();
EXPECT_TRUE(wpi::util::starts_with(out, "\ttiming_test: 1.5"));
}