Brian Carlstrom | 7e93b50 | 2011-08-04 14:16:22 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #include "intern_table.h" |
| 4 | |
| 5 | #include "common_test.h" |
| 6 | #include "object.h" |
| 7 | |
| 8 | #include "gtest/gtest.h" |
| 9 | |
| 10 | namespace art { |
| 11 | |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame^] | 12 | class InternTableTest : public CommonTest {}; |
Brian Carlstrom | 7e93b50 | 2011-08-04 14:16:22 -0700 | [diff] [blame] | 13 | |
| 14 | TEST_F(InternTableTest, Intern) { |
| 15 | InternTable intern_table; |
| 16 | String* foo_1 = intern_table.Intern(3, "foo"); |
| 17 | String* foo_2 = intern_table.Intern(3, "foo"); |
| 18 | String* foo_3 = String::AllocFromAscii("foo"); |
| 19 | String* bar = intern_table.Intern(3, "bar"); |
| 20 | EXPECT_TRUE(foo_1->Equals("foo")); |
| 21 | EXPECT_TRUE(foo_2->Equals("foo")); |
| 22 | EXPECT_TRUE(foo_3->Equals("foo")); |
| 23 | EXPECT_TRUE(foo_1 != NULL); |
| 24 | EXPECT_TRUE(foo_2 != NULL); |
| 25 | EXPECT_EQ(foo_1, foo_2); |
| 26 | EXPECT_NE(foo_1, bar); |
| 27 | EXPECT_NE(foo_2, bar); |
| 28 | EXPECT_NE(foo_3, bar); |
| 29 | } |
| 30 | |
| 31 | } // namespace art |