X-Git-Url: https://git.xandkar.net/?p=hope.git;a=blobdiff_plain;f=test%2Fhope_list_SUITE.erl;h=819c4fc476be5bcee3105e8a0e501f4a5c7cba10;hp=751157d1ce498f54d11c0b3d3c824d5d55659d6b;hb=f4780d184dddbe3233fed77dac7ddeb74c4f5b02;hpb=8dad2fafa947042d0f63de1c6c9da999490b1c89 diff --git a/test/hope_list_SUITE.erl b/test/hope_list_SUITE.erl index 751157d..819c4fc 100644 --- a/test/hope_list_SUITE.erl +++ b/test/hope_list_SUITE.erl @@ -1,5 +1,7 @@ -module(hope_list_SUITE). +-include_lib("proper/include/proper.hrl"). + %% Callbacks -export( [ all/0 @@ -14,6 +16,8 @@ -define(GROUP , hope_list). +-define(PROPTEST(A), true = proper:quickcheck(A())). + %% ============================================================================ %% Common Test callbacks @@ -35,11 +39,12 @@ groups() -> %% ============================================================================= t_unique_preserve_order(_Cfg) -> - ListAGiven = [a, a, g, b, f, c, a, d, a, e, f, d], - ListBGiven = "australia", - ListAExpected = [a, g, b, f, c, d, e], - ListBExpected = "austrli", - ListAComputed = hope_list:unique_preserve_order(ListAGiven), - ListBComputed = hope_list:unique_preserve_order(ListBGiven), - ListAComputed = ListAExpected, - ListBComputed = ListBExpected. + ?PROPTEST(prop_unique_preserve_order). + +prop_unique_preserve_order() -> + ?FORALL(L, list(), + begin + Duplicates = L -- lists:usort(L), + hope_list:unique_preserve_order(L) == + lists:reverse(lists:reverse(L) -- Duplicates) + end).