diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-05-27 11:56:16 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-05-27 11:56:16 +0100 |
commit | a657998d91000a17b0263aa560bfae4fcd1e8eb5 (patch) | |
tree | 5ab644075062d6d0441d29100fc77e4d7d03d056 | |
parent | 3b1531d8a9fba96844e9b5de0763325344c0a14f (diff) | |
download | rabbitmq-server-a657998d91000a17b0263aa560bfae4fcd1e8eb5.tar.gz |
More tests.
-rw-r--r-- | src/truncate.erl | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/truncate.erl b/src/truncate.erl index 685bdd7e..360d3dd2 100644 --- a/src/truncate.erl +++ b/src/truncate.erl @@ -124,12 +124,19 @@ lim(_) -> limit_exceeded. test() -> test_short_examples_exactly(), + test_term_limit(), test_large_examples_for_size(), ok. test_short_examples_exactly() -> - F = fun (Term, Exp) -> Exp = term(Term, {1, {10, 10, 5, 5}}) end, - FSmall = fun (Term, Exp) -> Exp = term(Term, {1, {2, 2, 2, 2}}) end, + F = fun (Term, Exp) -> + Exp = term(Term, {1, {10, 10, 5, 5}}), + Term = term(Term, {100000, {10, 10, 5, 5}}) + end, + FSmall = fun (Term, Exp) -> + Exp = term(Term, {1, {2, 2, 2, 2}}), + Term = term(Term, {100000, {2, 2, 2, 2}}) + end, F([], []), F("h", "h"), F("hello world", "hello w..."), @@ -147,6 +154,15 @@ test_short_examples_exactly() -> P ! die, ok. +test_term_limit() -> + S = <<"abc">>, + 1 = truncate:term_size(S, 4), + limit_exceeded = truncate:term_size(S, 3), + 90 = truncate:term_size([S, S], 100), + 88 = truncate:term_size([S, [S]], 100), + limit_exceeded = truncate:term_size([S, S], 6), + ok. + test_large_examples_for_size() -> %% Real world values Shrink = fun(Term) -> term(Term, {1, {1000, 100, 50, 5}}) end, |