blob: da222de610e5c9983cb098c7ed3b0b4556e633c3 [file] [log] [blame]
Austin Schuh1e69f942020-11-14 15:06:14 -08001/*----------------------------------------------------------------------------*/
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
18wpi::SmallString<128> buf;
19wpi::raw_svector_ostream os(buf);
20
21#ifdef __APPLE__
22TEST(ScopedTracerTest, DISABLED_Timing) {
23#else
24TEST(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}