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

feat(add): github actions #4

Merged
merged 5 commits into from
Feb 14, 2024
Merged
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
45 changes: 45 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
)
13 changes: 13 additions & 0 deletions src/include/uinteger.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
#include <limits>
#include <optional>
#include <type_traits>

template <typename T, typename = std::enable_if_t<std::is_unsigned<T>::value>>
class Uinteger {
public:
// unimplemented!

private:
T num_;
};
28 changes: 14 additions & 14 deletions test/integer/integer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ TEST(IntegerTest, IntegerCheckedAdd) {

{
auto num = 10_i64;
Integer<long> num1 = Integer<long>::MAX;
Int64 num1 = Int64::MAX;
ASSERT_EQ(num.checked_add(num1), std::nullopt);
}

Expand Down Expand Up @@ -172,7 +172,7 @@ TEST(IntegerTest, IntegerOverflowingAdd) {

{
auto num = 10_i64;
Integer<long> num1 = Integer<long>::MAX;
Int64 num1 = Int64::MAX;
auto [_, flag] = num.overflowing_add(num1);
ASSERT_TRUE(flag);
}
Expand Down Expand Up @@ -238,7 +238,7 @@ TEST(IntegerTest, IntegerSaturatingAdd) {

{
auto num = 10_i64;
Integer<long> num1 = Integer<long>::MAX;
Int64 num1 = Int64::MAX;
auto ret = num.saturating_add(num1);
ASSERT_EQ(ret, Int64::MAX);
}
Expand Down Expand Up @@ -283,7 +283,7 @@ TEST(IntegerTest, IntegerAddOverflow) {

{
auto num = 10_i64;
Integer<long> num1 = Integer<long>::MAX;
Int64 num1 = Int64::MAX;
ASSERT_THROW(num + num1, std::runtime_error);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Loading