-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAnomaly.bt
63 lines (54 loc) · 1.69 KB
/
Anomaly.bt
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// -*- mode: c;-*-
string EXSAnom(string reason){
local string out;
SPrintf(out, "%s: @ %08LXh", reason, FTell());
return out;
};
void Anom(uint64 cond, string msg){
if( !cond ){
Printf("*ANOMALY %s\n", msg);
}
};
// == NULL
void AnomUBytesNull( ubyte b[], string msg ){
local uint64 i;
local string omsg;
for( i = 0; i < sizeof(b); i++ ){
if( b[i] != 0x00 ){
SPrintf(omsg, "%d of %d was not null in %s", i, sizeof(b), msg);
Anom( b[i] != 0x00, EXSAnom(omsg));
}
}
};
// == ZERO
void AnomNotZero( uint a, string msg ){
local string omsg;
SPrintf(omsg, "%s %d != %d", msg, a, 0);
Anom( !a, EXSAnom(omsg));
};
void AnomUIntGTZero( uint a, string msg ){
local string omsg;
SPrintf(omsg, "%s %d was less not greater than zero", msg, a);
Anom( a > 0, EXSAnom(omsg));
};
void AnomUIntGTEZero( uint subject, string msg ){
local string omsg;
SPrintf(omsg, "%s %d was less not greater than or equal to zero", msg, subject);
Anom( subject >= 0, EXSAnom(omsg));
};
// == EQUALITY
void AnomNumberEquals( uint subject, uint expectation, string msg ){
local string omsg;
SPrintf(omsg, "%s was %d which isn't %d", msg, subject, expectation);
Anom( subject == expectation, EXSAnom(omsg));
};
void AnomEnum( string e, uint64 d, string msg ){
local string omsg;
SPrintf(omsg, "%s had an unknown value 0x%04LX", msg, d);
Anom( e != "", EXSAnom(omsg));
};
void AnomNumberInBetween( uint subject, uint min, uint max, string msg ){
local string omsg;
SPrintf(omsg, "%s was %d which isn't between %d and %d", msg, subject, min, max);
Anom( subject >= min && subject <= max, EXSAnom(omsg));
};