WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
Utility.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2016. 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 
14 #include <stdint.h>
15 
16 #include <string>
17 
18 #define wpi_assert(condition) \
19  wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
20 #define wpi_assertWithMessage(condition, message) \
21  wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
22  __FUNCTION__)
23 
24 #define wpi_assertEqual(a, b) \
25  wpi_assertEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
26 #define wpi_assertEqualWithMessage(a, b, message) \
27  wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
28 
29 #define wpi_assertNotEqual(a, b) \
30  wpi_assertNotEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
31 #define wpi_assertNotEqualWithMessage(a, b, message) \
32  wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
33  __FUNCTION__)
34 
35 bool wpi_assert_impl(bool conditionValue, const char* conditionText,
36  const char* message, const char* fileName, int lineNumber,
37  const char* funcName);
38 bool wpi_assertEqual_impl(int valueA, int valueB, const char* valueAString,
39  const char* valueBString, const char* message,
40  const char* fileName, int lineNumber,
41  const char* funcName);
42 bool wpi_assertNotEqual_impl(int valueA, int valueB, const char* valueAString,
43  const char* valueBString, const char* message,
44  const char* fileName, int lineNumber,
45  const char* funcName);
46 
47 void wpi_suspendOnAssertEnabled(bool enabled);
48 
49 namespace frc {
50 
51 int GetFPGAVersion();
52 int64_t GetFPGARevision();
53 uint64_t GetFPGATime();
54 bool GetUserButton();
55 std::string GetStackTrace(int offset);
56 
57 } // namespace frc
bool wpi_assert_impl(bool conditionValue, const char *conditionText, const char *message, const char *fileName, int lineNumber, const char *funcName)
Assert implementation.
Definition: Utility.cpp:29
bool wpi_assertEqual_impl(int valueA, int valueB, const char *valueAString, const char *valueBString, const char *message, const char *fileName, int lineNumber, const char *funcName)
Assert equal implementation.
Definition: Utility.cpp:97
bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *valueAString, const char *valueBString, const char *message, const char *fileName, int lineNumber, const char *funcName)
Assert not equal implementation.
Definition: Utility.cpp:115