hope_list:unique_preserve_order/1 property test
authorPaul Oliver <puzza007@gmail.com>
Tue, 19 Aug 2014 09:41:51 +0000 (11:41 +0200)
committerPaul Oliver <puzza007@gmail.com>
Tue, 19 Aug 2014 09:41:51 +0000 (11:41 +0200)
.gitignore
Makefile
rebar.config
test/hope_list_SUITE.erl

index 76b3746..34f27b0 100644 (file)
@@ -1,3 +1,4 @@
 ebin/
 logs/
 test/*.beam
+/deps/proper/
index 34c0fe9..3d80498 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,14 @@
        fresh-build \
        compile \
        clean \
+       deps \
+       deps-get \
+       deps-update \
        dialyze \
        test
 
 ci: \
+       deps \
        compile \
        test
 
@@ -20,6 +24,16 @@ compile:
 clean:
        @rebar clean
 
+deps: \
+       deps-get \
+       deps-update
+
+deps-get:
+       @rebar get-deps
+
+deps-update:
+       @rebar update-deps
+
 dialyze:
        @dialyzer ebin
 
index a760517..986fa40 100644 (file)
@@ -1 +1,6 @@
+%%% -*- mode: erlang -*-
 {clean_files, ["test/*.beam"]}.
+
+{deps,
+ [{proper, ".*", {git, "https://github.com/manopapad/proper.git", {tag, "v1.1"}}}]
+}.
index 751157d..819c4fc 100644 (file)
@@ -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).
This page took 0.020806 seconds and 4 git commands to generate.