diff options
Diffstat (limited to '')
-rwxr-xr-x | linden/indra/test/llrandom_tut.cpp | 160 |
1 files changed, 110 insertions, 50 deletions
diff --git a/linden/indra/test/llrandom_tut.cpp b/linden/indra/test/llrandom_tut.cpp index 1bb795e..a842dfd 100755 --- a/linden/indra/test/llrandom_tut.cpp +++ b/linden/indra/test/llrandom_tut.cpp | |||
@@ -1,9 +1,9 @@ | |||
1 | /** | 1 | /** |
2 | * @file llrandom_tut.cpp | 2 | * @file llrandom_tut.cpp |
3 | * @author Phoenix | 3 | * @author Phoenix |
4 | * @date 2007-01-25 | 4 | * @date 2007-01-25 |
5 | * | 5 | * |
6 | * Copyright (c) 2007-2007, Linden Research, Inc. | 6 | * Copyright (c) 2007-2007, Linden Research, Inc. |
7 | * | 7 | * |
8 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
9 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
@@ -23,47 +23,107 @@ | |||
23 | * | 23 | * |
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
26 | * COMPLETENESS OR PERFORMANCE. | 26 | * COMPLETENESS OR PERFORMANCE. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <tut/tut.h> | 29 | #include <tut/tut.h> |
30 | 30 | ||
31 | #include "linden_common.h" | 31 | #include "linden_common.h" |
32 | #include "llrand.h" | 32 | #include "llrand.h" |
33 | #include "lltut.h" | 33 | #include "lltut.h" |
34 | 34 | ||
35 | 35 | ||
36 | namespace tut | 36 | namespace tut |
37 | { | 37 | { |
38 | struct random | 38 | struct random |
39 | { | 39 | { |
40 | }; | 40 | }; |
41 | 41 | ||
42 | typedef test_group<random> random_t; | 42 | typedef test_group<random> random_t; |
43 | typedef random_t::object random_object_t; | 43 | typedef random_t::object random_object_t; |
44 | tut::random_t tut_random("random"); | 44 | tut::random_t tut_random("random"); |
45 | 45 | ||
46 | template<> template<> | 46 | template<> template<> |
47 | void random_object_t::test<1>() | 47 | void random_object_t::test<1>() |
48 | { | 48 | { |
49 | F32 number = 0.0f; | 49 | F32 number = 0.0f; |
50 | for(S32 ii = 0; ii < 100000; ++ii) | 50 | for(S32 ii = 0; ii < 100000; ++ii) |
51 | { | 51 | { |
52 | number = ll_frand(); | 52 | number = ll_frand(); |
53 | ensure("frand >= 0", (number >= 0.0f)); | 53 | ensure("frand >= 0", (number >= 0.0f)); |
54 | ensure("frand < 1", (number < 1.0f)); | 54 | ensure("frand < 1", (number < 1.0f)); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | template<> template<> | 58 | template<> template<> |
59 | void random_object_t::test<2>() | 59 | void random_object_t::test<2>() |
60 | { | 60 | { |
61 | F32 number = 0.0f; | 61 | F64 number = 0.0f; |
62 | for(S32 ii = 0; ii < 100000; ++ii) | 62 | for(S32 ii = 0; ii < 100000; ++ii) |
63 | { | 63 | { |
64 | number = ll_frand(2.0f) - 1.0f; | 64 | number = ll_drand(); |
65 | ensure("frand >= 0", (number >= -1.0f)); | 65 | ensure("drand >= 0", (number >= 0.0)); |
66 | ensure("frand < 1", (number <= 1.0f)); | 66 | ensure("drand < 1", (number < 1.0)); |
67 | } | 67 | } |
68 | } | 68 | } |
69 | } | 69 | |
70 | template<> template<> | ||
71 | void random_object_t::test<3>() | ||
72 | { | ||
73 | F32 number = 0.0f; | ||
74 | for(S32 ii = 0; ii < 100000; ++ii) | ||
75 | { | ||
76 | number = ll_frand(2.0f) - 1.0f; | ||
77 | ensure("frand >= 0", (number >= -1.0f)); | ||
78 | ensure("frand < 1", (number <= 1.0f)); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | template<> template<> | ||
83 | void random_object_t::test<4>() | ||
84 | { | ||
85 | F32 number = 0.0f; | ||
86 | for(S32 ii = 0; ii < 100000; ++ii) | ||
87 | { | ||
88 | number = ll_frand(-7.0); | ||
89 | ensure("drand <= 0", (number <= 0.0)); | ||
90 | ensure("drand > -7", (number > -7.0)); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | template<> template<> | ||
95 | void random_object_t::test<5>() | ||
96 | { | ||
97 | F64 number = 0.0f; | ||
98 | for(S32 ii = 0; ii < 100000; ++ii) | ||
99 | { | ||
100 | number = ll_drand(-2.0); | ||
101 | ensure("drand <= 0", (number <= 0.0)); | ||
102 | ensure("drand > -2", (number > -2.0)); | ||
103 | } | ||
104 | } | ||
105 | |||
106 | template<> template<> | ||
107 | void random_object_t::test<6>() | ||
108 | { | ||
109 | S32 number = 0; | ||
110 | for(S32 ii = 0; ii < 100000; ++ii) | ||
111 | { | ||
112 | number = ll_rand(100); | ||
113 | ensure("rand >= 0", (number >= 0)); | ||
114 | ensure("rand < 100", (number < 100)); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | template<> template<> | ||
119 | void random_object_t::test<7>() | ||
120 | { | ||
121 | S32 number = 0; | ||
122 | for(S32 ii = 0; ii < 100000; ++ii) | ||
123 | { | ||
124 | number = ll_rand(-127); | ||
125 | ensure("rand <= 0", (number <= 0)); | ||
126 | ensure("rand > -127", (number > -127)); | ||
127 | } | ||
128 | } | ||
129 | } | ||