Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
| 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 Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame] | 18 | #include "wpi/StringRef.h" |
| 19 | #include "wpi/Twine.h" |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 20 | |
| 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 Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame] | 38 | bool wpi_assert_impl(bool conditionValue, const wpi::Twine &conditionText, |
| 39 | const wpi::Twine &message, wpi::StringRef fileName, |
| 40 | int lineNumber, wpi::StringRef funcName); |
| 41 | bool 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 Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 46 | bool wpi_assertNotEqual_impl(int valueA, int valueB, |
Austin Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame] | 47 | const wpi::Twine &valueAString, |
| 48 | const wpi::Twine &valueBString, |
| 49 | const wpi::Twine &message, wpi::StringRef fileName, |
| 50 | int lineNumber, wpi::StringRef funcName); |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 51 | |
| 52 | void wpi_suspendOnAssertEnabled(bool enabled); |
| 53 | |
| 54 | namespace frc { |
| 55 | |
| 56 | int GetFPGAVersion(); |
| 57 | int64_t GetFPGARevision(); |
| 58 | uint64_t GetFPGATime(); |
| 59 | bool GetUserButton(); |
| 60 | std::string GetStackTrace(int offset); |
| 61 | |
| 62 | } // namespace frc |