A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
one-uniform-random-variable-many-get-value-calls-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mitch Watrous (watrous@u.washington.edu)
7 */
8
9#include "ns3/config.h"
10#include "ns3/double.h"
11#include "ns3/random-variable-stream.h"
12#include "ns3/test.h"
13
14#include <vector>
15
16/**
17 * \file
18 * \ingroup core-tests
19 * \ingroup randomvariable
20 * \ingroup rng-tests
21 * Test for one uniform random variable stream.
22 */
23
24namespace ns3
25{
26
27namespace tests
28{
29
30/**
31 * \ingroup rng-tests
32 * Test case for one uniform distribution random variable stream generator
33 */
43
46 : TestCase("One Uniform Random Variable with Many GetValue() Calls")
47{
48}
49
54
55void
57{
58 const double min = 0.0;
59 const double max = 10.0;
60
61 Config::SetDefault("ns3::UniformRandomVariable::Min", DoubleValue(min));
62 Config::SetDefault("ns3::UniformRandomVariable::Max", DoubleValue(max));
63
65
66 // Get many values from 1 random number generator.
67 double value;
68 const int count = 100000000;
69 for (int i = 0; i < count; i++)
70 {
71 value = uniform->GetValue();
72
73 NS_TEST_ASSERT_MSG_GT(value, min, "Value less than minimum.");
74 NS_TEST_ASSERT_MSG_LT(value, max, "Value greater than maximum.");
75 }
76}
77
78/**
79 * \ingroup rng-tests
80 * Test suite for one uniform distribution random variable stream generator
81 */
87
94
95/**
96 * \ingroup rng-tests
97 * OneUniformRandomVariableManyGetValueCallsTestSuite instance variable.
98 */
101
102} // namespace tests
103
104} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Smart pointer class similar to boost::intrusive_ptr.
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
static OneUniformRandomVariableManyGetValueCallsTestSuite g_oneUniformRandomVariableManyGetValueCallsTestSuite
OneUniformRandomVariableManyGetValueCallsTestSuite instance variable.
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
Definition test.h:699
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Definition test.h:864
Every class exported by the ns3 library is enclosed in the ns3 namespace.