test_numbersvector.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef TEST_NUMBERSVECTOR_HPP
  2. #define TEST_NUMBERSVECTOR_HPP
  3. #include <cxxtest/TestSuite.h>
  4. #include "chunkfile/chunkfile/numbersvector-inl.h"
  5. #include "gen_test_numbers.hpp"
  6. using namespace std;
  7. //
  8. /**
  9. @author Frank Michler,,, <frank@pc13365>
  10. */
  11. class Test_NumbersVector : public CxxTest::TestSuite
  12. {
  13. public:
  14. void testVectorsAreEqual()
  15. {
  16. vector<int> Vec1 = getIntTestNumbers<int>();
  17. vector<int> Vec2 = getIntTestNumbers<int>();
  18. TS_ASSERT(vectorsAreEqual(Vec1, Vec2));
  19. }
  20. void testVectorsAreDifferent()
  21. {
  22. vector<int> Vec1 = getIntTestNumbers<int>();
  23. vector<int> Vec2 = getIntTestNumbers2<int>();
  24. TS_ASSERT(!vectorsAreEqual(Vec1, Vec2));
  25. }
  26. void testVectorsNotEqualDueToCharOverflow()
  27. {
  28. vector<int> Vec1 = getIntTestNumbers<int>();
  29. vector<char> Vec2 = getIntTestNumbers<char>();
  30. TS_ASSERT(!vectorsAreEqual(Vec1, Vec2));
  31. }
  32. void testExceptionOnBadConversion()
  33. {
  34. vector<int> Vec1 = getIntTestNumbers<int>();
  35. ConvertibleNumbersVector* ConvNumVec= ConvertibleNumbersVector::create(Vec1);
  36. vector<char> CharVec;
  37. vector<long> LongVec;
  38. TS_ASSERT_THROWS(ConvNumVec->copyTo(CharVec), DataLossAtVectorCast);
  39. TS_ASSERT_THROWS_NOTHING(ConvNumVec->copyTo(LongVec));
  40. TS_ASSERT(vectorsAreEqual(Vec1, LongVec));
  41. delete ConvNumVec;
  42. }
  43. private:
  44. };
  45. #endif