turned printing into assert tests and added more tests to track.cpp
This commit is contained in:
parent
63f9f0a7fd
commit
ae9d9cd27d
1 changed files with 14 additions and 7 deletions
21
track.cpp
21
track.cpp
|
@ -1,3 +1,4 @@
|
|||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
// requires C++23 to compile
|
||||
|
@ -17,16 +18,22 @@ public:
|
|||
ret.counter--;
|
||||
return ret;
|
||||
}
|
||||
friend std::ostream &operator<<(std::ostream &lhs, A const &rhs) {
|
||||
lhs << rhs.counter;
|
||||
return lhs;
|
||||
}
|
||||
// friend std::ostream &operator<<(std::ostream &lhs, A const &rhs) {
|
||||
// lhs << rhs.counter;
|
||||
// return lhs;
|
||||
// }
|
||||
operator long long() { return counter; }
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
A a;
|
||||
std::cout << a[] << std::endl;
|
||||
std::cout << a[]() << std::endl;
|
||||
std::cout << a[]()() << std::endl;
|
||||
assert(a == 0);
|
||||
assert(a[] == -1);
|
||||
assert(a[]() == 0);
|
||||
assert(a[]()() == 1);
|
||||
int i = a;
|
||||
assert(i == 0);
|
||||
i = a()()();
|
||||
assert(i == 3);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue