summaryrefslogtreecommitdiff
path: root/src/common/intern-pool_test.cpp
blob: bf17b6798f38c345f636385ea02a23f095372e35 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "intern-pool.hpp"

#include <gtest/gtest.h>

#include "../strings/base.hpp"

TEST(InternPool, whydoesthisalwaysneedasecondname)
{
    InternPool p;
    EXPECT_EQ(0, p.size());
    EXPECT_EQ(0, p.intern("hello"));
    EXPECT_EQ(0, p.intern("hello"));
    EXPECT_EQ(1, p.size());
    EXPECT_EQ(1, p.intern("world"));
    EXPECT_EQ(0, p.intern("hello"));
    EXPECT_EQ(1, p.intern("world"));
    EXPECT_EQ(2, p.size());
    EXPECT_EQ("hello", p.outtern(0));
    EXPECT_EQ("world", p.outtern(1));
}