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.

status_test.cc 1.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Copyright 2019 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. #include "minddata/dataset/util/status.h"
  17. #include "common/common.h"
  18. #include "gtest/gtest.h"
  19. #include "utils/log_adapter.h"
  20. using namespace mindspore::dataset;
  21. class MindDataTestStatus : public UT::Common {
  22. public:
  23. MindDataTestStatus() {}
  24. };
  25. // This function returns Status
  26. Status f1() {
  27. Status rc(StatusCode::kUnexpectedError, "Testing macro");
  28. RETURN_IF_NOT_OK(rc);
  29. // We shouldn't get here
  30. return Status::OK();
  31. }
  32. Status f3() {
  33. RETURN_STATUS_UNEXPECTED("Testing macro3");
  34. }
  35. TEST_F(MindDataTestStatus, Test1) {
  36. // Test default constructor which should be OK
  37. Status rc;
  38. ASSERT_TRUE(rc.IsOk());
  39. Status err1(StatusCode::kOutOfMemory, __LINE__, __FILE__);
  40. MS_LOG(DEBUG) << err1;
  41. ASSERT_TRUE(err1.IsOutofMemory());
  42. ASSERT_TRUE(err1.IsError());
  43. Status err2(StatusCode::kUnexpectedError, __LINE__, __FILE__, "Oops");
  44. MS_LOG(DEBUG) << err2;
  45. }
  46. TEST_F(MindDataTestStatus, Test2) {
  47. Status rc = f1();
  48. MS_LOG(DEBUG) << rc;
  49. }
  50. TEST_F(MindDataTestStatus, Test3) {
  51. Status rc = f3();
  52. MS_LOG(DEBUG) << rc;
  53. }