Archival snapshot of the Virtual World Entertainment Tesla cockpit software, 1994-1996: MUNGA engine and L4 pod layer source (Borland C++ 5.0), BT/RP game code, and game content (models, audio, maps, gauges, Division renderer data). Includes third-party libraries: Division dVS/DPL graphics, HMI SOS audio, WATTCP networking. Files are preserved byte-for-byte (.gitattributes disables all line-ending conversion). README.md documents the layout, target hardware, and toolchain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
306 lines
8.5 KiB
Plaintext
306 lines
8.5 KiB
Plaintext
//===========================================================================//
|
|
// File: namelist.tst //
|
|
// Title: Definition of NameList TestClass methods. //
|
|
// Project: Munga //
|
|
// Author: Ken Olsen //
|
|
// Purpose: Maintains an unsorted list of strings with (void *) to //
|
|
// anything the client needs to associate with the string. //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// 01/06/95 KEO Stub-out TestClass methods. //
|
|
// 02/12/95 KEO Test IsEmpty method. //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (c) 1994, 1995 Virtual World Entertainment, Inc. //
|
|
// All rights reserved worldwide. //
|
|
// This unpublished source code is PROPRIETARY and CONFIDENTIAL. //
|
|
//===========================================================================//
|
|
|
|
//#############################################################################
|
|
//############## TestHost ###############################################
|
|
//#############################################################################
|
|
|
|
class TestHost SIGNATURED
|
|
{
|
|
public:
|
|
//--------------------------------------------------------------------
|
|
// ObjectNameList is designed to bond with another class to provide
|
|
// dymanic naming of the objects represented by that class. TestHost
|
|
// provides a means of testing the functionality of ObjectNameList.
|
|
//--------------------------------------------------------------------
|
|
const char
|
|
*name;
|
|
TestHost
|
|
*next;
|
|
static ObjectNameList
|
|
names;
|
|
|
|
TestHost(const char *a_name);
|
|
~TestHost();
|
|
|
|
Logical
|
|
TestInstance() const;
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
ObjectNameList
|
|
TestHost::names;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
TestHost::TestHost(const char *a_name)
|
|
{
|
|
Check_Pointer(this);
|
|
Check_Pointer(a_name);
|
|
name = names.AddEntry(a_name, (void *)this);
|
|
next = NULL;
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
TestHost::~TestHost()
|
|
{
|
|
Check(this);
|
|
names.DeleteEntry(name);
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
Logical
|
|
TestHost::TestInstance() const
|
|
{
|
|
return True;
|
|
}
|
|
|
|
//#############################################################################
|
|
//############## ObjectNameList::TestClass ##############################
|
|
//#############################################################################
|
|
|
|
Logical
|
|
ObjectNameList::TestClass()
|
|
{
|
|
DEBUG_STREAM << "Starting ObjectNameList test..." << endl;
|
|
|
|
TestHost
|
|
*host,
|
|
*save_host;
|
|
ObjectNameList::Entry
|
|
*next_entry,
|
|
*entry,
|
|
*save_entry;
|
|
NameList
|
|
sub_list;
|
|
int
|
|
freq,
|
|
count,
|
|
i;
|
|
div_t
|
|
mod;
|
|
char
|
|
name[20],
|
|
save_name[20];
|
|
ostrstream
|
|
stream(name, sizeof(name));
|
|
|
|
//----------------------
|
|
// initialize variables
|
|
//----------------------
|
|
save_host = NULL;
|
|
freq = TEST_CLASS / 10;
|
|
Test( freq > 1 );
|
|
count = 0;
|
|
|
|
//--------------------------------
|
|
// add objects to test and delete
|
|
// a few in the process
|
|
//--------------------------------
|
|
Test( TestHost::names.IsEmpty() );
|
|
for (i=0; i<TEST_CLASS; i++)
|
|
{
|
|
//-------------------------------------
|
|
// reset stream to beginning of buffer
|
|
// and create the object's name
|
|
//-------------------------------------
|
|
stream.clear();
|
|
stream.seekp(0);
|
|
stream << "NAME" << i << ends;
|
|
|
|
host = new TestHost(name);
|
|
Register_Object(host);
|
|
count++;
|
|
|
|
mod = div(i, freq);
|
|
if (mod.rem == 1)
|
|
{
|
|
//-----------------------------------------------
|
|
// save name and host pointer for later deletion
|
|
//-----------------------------------------------
|
|
strcpy(save_name, name);
|
|
save_host = host;
|
|
}
|
|
|
|
if (mod.rem == 0 && save_host != NULL)
|
|
{
|
|
//----------------------------------------------
|
|
// find and delete host object previously saved
|
|
//----------------------------------------------
|
|
host = (TestHost *)TestHost::names.FindObject(save_name);
|
|
Check(host);
|
|
Test( host == save_host );
|
|
Unregister_Object(host);
|
|
delete host;
|
|
count--;
|
|
}
|
|
}
|
|
Test( !TestHost::names.IsEmpty() );
|
|
|
|
//-----------------------
|
|
// check count and names
|
|
//-----------------------
|
|
Test( count == TestHost::names.EntryCount() );
|
|
|
|
i = count / 2;
|
|
entry = TestHost::names.GetFirstEntry();
|
|
while (entry)
|
|
{
|
|
Check_Pointer(entry); // special case (entry is not constructed)
|
|
host = (TestHost *)entry->GetObject();
|
|
Check(host);
|
|
Check_Pointer(host->name);
|
|
Check_Pointer(entry->GetName());
|
|
Test( host->name == entry->GetName() );
|
|
if (!(--i))
|
|
{
|
|
save_entry = entry;
|
|
}
|
|
entry = entry->GetNextEntry();
|
|
}
|
|
|
|
//--------------------------------------
|
|
// delete middle, first and last object
|
|
//--------------------------------------
|
|
entry = save_entry;
|
|
if (entry)
|
|
{
|
|
Check_Pointer(entry); // special case (entry is not constructed)
|
|
host = (TestHost *)entry->GetObject();
|
|
Check(host);
|
|
Unregister_Object(host);
|
|
delete host;
|
|
count--;
|
|
}
|
|
|
|
entry = TestHost::names.GetFirstEntry();
|
|
if (entry)
|
|
{
|
|
Check_Pointer(entry); // special case (entry is not constructed)
|
|
host = (TestHost *)entry->GetObject();
|
|
Check(host);
|
|
Unregister_Object(host);
|
|
delete host;
|
|
count--;
|
|
}
|
|
|
|
entry = TestHost::names.GetLastEntry();
|
|
if (entry)
|
|
{
|
|
Check_Pointer(entry); // special case (entry is not constructed)
|
|
host = (TestHost *)entry->GetObject();
|
|
Check(host);
|
|
Unregister_Object(host);
|
|
delete host;
|
|
count--;
|
|
}
|
|
|
|
//------------------------
|
|
// add a few more objects
|
|
//------------------------
|
|
for (i=TEST_CLASS; i<TEST_CLASS+freq; i++)
|
|
{
|
|
//-------------------------------------
|
|
// reset stream to beginning of buffer
|
|
// and create the object's name
|
|
//-------------------------------------
|
|
stream.clear();
|
|
stream.seekp(0);
|
|
stream << "TEST" << i << ends;
|
|
|
|
#if DEBUG_LEVEL>0
|
|
host =
|
|
#endif
|
|
new TestHost(name);
|
|
Register_Object(host);
|
|
count++;
|
|
}
|
|
|
|
//-----------------
|
|
// create sub list
|
|
//-----------------
|
|
i = sub_list.BuildSubList(TestHost::names, "TEST");
|
|
Test( i == freq );
|
|
Test( i == sub_list.EntryCount() );
|
|
|
|
//-----------------------------
|
|
// check count and names again
|
|
// and delete as we go
|
|
//-----------------------------
|
|
Test( count == TestHost::names.EntryCount() );
|
|
|
|
entry = TestHost::names.GetFirstEntry();
|
|
while (entry)
|
|
{
|
|
Check_Pointer(entry); // special case (entry is not constructed)
|
|
host = (TestHost *)entry->GetObject();
|
|
Check(host);
|
|
Check_Pointer(host->name);
|
|
Check_Pointer(entry->GetName());
|
|
Test( host->name == entry->GetName() );
|
|
|
|
next_entry = entry->GetNextEntry();
|
|
if (!next_entry)
|
|
{
|
|
Test( entry == TestHost::names.GetLastEntry() );
|
|
Test( entry == TestHost::names.GetFirstEntry() );
|
|
}
|
|
Unregister_Object(host);
|
|
delete host;
|
|
count--;
|
|
entry = next_entry;
|
|
}
|
|
|
|
Test( count == 0 );
|
|
|
|
// Tell(" ObjectNameList::TestClass() is stubbed out!\n");
|
|
return True;
|
|
}
|
|
|
|
//#############################################################################
|
|
//############## NameList::TestClass ####################################
|
|
//#############################################################################
|
|
|
|
Logical
|
|
NameList::TestClass()
|
|
{
|
|
DEBUG_STREAM << "Starting NameList test..." << endl;
|
|
|
|
Tell(" NameList::TestClass() is stubbed out!\n");
|
|
return False;
|
|
}
|
|
|
|
//#############################################################################
|
|
//############## AlphaNameList::TestClass ###############################
|
|
//#############################################################################
|
|
|
|
Logical
|
|
AlphaNameList::TestClass()
|
|
{
|
|
DEBUG_STREAM << "Starting AlphaNameList test..." << endl;
|
|
|
|
Tell(" AlphaNameList::TestClass() is stubbed out!\n");
|
|
return False;
|
|
}
|
|
|
|
//#############################################################################
|
|
//#############################################################################
|