blob: be8dc35afa8bf96d971b692ddb4a1efed5008a31 [file] [log] [blame]
Parker Schuhd3b7a8872018-02-19 16:42:27 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008-2017. 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#pragma once
9
10/** @file
11 * Contains global utility functions
12 */
13
14#include <stdint.h>
15
16#include <string>
17
Austin Schuhf6b94632019-02-02 22:11:27 -080018#include "wpi/StringRef.h"
19#include "wpi/Twine.h"
Parker Schuhd3b7a8872018-02-19 16:42:27 -080020
21#define wpi_assert(condition) \
22 wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
23#define wpi_assertWithMessage(condition, message) \
24 wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
25 __FUNCTION__)
26
27#define wpi_assertEqual(a, b) \
28 wpi_assertEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
29#define wpi_assertEqualWithMessage(a, b, message) \
30 wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
31
32#define wpi_assertNotEqual(a, b) \
33 wpi_assertNotEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
34#define wpi_assertNotEqualWithMessage(a, b, message) \
35 wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
36 __FUNCTION__)
37
Austin Schuhf6b94632019-02-02 22:11:27 -080038bool wpi_assert_impl(bool conditionValue, const wpi::Twine &conditionText,
39 const wpi::Twine &message, wpi::StringRef fileName,
40 int lineNumber, wpi::StringRef funcName);
41bool wpi_assertEqual_impl(int valueA, int valueB,
42 const wpi::Twine &valueAString,
43 const wpi::Twine &valueBString,
44 const wpi::Twine &message, wpi::StringRef fileName,
45 int lineNumber, wpi::StringRef funcName);
Parker Schuhd3b7a8872018-02-19 16:42:27 -080046bool wpi_assertNotEqual_impl(int valueA, int valueB,
Austin Schuhf6b94632019-02-02 22:11:27 -080047 const wpi::Twine &valueAString,
48 const wpi::Twine &valueBString,
49 const wpi::Twine &message, wpi::StringRef fileName,
50 int lineNumber, wpi::StringRef funcName);
Parker Schuhd3b7a8872018-02-19 16:42:27 -080051
52void wpi_suspendOnAssertEnabled(bool enabled);
53
54namespace frc {
55
56int GetFPGAVersion();
57int64_t GetFPGARevision();
58uint64_t GetFPGATime();
59bool GetUserButton();
60std::string GetStackTrace(int offset);
61
62} // namespace frc