-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsserts.CC
33 lines (30 loc) · 916 Bytes
/
Asserts.CC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Greg Kaiser
//
// CS290 with Prof. Francis
// 4D Tetris
//
// Asserts.C
// Last modified: April 17, 1996
//
// (C) 1996 Board of Trustees University of Illinois
#include "Asserts.h"
// Given: A SafeCondition, in the form of a boolean expression, and a ErrMsg
// Task: If the SafeCondition isn't true, then the ErrMsg is displayed to
// to the screen as an error and the program is terminated
// Return: Nothing
void Assert(int SafeCondition, char* ErrMsg)
{
if (!SafeCondition) {
std::cerr << "***Error: " << ErrMsg << std::endl;
exit(1);
}
}
// Given: A SafeCondition, in the form of a boolean expression, and a ErrMsg
// Task: If the SafeCondition isn't true, then the ErrMsg is displayed to
// to the screen as a warning
// Return: Nothing
void Warn(int SafeCondition, char* ErrMsg)
{
if (!SafeCondition)
std::cerr << "***Warning: " << ErrMsg << std::endl;
}