1 /*
2 * Copyright 2021 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 #include "fcp/client/engine/caching_error_reporter.h"
17
18 #include <string>
19
20 #include "gtest/gtest.h"
21 #include "absl/strings/str_cat.h"
22 #include "fcp/testing/testing.h"
23 #include "tensorflow/lite/core/api/error_reporter.h"
24
25 namespace fcp {
26 namespace client {
27 namespace engine {
28 namespace {
29
30 using ::testing::IsEmpty;
31
TEST(CachingErrorReporterTest,CachingMultiple)32 TEST(CachingErrorReporterTest, CachingMultiple) {
33 CachingErrorReporter reporter;
34 std::string first_error = "Op a is not found.";
35 TF_LITE_REPORT_ERROR(&reporter, "%s%d", first_error.c_str(), 1);
36 std::string second_error = "Op b is not found.";
37 TF_LITE_REPORT_ERROR(&reporter, "%s%d", second_error.c_str(), 2);
38 EXPECT_THAT(reporter.GetFirstErrorMessage(), absl::StrCat(first_error, "1"));
39 }
40
TEST(CachingErrorReporterTest,Empty)41 TEST(CachingErrorReporterTest, Empty) {
42 CachingErrorReporter reporter;
43 EXPECT_THAT(reporter.GetFirstErrorMessage(), IsEmpty());
44 }
45
46 } // anonymous namespace
47 } // namespace engine
48 } // namespace client
49 } // namespace fcp
50