From a60e8a8eabde116cc3da920b637bc4f6f5b8b17c Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Thu, 5 Dec 2013 22:21:11 +0100 Subject: Added tests. --- tests/exec/interval.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/exec/interval.cpp (limited to 'tests/exec/interval.cpp') diff --git a/tests/exec/interval.cpp b/tests/exec/interval.cpp new file mode 100644 index 0000000..81661e3 --- /dev/null +++ b/tests/exec/interval.cpp @@ -0,0 +1,29 @@ +#include + +class interval { +public: + int low, hi; + interval(int low, int hi); + void iterate(int& i); + int ok(int& i); + int next(int& i); +}; + +interval::interval(int low, int hi) { + this->low = low; + this->hi = hi; +} + +void interval::iterate(int& i) { i = low; } + +int interval::ok(int& i) { return i <= hi; } + +int interval::next(int& i) { return i++; } + +int main() { + interval s = interval(3, 10); + int i; + s.iterate(i); + while(s.ok(i)) + std::cout << s.next(i) << "\n"; +} -- cgit v1.2.3