complex.cxx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include "cmTestConfigure.h"
  2. #include "ExtraSources/file1.h"
  3. #include "file2.h"
  4. #include "sharedFile.h"
  5. #include "cmStandardIncludes.h"
  6. int passed = 0;
  7. int failed = 0;
  8. void Failed(const char* Message, const char* m2= "")
  9. {
  10. std::cerr << "Failed: " << Message << m2 << "\n";
  11. failed++;
  12. }
  13. void Passed(const char* Message, const char* m2="")
  14. {
  15. std::cout << "Passed: " << Message << m2 << "\n";
  16. passed++;
  17. }
  18. main()
  19. {
  20. if(sharedFunction() != 1)
  21. {
  22. Failed("Call to sharedFunction from shared library failed.");
  23. }
  24. else
  25. {
  26. Passed("Call to sharedFunction from shared library worked.");
  27. }
  28. if(file1() != 1)
  29. {
  30. Failed("Call to file1 function from library failed.");
  31. }
  32. else
  33. {
  34. Passed("Call to file1 function returned 1.");
  35. }
  36. if(file2() != 1)
  37. {
  38. Failed("Call to file2 function from library failed.");
  39. }
  40. else
  41. {
  42. Passed("Call to file2 function returned 1.");
  43. }
  44. #ifndef CMAKE_IS_FUN
  45. Failed("CMake is not fun, so it is broken and should be fixed.");
  46. #else
  47. Passed("CMAKE_IS_FUN is defined.");
  48. #endif
  49. #ifdef SHOULD_NOT_BE_DEFINED
  50. Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
  51. #else
  52. Passed("SHOULD_NOT_BE_DEFINED is not defined.");
  53. #endif
  54. #ifndef SHOULD_BE_DEFINED
  55. Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
  56. #else
  57. Passed("SHOULD_BE_DEFINED is defined.");
  58. #endif
  59. #ifndef ONE_VAR
  60. Failed("cmakedefine is broken, ONE_VAR is not defined.");
  61. #else
  62. Passed("ONE_VAR is defined.");
  63. #endif
  64. #ifdef ZERO_VAR
  65. Failed("cmakedefine is broken, ZERO_VAR is defined.");
  66. #else
  67. Passed("ZERO_VAR is not defined.");
  68. #endif
  69. #ifndef STRING_VAR
  70. Failed("configureFile is broken, STRING_VAR is not defined.");
  71. #else
  72. if(strcmp(STRING_VAR, "CMake is great") != 0)
  73. {
  74. Failed("CMake is not great, so the SET command,"
  75. "or the configurefile comand is broken. STRING_VAR== ",
  76. STRING_VAR);
  77. }
  78. else
  79. {
  80. Passed("STRING_VAR == ", STRING_VAR);
  81. }
  82. #endif
  83. std::cout << "Passed:" << passed << "\n";
  84. if(failed)
  85. {
  86. std::cout << "Failed: " << failed << "\n";
  87. return failed;
  88. }
  89. return 0;
  90. }