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 | 826a9c08b36460927bcbec72425b00078f0ce404 (patch) | |
| tree | 5ab644075062d6d0441d29100fc77e4d7d03d056 /src | |
| parent | 30887043d2636fbefbe79768eab7459af9d291b9 (diff) | |
| download | rabbitmq-server-git-826a9c08b36460927bcbec72425b00078f0ce404.tar.gz | |
More tests.
Diffstat (limited to 'src')
| -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 685bdd7e71..360d3dd273 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, |
