1//
2// NamePoolTest.cpp
3//
4// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
5// and Contributors.
6//
7// SPDX-License-Identifier: BSL-1.0
8//
9
10
11#include "NamePoolTest.h"
12#include "Poco/CppUnit/TestCaller.h"
13#include "Poco/CppUnit/TestSuite.h"
14#include "Poco/XML/NamePool.h"
15#include "Poco/XML/Name.h"
16#include "Poco/DOM/AutoPtr.h"
17
18
19using Poco::XML::NamePool;
20using Poco::XML::Name;
21using Poco::XML::AutoPtr;
22
23
24NamePoolTest::NamePoolTest(const std::string& name): CppUnit::TestCase(name)
25{
26}
27
28
29NamePoolTest::~NamePoolTest()
30{
31}
32
33
34void NamePoolTest::testNamePool()
35{
36 AutoPtr<NamePool> pool = new NamePool;
37 const Name* pName = 0;
38 Name name("pre:local", "http://www.appinf.com");
39
40 pName = &pool->insert(name);
41 const Name* pName2 = &pool->insert("pre:local", "http://www.appinf.com", "local");
42 assertTrue (pName == pName2);
43
44 pName2 = &pool->insert("pre:local2", "http://www.appinf.com", "local2");
45 assertTrue (pName2 != pName);
46
47 pName2 = &pool->insert(name);
48 assertTrue (pName2 == pName);
49
50 pName2 = &pool->insert(*pName);
51 assertTrue (pName2 == pName);
52}
53
54
55void NamePoolTest::setUp()
56{
57}
58
59
60void NamePoolTest::tearDown()
61{
62}
63
64
65CppUnit::Test* NamePoolTest::suite()
66{
67 CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NamePoolTest");
68
69 CppUnit_addTest(pSuite, NamePoolTest, testNamePool);
70
71 return pSuite;
72}
73