Skip to content

Commit

Permalink
PBT テストを追加する
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Jul 28, 2024
1 parent 0c97851 commit 285fc67
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
image: shiguredo/erlang:otp-27.0.1-openssl-3.3.1-ubuntu-24.04-x86_64
steps:
- uses: actions/checkout@v4
- run: make
- run: make ci
- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@v2
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

- [CHANGE] rebar3 の minimum_otp_vsn を 27.0 にする
- @voluntas
- [ADD] PBT を追加
- clockwork のみ
- @voluntas
- [UPDATE] rebar3 3.23.0 に更新する
- @voluntas
- [UPDATE] GitHub Actions の docker の OTP を 27.0.1 / OpenSSL 3.3.1 に上げる
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
.PHONY: all upgrade compile test dialyzer clean github
.PHONY: all upgrade compile dialyzer test proper clean ci publish

all: clean upgrade compile test dialyzer
all: clean upgrade compile dialyzer test proper

upgrade:
@./rebar3 do update, upgrade --all

compile:
@./rebar3 xref

dialyzer:
@./rebar3 dialyzer

test:
@./rebar3 as test eunit, cover

dialyzer:
@./rebar3 dialyzer
proper:
@./rebar3 as test proper

clean:
@./rebar3 clean

github:
$(MAKE) compile
$(MAKE) dialyzer
$(MAKE) test
ci: compile dialyzer test proper

publish:
@./rebar3 hex publish package
5 changes: 5 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@
{elvis_output_format, colors}.

{plugins, [rebar3_hex]}.

{profiles,
[{test,
[{plugins, [rebar3_proper]},
{deps, [{proper, {git, "https://github.com/proper-testing/proper", {branch, "master"}}}]}]}]}.
35 changes: 35 additions & 0 deletions test/prop_base32_clockwork.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-module(prop_base32_clockwork).

-export([prop_base32_clockwork_encode_decode/1]).

-include_lib("proper/include/proper.hrl").


prop_base32_clockwork_encode_decode(doc) ->
"base32_clockwork を encode して decode する";
prop_base32_clockwork_encode_decode(opts) ->
[{numtests, 100000}, {on_output, fun proper_output/2}].


prop_base32_clockwork_encode_decode() ->
?FORALL(N,
range(1, 100),
?FORALL(RandomBytes,
binary(N),
begin
Base32edBytes = base32_clockwork:encode(RandomBytes),
case base32_clockwork:decode(Base32edBytes) of
{ok, RandomBytes} ->
true;
{ok, _} ->
false;
{error, _Reason} ->
false
end
end)).


proper_output(".", _Args) ->
ok;
proper_output(Format, Args) ->
io:format(Format, Args).

0 comments on commit 285fc67

Please sign in to comment.