Skip to content

Commit

Permalink
Add tests for increment and decrement operators
Browse files Browse the repository at this point in the history
  • Loading branch information
faheel committed Oct 10, 2017
1 parent 50e78e1 commit 4b140a5
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/operators/increment_decrement.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#define CATCH_CONFIG_MAIN

#include "constructors/constructors.hpp"
#include "operators/assignment.hpp"
#include "operators/increment_decrement.hpp"
#include "operators/io_stream.hpp"
#include "operators/relational.hpp"
#include "third_party/catch.hpp"


TEST_CASE("Increment operators 1", "[increment][operators]") {
BigInt num;
REQUIRE(num++ == 0);
REQUIRE(num == 1);
REQUIRE(++num == 2);
REQUIRE(num == 2);
}

TEST_CASE("Increment operators 2", "[increment][operators]") {
BigInt num = -1000000000;
REQUIRE(num++ == -1000000000);
REQUIRE(num == -999999999);
REQUIRE(++num == -999999998);
REQUIRE(num == -999999998);
}

TEST_CASE("Decrement operators 1", "[increment][operators]") {
BigInt num;
REQUIRE(num-- == 0);
REQUIRE(num == -1);
REQUIRE(--num == -2);
REQUIRE(num == -2);
}

TEST_CASE("Decrement operators 2", "[increment][operators]") {
BigInt num = -1000000000;
REQUIRE(num-- == -1000000000);
REQUIRE(num == -1000000001);
REQUIRE(--num == -1000000002);
REQUIRE(num == -1000000002);
}

0 comments on commit 4b140a5

Please sign in to comment.