diff --git a/.github/workflows/codeformat-pr.yml b/.github/workflows/codeformat-pr.yml new file mode 100644 index 0000000..b6b9e05 --- /dev/null +++ b/.github/workflows/codeformat-pr.yml @@ -0,0 +1,29 @@ +name: Code Formatting + +on: + pull_request: + branches: + - master + types: [opened, edited, reopened, synchronize] + +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + - uses: julia-actions/setup-julia@v1 + with: + version: 1.6 + - name: Install JuliaFormatter and format + run: julia -e 'import Pkg; Pkg.add("JuliaFormatter"); using JuliaFormatter; format(".")' + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Format files using JuliaFormatter + title: ${{ format('[AUTO] Format {0} using JuliaFormatter', github.event.pull_request.number) }} + body: ${{ format('[JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) would suggest these formatting changes against \#{0}.', github.event.pull_request.number) }} + labels: no changelog + branch: ${{ format('code-format/{0}', github.event.pull_request.number) }} diff --git a/test/runtests.jl b/test/runtests.jl index 3248921..7f0cd19 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,3 +23,23 @@ using Random end end end + +@testset "zero bins" begin + h = SingleThreadFixedWidth2DHistogram() + calc_hist!(h, rand(UInt8, 10, 10), rand(UInt8, 10, 10)) + + @test any(counts(h) .!= 0) + + zero!(h) + @test all(counts(h) .== 0) +end + +@testset "default hist bin type" begin + h = SingleThreadFixedWidth2DHistogram() + @test bin_type(h) == UInt8 +end + +@testset "custom hist bin type" begin + h = SingleThreadFixedWidth2DHistogram(Int32(0), Int32(16), 16) + @test bin_type(h) == Int32 +end