1 /*
2 * Copyright 2019 Google LLC
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
17 #include "fcp/tensorflow/status.h"
18
19 #include "gmock/gmock.h"
20 #include "gtest/gtest.h"
21
22 namespace fcp {
23
24 using ::testing::Eq;
25
TEST(StatusTest,ToTensorFlow_Ok)26 TEST(StatusTest, ToTensorFlow_Ok) {
27 EXPECT_THAT(ConvertToTensorFlowStatus(FCP_STATUS(OK)),
28 Eq(tensorflow::OkStatus()));
29 }
30
TEST(StatusTest,ToTensorFlow_Error)31 TEST(StatusTest, ToTensorFlow_Error) {
32 Status error = FCP_STATUS(NOT_FOUND) << "Where is my mind?";
33 EXPECT_THAT(ConvertToTensorFlowStatus(error),
34 // Remove the cast after TF 2.12 is released and used in FCP.
35 Eq(tensorflow::Status(
36 static_cast<tsl::errors::Code>(absl::StatusCode::kNotFound),
37 error.message())));
38 }
39
40 } // namespace fcp
41