blob: d17be7fc4e75a0f2fd8f40e7bdfb65d4d45b2f9b [file] [log] [blame]
Gaurav Shah3df47b72013-03-22 15:40:41 -07001// Copyright (c) 2013 The Chromium OS 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 "shill/dbus_variant_gmock_printer.h"
6
7#include <gmock/gmock.h>
8
9#include "shill/dbus_adaptor.h"
10
11namespace DBus {
12
Paul Stewarta794cd62015-06-16 13:13:10 -070013void PrintTo(const ::DBus::Variant& value, ::std::ostream* os) {
Gaurav Shah3df47b72013-03-22 15:40:41 -070014 if (shill::DBusAdaptor::IsBool(value.signature()))
15 *os << value.reader().get_bool();
16 else if (shill::DBusAdaptor::IsByte(value.signature()))
17 *os << value.reader().get_byte();
18 else if (shill::DBusAdaptor::IsInt16(value.signature()))
19 *os << value.reader().get_int16();
20 else if (shill::DBusAdaptor::IsInt32(value.signature()))
21 *os << value.reader().get_int32();
22 else if (shill::DBusAdaptor::IsPath(value.signature()))
23 *os << value.reader().get_path();
24 else if (shill::DBusAdaptor::IsString(value.signature()))
25 *os << value.reader().get_string();
26 else if (shill::DBusAdaptor::IsStringmap(value.signature()))
27 *os << testing::PrintToString(value.operator shill::Stringmap());
28 else if (shill::DBusAdaptor::IsStringmaps(value.signature()))
29 *os << testing::PrintToString(value.operator shill::Stringmaps());
30 else if (shill::DBusAdaptor::IsStrings(value.signature()))
31 *os << testing::PrintToString(value.operator shill::Strings());
32 else if (shill::DBusAdaptor::IsUint16(value.signature()))
33 *os << value.reader().get_uint16();
34 else if (shill::DBusAdaptor::IsUint32(value.signature()))
35 *os << value.reader().get_uint32();
36 else if (shill::DBusAdaptor::IsUint64(value.signature()))
37 *os << value.reader().get_uint64();
38 else
39 *os << "(Do not know how to print: unknown type: " << value.signature()
40 << ")";
41}
42
43} // namespace DBus