25 #ifndef WVALUESETHISTOGRAM_TEST_H
26 #define WVALUESETHISTOGRAM_TEST_H
31 #include <cxxtest/TestSuite.h>
33 #include "../../WValueSet.h"
34 #include "../WValueSetHistogram.h"
48 double a[2] = { 0.0, 3.1415 };
49 const std::shared_ptr< std::vector< double > > v =
50 std::shared_ptr< std::vector< double > >(
51 new std::vector< double >( a, a +
sizeof( a ) /
sizeof(
double ) ) );
56 std::shared_ptr< WValueSet< double > > vsPtr( valueSet );
66 double a[4] = { 0.0, 1.0, 1.0, 4.0 };
67 const std::shared_ptr< std::vector< double > > v =
68 std::shared_ptr< std::vector< double > >(
69 new std::vector< double >( a, a +
sizeof( a ) /
sizeof(
double ) ) );
74 TS_ASSERT_EQUALS( hist[0], 1 );
75 TS_ASSERT_EQUALS( hist[1], 2 );
76 TS_ASSERT_EQUALS( hist[2], 0 );
77 TS_ASSERT_EQUALS( hist[3], 0 );
78 TS_ASSERT_EQUALS( hist[4], 1 );
87 double a[4] = { 0.0, 1.0, 1.0, 4.0 };
88 const std::shared_ptr< std::vector< double > > v =
89 std::shared_ptr< std::vector< double > >(
90 new std::vector< double >( a, a +
sizeof( a ) /
sizeof(
double ) ) );
97 TS_ASSERT_EQUALS( hist.
at( 0 ), 1 );
98 TS_ASSERT_EQUALS( hist.
at( 1 ), 2 );
99 TS_ASSERT_EQUALS( hist.
at( 2 ), 0 );
100 TS_ASSERT_EQUALS( hist.
at( 3 ), 0 );
101 TS_ASSERT_EQUALS( hist.
at( 4 ), 1 );
104 TS_ASSERT_THROWS_ANYTHING( hist.
at( 5 ) );
113 double a[4] = { 0.0, -5.0, 1.0, 2.0 };
114 const std::shared_ptr< std::vector< double > > v =
115 std::shared_ptr< std::vector< double > >(
116 new std::vector< double >( a, a +
sizeof( a ) /
sizeof(
double ) ) );
132 double a[5] = { 0.0, 4.0, 1.0, 2.0, 1.0 };
133 const std::shared_ptr< std::vector< double > > v =
134 std::shared_ptr< std::vector< double > >(
135 new std::vector< double >( a, a +
sizeof( a ) /
sizeof(
double ) ) );
141 TS_ASSERT_EQUALS( hist.
size(), 5 );
151 double a[5] = { 0.0, 4.0, 1.0, 2.0, 1.0 };
152 const std::shared_ptr< std::vector< double > > v =
153 std::shared_ptr< std::vector< double > >(
154 new std::vector< double >( a, a +
sizeof( a ) /
sizeof(
double ) ) );
178 double a[5] = { 0.0, 4.0, 1.0, 2.0, 1.0 };
179 const std::shared_ptr< std::vector< double > > v =
180 std::shared_ptr< std::vector< double > >(
181 new std::vector< double >( a, a +
sizeof( a ) /
sizeof(
double ) ) );
186 std::cout << hist << std::endl;
188 TS_ASSERT_EQUALS( hist.
accumulate( 0, 2 ), 3 );
189 TS_ASSERT_EQUALS( hist.
accumulate( 2, 0 ), 3 );
190 TS_ASSERT_EQUALS( hist.
accumulate( 2, 2 ), 0 );
191 TS_ASSERT( hist.
accumulate( 2, 2 ) != hist[ 2 ] );
193 TS_ASSERT_THROWS_ANYTHING( hist.
accumulate( 0, 123 ) );
202 double a[5] = { 0.0, 4.0, 1.0, 2.0, 1.0 };
203 const std::shared_ptr< std::vector< double > > v =
204 std::shared_ptr< std::vector< double > >(
205 new std::vector< double >( a, a +
sizeof( a ) /
sizeof(
double ) ) );
242 double a[5] = { 0.0, 4.0, 1.0, 2.0, 1.0 };
243 const std::shared_ptr< std::vector< double > > v =
244 std::shared_ptr< std::vector< double > >(
245 new std::vector< double >( a, a +
sizeof( a ) /
sizeof(
double ) ) );
266 TS_ASSERT_EQUALS( hist2.
at( 0 ), 4 );
267 TS_ASSERT_EQUALS( hist2.
at( 1 ), 1 );
double m_minimum
The smallest value.
virtual double getMinimum() const
Returns the minimum value.
double m_maximum
The biggest value.
virtual double getMaximum() const
Returns the maximum value.
void testOperator(void)
Test operator[].
void testInstantiation(void)
Test instantiation.
void testCopyWithoutIntervalChanges(void)
Test copy construction.
void testSizes(void)
Test size(), and getBucketSize()
void testAt(void)
Test at()
void testCopyWithIntervalChanges(void)
Test copy construction with changed interval sizes.
void testMinMax(void)
Test getMinimum(), getMaximum()
void testAccum(void)
Test accumulate.
void testIndex(void)
Test getIndexForValue()
Used to find the occurrence frequencies of values in a value set.
virtual size_t accumulate(size_t startIndex, size_t endIndex) const
Sums up the buckets in the specified interval.
double m_mappedBucketSize
Size of one bucket in the mapped histogram.
virtual size_t at(size_t index) const
Get the count of the bucket.
boost::shared_array< size_t > m_initialBuckets
Pointer to all initial buckets of the histogram.
size_t m_nInitialBuckets
Number of buckets in the initial histogram.
virtual size_t getIndexForValue(double value) const
Returns the right index to the bucket containing the given value.
virtual double getBucketSize(size_t index=0) const
Return the size of one bucket.
double m_initialBucketSize
Size of one bucket in the initial histogram.
size_t m_nMappedBuckets
Tracks the number of a buckets in the mapped histogram.
virtual size_t size() const
Returns the number of buckets in the histogram with the actual mapping.
boost::shared_array< size_t > m_mappedBuckets
Pointer to all initial buckets of the histogram.
Base Class for all value set types.