-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdate_test.cc
45 lines (35 loc) · 839 Bytes
/
date_test.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
34
35
36
37
38
39
40
41
42
43
44
45
#include "date.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
static int errors = 0;
ostream& ERROR() {
++errors;
cout << "Error: ";
return cout;
}
bool TestToString() {
bool success = true;
Date d;
d.SetToNow();
string str = d.ToString();
int good_strlen = 24;
cout << "\"" << str << "\"" << endl;
if (str.length() > good_strlen) {
success = false;
ERROR() << "Date's stl string's length was > " << good_strlen << " ("
<< str.length() << ")" << endl;
}
if (strlen(str.c_str()) > good_strlen) {
success = false;
ERROR() << "Date's char* length was > " << good_strlen << " ("
<< strlen(str.c_str()) << ")" << endl;
}
return success;
}
int main() {
bool s = TestToString();
cout << errors << " errors." << endl;
return s;
}