OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/trace_event/trace_event_argument.h" | 5 #include "base/trace_event/trace_event_argument.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace base { | 8 namespace base { |
9 namespace debug { | 9 namespace trace_event { |
10 | 10 |
11 TEST(TraceEventArgumentTest, FlatDictionary) { | 11 TEST(TraceEventArgumentTest, FlatDictionary) { |
12 scoped_refptr<TracedValue> value = new TracedValue(); | 12 scoped_refptr<TracedValue> value = new TracedValue(); |
13 value->SetInteger("int", 2014); | 13 value->SetInteger("int", 2014); |
14 value->SetDouble("double", 0.0); | 14 value->SetDouble("double", 0.0); |
15 value->SetBoolean("bool", true); | 15 value->SetBoolean("bool", true); |
16 value->SetString("string", "string"); | 16 value->SetString("string", "string"); |
17 std::string json; | 17 std::string json; |
18 value->AppendAsTraceFormat(&json); | 18 value->AppendAsTraceFormat(&json); |
19 EXPECT_EQ("{\"bool\":true,\"double\":0.0,\"int\":2014,\"string\":\"string\"}", | 19 EXPECT_EQ("{\"bool\":true,\"double\":0.0,\"int\":2014,\"string\":\"string\"}", |
(...skipping 22 matching lines...) Expand all Loading... |
42 value->SetString("s0", "foo"); | 42 value->SetString("s0", "foo"); |
43 std::string json; | 43 std::string json; |
44 value->AppendAsTraceFormat(&json); | 44 value->AppendAsTraceFormat(&json); |
45 EXPECT_EQ( | 45 EXPECT_EQ( |
46 "{\"a1\":[1,true,{\"i2\":3}],\"b0\":true,\"d0\":0.0,\"dict1\":{\"dict2\":" | 46 "{\"a1\":[1,true,{\"i2\":3}],\"b0\":true,\"d0\":0.0,\"dict1\":{\"dict2\":" |
47 "{\"b2\":false},\"i1\":2014,\"s1\":\"foo\"},\"i0\":2014,\"s0\":" | 47 "{\"b2\":false},\"i1\":2014,\"s1\":\"foo\"},\"i0\":2014,\"s0\":" |
48 "\"foo\"}", | 48 "\"foo\"}", |
49 json); | 49 json); |
50 } | 50 } |
51 | 51 |
52 } // namespace debug | 52 } // namespace trace_event |
53 } // namespace base | 53 } // namespace base |
OLD | NEW |