Browse Source

Extra constructor for simple testing.

Former-commit-id: 0fcef3d5e7
tempestpy_adaptions
sjunges 9 years ago
parent
commit
d4ba7905fa
  1. 5
      src/storage/BitVector.cpp
  2. 5
      src/storage/BitVector.h
  3. 15
      test/functional/storage/BitVectorTest.cpp

5
src/storage/BitVector.cpp

@ -78,6 +78,11 @@ namespace storm {
set(begin, end); set(begin, end);
} }
BitVector::BitVector(uint_fast64_t length, std::vector<uint_fast64_t> setEntries) : BitVector(length, setEntries.begin(), setEntries.end())
{
// Intentionally left empty.
}
BitVector::BitVector(uint_fast64_t bucketCount, uint_fast64_t bitCount) : bitCount(bitCount), bucketVector(bucketCount) { BitVector::BitVector(uint_fast64_t bucketCount, uint_fast64_t bitCount) : bitCount(bitCount), bucketVector(bucketCount) {
STORM_LOG_ASSERT((bucketCount << 6) == bitCount, "Bit count does not match number of buckets."); STORM_LOG_ASSERT((bucketCount << 6) == bitCount, "Bit count does not match number of buckets.");
} }

5
src/storage/BitVector.h

@ -118,6 +118,11 @@ namespace storm {
template<typename InputIterator> template<typename InputIterator>
BitVector(uint_fast64_t length, InputIterator first, InputIterator last); BitVector(uint_fast64_t length, InputIterator first, InputIterator last);
/*!
* Creates a bit vector that has exactly the bits set that are given by the vector
*/
BitVector(uint_fast64_t length, std::vector<uint_fast64_t> setEntries);
/*! /*!
* Performs a deep copy of the given bit vector. * Performs a deep copy of the given bit vector.
* *

15
test/functional/storage/BitVectorTest.cpp

@ -39,6 +39,21 @@ TEST(BitVectorTest, InitFromIterator) {
} }
} }
TEST(BitVectorTest, InitFromIntVector) {
std::vector<uint_fast64_t> valueVector = {0, 4, 10};
storm::storage::BitVector vector(32, valueVector);
ASSERT_EQ(32ul, vector.size());
for (uint_fast64_t i = 0; i < 32; ++i) {
if (i == 0 || i == 4 || i == 10) {
ASSERT_TRUE(vector.get(i));
} else {
ASSERT_FALSE(vector.get(i));
}
}
}
TEST(BitVectorTest, GetSet) { TEST(BitVectorTest, GetSet) {
storm::storage::BitVector vector(32); storm::storage::BitVector vector(32);

Loading…
Cancel
Save