General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.0 KiB

  1. #include "test_scaffold.h"
  2. #include "gp/array.hpp"
  3. #include <thread>
  4. #include <chrono>
  5. #include <numeric>
  6. #include <iomanip>
  7. #include <fstream>
  8. struct arraysum_test : public test_scaffold {
  9. arraysum_test() {
  10. name = __FILE__ ":1";
  11. }
  12. virtual int run() {
  13. gp::array<uint32_t, 16> test;
  14. for(auto& elem : test)
  15. {
  16. elem = 12;
  17. }
  18. return std::accumulate(test.begin(), test.end(), 0) != 12*test.size();
  19. }
  20. };
  21. append_test dummy_sd45uisd3(new arraysum_test{});
  22. struct optional_test : public test_scaffold {
  23. optional_test() {
  24. name = __FILE__ ":1";
  25. }
  26. virtual int run() {
  27. int res = 0;
  28. {
  29. gp::optional<uint32_t> test;
  30. if(test.has_value())
  31. {
  32. res++;
  33. }
  34. test = 12;
  35. if(test.has_value())
  36. {
  37. if(test.value()!=12)
  38. {
  39. res++;
  40. }
  41. }
  42. else
  43. {
  44. res++;
  45. }
  46. }
  47. {
  48. gp::optional<std::ifstream> test;
  49. if(test.has_value())
  50. {
  51. res++;
  52. }
  53. test = std::ifstream("/proc/cpuinfo");
  54. if(!test.has_value())
  55. {
  56. res++;
  57. }
  58. }
  59. return res;
  60. }
  61. };
  62. append_test dummy_mlyusisd3(new optional_test{});