test_sdformat.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. */
  6. #include <cstdio>
  7. #include <string_view>
  8. // This is just a basic include and compile test
  9. #include <sdformat.hh>
  10. int main(int argc, char** argv)
  11. {
  12. if (argc < 2)
  13. {
  14. printf("Usage: %s [SDF VERSION_FULL]\n", argv[0]);
  15. return 1;
  16. }
  17. std::string_view sdfVersionFull = argv[1];
  18. printf(R"(Validating SDF version "%.*s": )", sdfVersionFull.size(), sdfVersionFull.data());
  19. if (sdfVersionFull != SDF_VERSION_FULL)
  20. {
  21. printf("Failure\n"
  22. R"(SDformat SDF_VERSION_FULL returned a version of "%s". Expecting "%.*s".)" "\n",
  23. SDF_VERSION_FULL, sdfVersionFull.size(), sdfVersionFull.data());
  24. return 1;
  25. }
  26. else
  27. {
  28. printf("OK\n");
  29. }
  30. sdf::SDF defaultSdf;
  31. const std::string& sdfVersion = defaultSdf.Version();
  32. printf(R"(Validating new SDF object has a non-empty version string: )");
  33. if (sdfVersion.empty())
  34. {
  35. printf("Failure\n" "SDF object version string is empty\n");
  36. return 1;
  37. }
  38. else
  39. {
  40. printf("OK\n");
  41. }
  42. return 0;
  43. }