From ae9d9cd27dd718323bd909b36297831db0ad7262 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Wed, 11 Dec 2024 14:24:49 -0500 Subject: [PATCH] turned printing into assert tests and added more tests to track.cpp --- track.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/track.cpp b/track.cpp index a2c39de..a3a2d95 100644 --- a/track.cpp +++ b/track.cpp @@ -1,3 +1,4 @@ +#include #include #include // 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; }