diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000..32a73da --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,45 @@ +name: CMake CI Matrix + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build-and-test: + name: Build and Test on ${{ matrix.os }} with ${{ matrix.compiler }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + include: + - os: ubuntu-latest + compiler: GCC + install: sudo apt-get update && sudo apt-get install -y build-essential + build-dir: build-gcc + - os: macos-latest + compiler: Clang + install: "" + build-dir: build-clang + + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: ${{ matrix.install }} + - name: Configure + run: | + mkdir ${{ matrix.build-dir }} && cd ${{ matrix.build-dir }} + cmake .. + - name: Build + run: | + cd ${{ matrix.build-dir }} + make -j6 + - name: Example + run: | + cd ${{ matrix.build-dir }} + make example + - name: Test + run: | + cd ${{ matrix.build-dir }} + make run-tests \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7e178ed..4f40408 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.10) project(NumbersExample LANGUAGES CXX) -add_executable(${PROJECT_NAME} main.cc) +add_executable(${PROJECT_NAME} EXCLUDE_FROM_ALL main.cc) add_custom_target(example COMMAND ${PROJECT_NAME} DEPENDS ${PROJECT_NAME} - COMMENT "Run Example..." + COMMENT "Running Example..." ) \ No newline at end of file diff --git a/src/include/uinteger.hh b/src/include/uinteger.hh index e69de29..5ce3b28 100644 --- a/src/include/uinteger.hh +++ b/src/include/uinteger.hh @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +template ::value>> +class Uinteger { +public: +// unimplemented! + +private: + T num_; +}; \ No newline at end of file diff --git a/test/integer/integer_test.cc b/test/integer/integer_test.cc index 1235649..e53030f 100644 --- a/test/integer/integer_test.cc +++ b/test/integer/integer_test.cc @@ -119,7 +119,7 @@ TEST(IntegerTest, IntegerCheckedAdd) { { auto num = 10_i64; - Integer num1 = Integer::MAX; + Int64 num1 = Int64::MAX; ASSERT_EQ(num.checked_add(num1), std::nullopt); } @@ -172,7 +172,7 @@ TEST(IntegerTest, IntegerOverflowingAdd) { { auto num = 10_i64; - Integer num1 = Integer::MAX; + Int64 num1 = Int64::MAX; auto [_, flag] = num.overflowing_add(num1); ASSERT_TRUE(flag); } @@ -238,7 +238,7 @@ TEST(IntegerTest, IntegerSaturatingAdd) { { auto num = 10_i64; - Integer num1 = Integer::MAX; + Int64 num1 = Int64::MAX; auto ret = num.saturating_add(num1); ASSERT_EQ(ret, Int64::MAX); } @@ -283,7 +283,7 @@ TEST(IntegerTest, IntegerAddOverflow) { { auto num = 10_i64; - Integer num1 = Integer::MAX; + Int64 num1 = Int64::MAX; ASSERT_THROW(num + num1, std::runtime_error); } @@ -801,7 +801,7 @@ TEST(IntegerTest, IntegerAbs) { ASSERT_THROW(min_num.abs(), std::runtime_error); } -TEST(IntegerTest, IntegerAbsNoSizeEffects) { +TEST(IntegerTest, IntegerAbsNoSideEffects) { Int32 num = 10_i32; Int32 tmp_num = num; ASSERT_EQ(num, tmp_num); @@ -835,7 +835,7 @@ TEST(IntegerTest, IntegerOverflowingAbs) { ASSERT_EQ(ret, min_num); } -TEST(IntegerTest, IntegerOverflowingAbsNoSizeEffects) { +TEST(IntegerTest, IntegerOverflowingAbsNoSideEffects) { Int32 num = 10_i32; Int32 tmp_num = num; ASSERT_EQ(num, tmp_num); @@ -862,7 +862,7 @@ TEST(IntegerTest, IntegerSaturatingAbs) { ASSERT_EQ(min_num.saturating_abs(), Integer(Int32::MAX)); } -TEST(IntegerTest, IntegerSaturatingAbsNoSizeEffects) { +TEST(IntegerTest, IntegerSaturatingAbsNoSideEffects) { Int32 num = 10_i32; Int32 tmp_num = num; ASSERT_EQ(num, tmp_num); @@ -888,7 +888,7 @@ TEST(IntegerTest, IntegerCheckedAbs) { ASSERT_EQ(min_num.checked_abs(), std::nullopt); } -TEST(IntegerTest, IntegerCheckedAbsNoSizeEffects) { +TEST(IntegerTest, IntegerCheckedAbsNoSideEffects) { Int32 num = 10_i32; Int32 tmp_num = num; ASSERT_EQ(num, tmp_num); @@ -914,7 +914,7 @@ TEST(IntegerTest, IntegerWrappingAbs) { ASSERT_EQ(min_num.wrapping_abs(), Int32(Int32::MIN)); } -TEST(IntegerTest, IntegerWrappingAbsNoSizeEffects) { +TEST(IntegerTest, IntegerWrappingAbsNoSideEffects) { Int32 num = 10_i32; Int32 tmp_num = num; ASSERT_EQ(num, tmp_num); @@ -940,7 +940,7 @@ TEST(IntegerTest, IntegerNeg) { ASSERT_THROW(-min_num, std::runtime_error); } -TEST(IntegerTest, IntegerNegNoSizeEffects) { +TEST(IntegerTest, IntegerNegNoSideEffects) { Int32 num = 10_i32; Int32 tmp_num = num; ASSERT_EQ(num, tmp_num); @@ -966,7 +966,7 @@ TEST(IntegerTest, IntegerCheckedNeg) { ASSERT_EQ(min_num.checked_neg(), std::nullopt); } -TEST(IntegerTest, IntegerCheckedNegNoSizeEffects) { +TEST(IntegerTest, IntegerCheckedNegNoSideEffects) { Int32 num = 10_i32; Int32 tmp_num = num; ASSERT_EQ(num, tmp_num); @@ -1000,7 +1000,7 @@ TEST(IntegerTest, IntegerOverflowingNeg) { ASSERT_EQ(ret, min_num); } -TEST(IntegerTest, IntegerOverflowingNegNoSizeEffects) { +TEST(IntegerTest, IntegerOverflowingNegNoSideEffects) { Int32 num = 10_i32; Int32 tmp_num = num; ASSERT_EQ(num, tmp_num); @@ -1026,7 +1026,7 @@ TEST(IntegerTest, IntegerWrappingNeg) { ASSERT_EQ(min_num.wrapping_neg(), min_num); } -TEST(IntegerTest, IntegerWrappingNegNoSizeEffects) { +TEST(IntegerTest, IntegerWrappingNegNoSideEffects) { Int32 num = 10_i32; Int32 tmp_num = num; ASSERT_EQ(num, tmp_num); @@ -1052,7 +1052,7 @@ TEST(IntegerTest, IntegerSaturatingNeg) { ASSERT_EQ(min_num.saturating_neg(), max_num); } -TEST(IntegerTest, IntegerSaturatingNegNoSizeEffects) { +TEST(IntegerTest, IntegerSaturatingNegNoSideEffects) { Int32 num = 10_i32; Int32 tmp_num = num; ASSERT_EQ(num, tmp_num);