1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Tests: Add NodeResolver unittests

Minor misc. NodeResolver cleanups
Prefix faux content type constants for testing with t_ to avoid
confusion or name collisions
This commit is contained in:
kwolekr 2015-05-05 11:36:40 -04:00
parent 1be2d32fd5
commit b45df9d6a7
8 changed files with 349 additions and 25 deletions

View file

@ -1346,7 +1346,8 @@ void CNodeDefManager::runNodeResolveCallbacks()
//// NodeResolver
////
NodeResolver::NodeResolver() {
NodeResolver::NodeResolver()
{
m_ndef = NULL;
m_nodenames_idx = 0;
m_nnlistsizes_idx = 0;
@ -1379,14 +1380,14 @@ void NodeResolver::nodeResolveInternal()
const std::string &NodeResolver::getNodeName(content_t c) const
{
if (m_nodenames.size() == 0) {
if (c < m_nodenames.size())
return m_nodenames[c];
if (m_ndef)
return m_ndef->get(c).name;
} else {
if (c < m_nodenames.size())
return m_nodenames[c];
else
return m_ndef->get(CONTENT_UNKNOWN).name;
}
static const std::string unknown_str("unknown");
return unknown_str;
}
@ -1395,7 +1396,7 @@ bool NodeResolver::getIdFromNrBacklog(content_t *result_out,
{
if (m_nodenames_idx == m_nodenames.size()) {
*result_out = c_fallback;
errorstream << "Resolver: no more nodes in list" << std::endl;
errorstream << "NodeResolver: no more nodes in list" << std::endl;
return false;
}