You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

common.h 3.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Copyright 2019-2021 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef TESTS_DATASET_UT_CORE_COMMON_DE_UT_COMMON_H_
  17. #define TESTS_DATASET_UT_CORE_COMMON_DE_UT_COMMON_H_
  18. #include "gtest/gtest.h"
  19. #include "include/api/status.h"
  20. #include "include/api/types.h"
  21. #include "minddata/dataset/core/tensor_shape.h"
  22. #include "minddata/dataset/include/type_id.h"
  23. #include "utils/log_adapter.h"
  24. using mindspore::Status;
  25. using mindspore::StatusCode;
  26. #define ASSERT_OK(_s) \
  27. do { \
  28. Status __rc = (_s); \
  29. if (__rc.IsError()) { \
  30. MS_LOG(ERROR) << __rc.ToString() << "."; \
  31. ASSERT_TRUE(false); \
  32. } \
  33. } while (false)
  34. #define EXPECT_OK(_s) \
  35. do { \
  36. Status __rc = (_s); \
  37. if (__rc.IsError()) { \
  38. MS_LOG(ERROR) << __rc.ToString() << "."; \
  39. EXPECT_TRUE(false); \
  40. } \
  41. } while (false)
  42. #define ASSERT_ERROR(_s) \
  43. do { \
  44. Status __rc = (_s); \
  45. if (__rc.IsOk()) { \
  46. MS_LOG(ERROR) << __rc.ToString() << "."; \
  47. ASSERT_TRUE(false); \
  48. } \
  49. } while (false)
  50. #define EXPECT_ERROR(_s) \
  51. do { \
  52. Status __rc = (_s); \
  53. if (__rc.IsOk()) { \
  54. MS_LOG(ERROR) << __rc.ToString() << "."; \
  55. EXPECT_TRUE(false); \
  56. } \
  57. } while (false)
  58. namespace UT {
  59. class Common : public testing::Test {
  60. public:
  61. // every TEST_F macro will enter one
  62. virtual void SetUp();
  63. virtual void TearDown();
  64. };
  65. class DatasetOpTesting : public Common {
  66. public:
  67. std::vector<mindspore::dataset::TensorShape> ToTensorShapeVec(const std::vector<std::vector<int64_t>> &v);
  68. std::vector<mindspore::dataset::DataType> ToDETypes(const std::vector<mindspore::DataType> &t);
  69. std::string datasets_root_path_;
  70. std::string mindrecord_root_path_;
  71. void SetUp() override;
  72. };
  73. } // namespace UT
  74. #endif // TESTS_DATASET_UT_CORE_COMMON_DE_UT_COMMON_H_