12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #ifndef TEST_NUMBERSVECTOR_HPP
- #define TEST_NUMBERSVECTOR_HPP
- #include <cxxtest/TestSuite.h>
- #include "chunkfile/chunkfile/numbersvector-inl.h"
- #include "gen_test_numbers.hpp"
- using namespace std;
- //
- /**
- @author Frank Michler,,, <frank@pc13365>
- */
- class Test_NumbersVector : public CxxTest::TestSuite
- {
- public:
- void testVectorsAreEqual()
- {
- vector<int> Vec1 = getIntTestNumbers<int>();
- vector<int> Vec2 = getIntTestNumbers<int>();
- TS_ASSERT(vectorsAreEqual(Vec1, Vec2));
- }
- void testVectorsAreDifferent()
- {
- vector<int> Vec1 = getIntTestNumbers<int>();
- vector<int> Vec2 = getIntTestNumbers2<int>();
- TS_ASSERT(!vectorsAreEqual(Vec1, Vec2));
- }
- void testVectorsNotEqualDueToCharOverflow()
- {
- vector<int> Vec1 = getIntTestNumbers<int>();
- vector<char> Vec2 = getIntTestNumbers<char>();
- TS_ASSERT(!vectorsAreEqual(Vec1, Vec2));
- }
- void testExceptionOnBadConversion()
- {
- vector<int> Vec1 = getIntTestNumbers<int>();
-
- ConvertibleNumbersVector* ConvNumVec= ConvertibleNumbersVector::create(Vec1);
- vector<char> CharVec;
- vector<long> LongVec;
- TS_ASSERT_THROWS(ConvNumVec->copyTo(CharVec), DataLossAtVectorCast);
- TS_ASSERT_THROWS_NOTHING(ConvNumVec->copyTo(LongVec));
- TS_ASSERT(vectorsAreEqual(Vec1, LongVec));
-
- delete ConvNumVec;
- }
-
- private:
-
- };
- #endif
|