@@ -22,7 +22,7 @@ static void __timer_start()
2222 struct timeval tv;
2323 if (gettimeofday(&tv, NULL) == 0)
2424 {
25- __time = ( double) tv.tv_sec + ( double) tv.tv_usec * 0.000001;
25+ __time = double( tv.tv_sec) + double( tv.tv_usec) * 0.000001;
2626 }
2727}
2828
@@ -34,6 +34,12 @@ static double __timer_stop()
3434}
3535
3636
37+ static void __eat_whitespace(std::istream& in)
38+ {
39+ while (in.good() && std::isspace(in.peek())) in.get();
40+ }
41+
42+
3743std::ostream& operator << (std::ostream& out, const std::string& str)
3844{
3945 out << '"' << str.c_str() << '"';
@@ -55,7 +61,7 @@ std::ostream& operator << (std::ostream& out, const std::vector<T>& vec)
5561
5662std::istream& operator >> (std::istream& in, std::string& str)
5763{
58- while (in.good() && std::isspace(in.peek())) in.get( );
64+ __eat_whitespace (in);
5965
6066 int c;
6167 if (in.good() && (c = in.get()) == '"')
@@ -74,26 +80,29 @@ std::istream& operator >> (std::istream& in, std::string& str)
7480template <class T>
7581std::istream& operator >> (std::istream& in, std::vector<T>& vec)
7682{
77- while (in.good() && std::isspace(in.peek())) in.get( );
83+ __eat_whitespace (in);
7884
7985 int c;
8086 if (in.good() && (c = in.get()) == '{')
8187 {
82- while (in.good() && std::isspace(in.peek())) in.get();
83- T t;
88+ __eat_whitespace(in);
8489 vec.clear();
8590 while (in.good() && (c = in.get()) != '}')
8691 {
8792 if (c != ',') in.putback(c);
93+
94+ T t;
8895 in >> t;
96+ __eat_whitespace(in);
97+
8998 vec.push_back(t);
90- while (in.good() && std::isspace(in.peek())) in.get();
9199 }
92100 }
93101
94102 return in;
95103}
96104
105+
97106template <class T>
98107bool __equals(const T& actual, const T& expected)
99108{
0 commit comments