blob: 7613df49944e41022c9899708a12718d997ae63e [file] [log] [blame]
Richard Uhler35244722015-09-10 16:45:54 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
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
17package com.android.ahat;
18
19import com.android.tools.perflib.heap.Instance;
20import java.io.IOException;
21import static org.junit.Assert.assertEquals;
22import static org.junit.Assert.assertNotNull;
23import static org.junit.Assert.assertNull;
24import org.junit.Test;
25
26public class InstanceUtilsTest {
27 @Test
28 public void basicString() throws IOException {
29 TestDump dump = TestDump.getTestDump();
30 Instance str = (Instance)dump.getDumpedThing("basicString");
31 assertEquals("hello, world", InstanceUtils.asString(str));
32 }
33
34 @Test
35 public void nullString() throws IOException {
36 TestDump dump = TestDump.getTestDump();
37 Instance obj = (Instance)dump.getDumpedThing("nullString");
38 assertNull(InstanceUtils.asString(obj));
39 }
40
41 @Test
42 public void notString() throws IOException {
43 TestDump dump = TestDump.getTestDump();
44 Instance obj = (Instance)dump.getDumpedThing("anObject");
45 assertNotNull(obj);
46 assertNull(InstanceUtils.asString(obj));
47 }
48}