bugs.hxx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef BUGS_HXX
  2. #define BUGS_HXX
  3. #include "libbinom/include/binom.hxx"
  4. #include "tester.hxx"
  5. void testBugConstGenericArithmeticAssignment() {
  6. TEST_ANNOUNCE(Constant GenericArithmetic Assignment bug#1);
  7. LOG( RED_TXT "This error is related to the following symbols: binom::GenericValue, binom::GenericValueRef, binom::Number")
  8. LOG( RED_TXT "Solution not found")
  9. GRP_PUSH;
  10. using namespace binom;
  11. LOG("Context:"); GRP_PUSH;
  12. PRINT_RUN(GenericValue a = 5);
  13. PRINT_RUN(const GenericValue b = 15);
  14. PRINT_RUN(GenericValue c = 20);
  15. PRINT_RUN(a = c);
  16. GRP_POP;
  17. LOG( RED_TXT "Problem:"); GRP_PUSH;
  18. LOG("a = b;" RED_TXT " error: object of type 'binom::GenericValue' cannot be assigned because its copy assignment operator is implicitly deleted");
  19. GRP_POP;
  20. LOG( GREEN_TXT "Workarounds:"); GRP_PUSH;
  21. LOG( GREEN_TXT "Way 1: Cast a generic value to a value of a specific type:")
  22. PRINT_RUN(a = int(b));
  23. LOG("Result:");
  24. LOG("a = " << int(a));
  25. LOG( GREEN_TXT "Way 2: Remove type constancy:")
  26. PRINT_RUN(a = c);
  27. PRINT_RUN(a = const_cast<GenericValue&>(b));
  28. LOG("Result:");
  29. LOG("a = " << int(a));
  30. GRP_POP;
  31. GRP_POP;
  32. }
  33. void testAllBugs() {
  34. SEPARATOR
  35. TEST_ANNOUNCE(Bug list:);
  36. LOG("Attention: Known errors in the project and their workarounds are described here");
  37. GRP_PUSH;
  38. testBugConstGenericArithmeticAssignment();
  39. GRP_POP;
  40. }
  41. #endif // BUGS_HXX