Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitwise assignment operators + tests #72

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ add_executable(OperatorsUnaryArithmeticTest
test/operators/unary_arithmetic.cpp)
target_link_libraries(OperatorsUnaryArithmeticTest TestRunner)

add_executable(OperatorsBitwiseTest
test/operators/bitwise.cpp)
target_link_libraries(OperatorsBitwiseTest TestRunner)

add_executable(OperatorsBitwiseAssignmentTest
test/operators/bitwise_assignment.cpp)
target_link_libraries(OperatorsBitwiseAssignmentTest TestRunner)

if(ENABLE_COVERAGE)
# Include code coverage module
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
Expand All @@ -83,6 +91,8 @@ if(ENABLE_COVERAGE)
add_coverage(OperatorsIOStreamTest)
add_coverage(OperatorsRelationalTest)
add_coverage(OperatorsUnaryArithmeticTest)
add_coverage(OperatorsBitwiseTest)
add_coverage(OperatorsBitwiseAssignmentTest)
list(APPEND LCOV_REMOVE_PATTERNS "'/usr/*'" "'include/third_party/*'")
coverage_evaluate()
endif()
Expand Down Expand Up @@ -110,3 +120,7 @@ add_test(NAME OperatorsRelationalTest
COMMAND $<TARGET_FILE:OperatorsRelationalTest>)
add_test(NAME OperatorsUnaryArithmeticTest
COMMAND $<TARGET_FILE:OperatorsUnaryArithmeticTest>)
add_test(NAME OperatorsBitwiseTest
COMMAND $<TARGET_FILE:OperatorsBitwiseTest>)
add_test(NAME OperatorsBitwiseAssignmentTest
COMMAND $<TARGET_FILE:OperatorsBitwiseAssignmentTest>)
35 changes: 35 additions & 0 deletions include/BigInt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,41 @@ class BigInt {
friend std::istream& operator>>(std::istream&, BigInt&);
friend std::ostream& operator<<(std::ostream&, const BigInt&);

// Bitwise operators:
BigInt operator<<(const BigInt&) const;
BigInt operator>>(const BigInt&) const;
BigInt operator|(const BigInt&) const;
BigInt operator&(const BigInt&) const;
BigInt operator^(const BigInt&) const;
BigInt operator<<(const long long&) const;
BigInt operator>>(const long long&) const;
BigInt operator|(const long long&) const;
BigInt operator&(const long long&) const;
BigInt operator^(const long long&) const;
BigInt operator<<(const std::string&) const;
BigInt operator>>(const std::string&) const;
BigInt operator|(const std::string&) const;
BigInt operator&(const std::string&) const;
BigInt operator^(const std::string&) const;
BigInt operator~() const;

//Bitwise assignment operators:
BigInt& operator<<=(const BigInt&);
BigInt& operator>>=(const BigInt&);
BigInt& operator|=(const BigInt&);
BigInt& operator&=(const BigInt&);
BigInt& operator^=(const BigInt&);
BigInt& operator<<=(const long long&);
BigInt& operator>>=(const long long&);
BigInt& operator|=(const long long&);
BigInt& operator&=(const long long&);
BigInt& operator^=(const long long&);
BigInt& operator<<=(const std::string&);
BigInt& operator>>=(const std::string&);
BigInt& operator|=(const std::string&);
BigInt& operator&=(const std::string&);
BigInt& operator^=(const std::string&);

// Conversion functions:
std::string to_string() const;
int to_int() const;
Expand Down
Loading