blob: 67d5386b7f3498e15d985ec27721007122960895 [file] [log] [blame]
Yusuke Sato0d6eb572021-04-06 23:48:461// Copyright 2021 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "components/arc/session/arc_instance_mode.h"
6
7#include <sstream>
8
Yusuke Sato0d6eb572021-04-06 23:48:469#include "testing/gtest/include/gtest/gtest.h"
Anton Bikineev1156b5f2021-05-15 22:35:3610#include "third_party/abseil-cpp/absl/types/optional.h"
Yusuke Sato0d6eb572021-04-06 23:48:4611
12namespace arc {
13namespace {
14
15// Test that ArcInstanceMode can be logged.
16TEST(ArcInstanceModeTest, TestLogging) {
17 std::ostringstream mini;
18 mini << ArcInstanceMode::MINI_INSTANCE;
19 EXPECT_FALSE(mini.str().empty());
20
21 std::ostringstream full;
22 full << ArcInstanceMode::FULL_INSTANCE;
23 EXPECT_FALSE(full.str().empty());
24 EXPECT_NE(mini.str(), full.str());
25
26 std::ostringstream invalid;
27 invalid << static_cast<ArcInstanceMode>(-1);
28 EXPECT_TRUE(invalid.str().empty()) << invalid.str();
29}
30
Anton Bikineev1156b5f2021-05-15 22:35:3631// Test that absl::optional<ArcInstanceMode> can be logged too.
Yusuke Sato0d6eb572021-04-06 23:48:4632TEST(ArcInstanceModeTest, TestLoggingWithOptional) {
33 std::ostringstream nullopt;
Anton Bikineev1156b5f2021-05-15 22:35:3634 nullopt << absl::optional<ArcInstanceMode>();
Yusuke Sato0d6eb572021-04-06 23:48:4635 EXPECT_FALSE(nullopt.str().empty());
36
37 std::ostringstream non_nullopt;
Anton Bikineev1156b5f2021-05-15 22:35:3638 non_nullopt << absl::optional<ArcInstanceMode>(
Yusuke Sato0d6eb572021-04-06 23:48:4639 ArcInstanceMode::MINI_INSTANCE);
40 EXPECT_FALSE(non_nullopt.str().empty());
41 EXPECT_NE(nullopt.str(), non_nullopt.str());
42
43 std::ostringstream value;
44 value << ArcInstanceMode::MINI_INSTANCE;
45 EXPECT_FALSE(value.str().empty());
46 EXPECT_EQ(non_nullopt.str(), value.str());
47}
48
49} // namespace
50} // namespace arc