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 <iostream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
// requires C++23 to compile
|
// requires C++23 to compile
|
||||||
|
@ -17,16 +18,22 @@ public:
|
||||||
ret.counter--;
|
ret.counter--;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
friend std::ostream &operator<<(std::ostream &lhs, A const &rhs) {
|
// friend std::ostream &operator<<(std::ostream &lhs, A const &rhs) {
|
||||||
lhs << rhs.counter;
|
// lhs << rhs.counter;
|
||||||
return lhs;
|
// return lhs;
|
||||||
}
|
// }
|
||||||
|
operator long long() { return counter; }
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
A a;
|
A a;
|
||||||
std::cout << a[] << std::endl;
|
assert(a == 0);
|
||||||
std::cout << a[]() << std::endl;
|
assert(a[] == -1);
|
||||||
std::cout << a[]()() << std::endl;
|
assert(a[]() == 0);
|
||||||
|
assert(a[]()() == 1);
|
||||||
|
int i = a;
|
||||||
|
assert(i == 0);
|
||||||
|
i = a()()();
|
||||||
|
assert(i == 3);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue