Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) 2020 FIRST. All Rights Reserved. */ |
| 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
| 6 | /*----------------------------------------------------------------------------*/ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <thread> |
| 10 | |
| 11 | #include <wpi/SmallString.h> |
| 12 | #include <wpi/StringRef.h> |
| 13 | #include <wpi/raw_ostream.h> |
| 14 | |
| 15 | #include "frc/ScopedTracer.h" |
| 16 | #include "gtest/gtest.h" |
| 17 | |
| 18 | wpi::SmallString<128> buf; |
| 19 | wpi::raw_svector_ostream os(buf); |
| 20 | |
| 21 | #ifdef __APPLE__ |
| 22 | TEST(ScopedTracerTest, DISABLED_Timing) { |
| 23 | #else |
| 24 | TEST(ScopedTracerTest, Timing) { |
| 25 | #endif |
| 26 | { |
| 27 | frc::ScopedTracer tracer("timing_test", os); |
| 28 | std::this_thread::sleep_for(std::chrono::milliseconds(1500)); |
| 29 | } |
| 30 | |
| 31 | wpi::StringRef out = os.str(); |
| 32 | EXPECT_TRUE(out.startswith(" timing_test: 1.5")); |
| 33 | } |