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>
451 lines
16 KiB
Plaintext
451 lines
16 KiB
Plaintext
//===========================================================================//
|
|
// File: notation.tcp //
|
|
// Title: Definition of NotationFile TestClass methods. //
|
|
// Project: Munga //
|
|
// Author: Ken Olsen //
|
|
// Purpose: Provide general purpose access to data stored in a formatted //
|
|
// text file. //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// 01/07/95 KEO Stub-out TestClass method. //
|
|
// 02/07/95 KEO Add AppendEntry methods. //
|
|
// 02/17/95 KEO Change page and entry lists to make nomenclature. //
|
|
// 03/24/95 KEO Add tests for new in-memory read and write methods. //
|
|
// 03/31/95 KEO Add tests for lab only methods. //
|
|
// 11/11/95 KEO Correct and improve testing. //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (c) 1994, 1995 Virtual World Entertainment, Inc. //
|
|
// All rights reserved worldwide. //
|
|
// This unpublished source code is PROPRIETARY and CONFIDENTIAL. //
|
|
//===========================================================================//
|
|
|
|
//#############################################################################
|
|
//############## NotationFile::TestClass ################################
|
|
//#############################################################################
|
|
|
|
Logical
|
|
NotationFile::TestClass()
|
|
{
|
|
DEBUG_STREAM << "Starting NotationFile test..." << endl;
|
|
|
|
#if 0
|
|
ofstream
|
|
output;
|
|
|
|
if (output.open(TEST_FILENAME))
|
|
{
|
|
//------------------------------
|
|
// write out test notation file
|
|
//------------------------------
|
|
output <<
|
|
endl <<
|
|
"; this is a comment" << endl <<
|
|
endl <<
|
|
"[header]" << endl;
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
cerr << "NotationFile: ERROR - Could not open test file." << endl;
|
|
return False;
|
|
}
|
|
#endif
|
|
|
|
const char
|
|
*test_filename = "notation.ini",
|
|
*lab_only = "LAB_ONLY",
|
|
*page_1 = "Page 1",
|
|
*page_2 = "Page 2",
|
|
*page_3 = "Page 3",
|
|
// *page_4 = "Page 4",
|
|
*page_5 = "Page 5",
|
|
// *page_6 = "Page 6",
|
|
*page_7 = "Page 7",
|
|
*page_8 = "Page 8",
|
|
*_page9 = "_Page9",
|
|
*entry_1 = "Entry 1",
|
|
*entry_2 = "Entry 2",
|
|
*entry_3 = "Entry 3",
|
|
*entry_4 = "Entry 4",
|
|
*entry_5 = "Entry 5",
|
|
*entry_6 = "Entry 6",
|
|
*entry_7 = "Entry 7",
|
|
// *entry_8 = "Entry 8",
|
|
*entry_9 = "Entry 9",
|
|
*text_a = "Text Line A",
|
|
*text_b = "Text Line B",
|
|
*text_c = "Text Line C",
|
|
*text_i = "-35",
|
|
*text_s = "3.1415",
|
|
*text_d = "1.99d+199",
|
|
*text_t = "yes",
|
|
*text_f = "no";
|
|
|
|
NotationFile
|
|
*ini_file;
|
|
char
|
|
*buffer;
|
|
long
|
|
size,
|
|
actual_size;
|
|
const char
|
|
*string_value;
|
|
int
|
|
count,
|
|
integer_value;
|
|
Scalar
|
|
scalar_value;
|
|
double
|
|
double_value;
|
|
Logical
|
|
logical_value;
|
|
NameList
|
|
*name_list;
|
|
AlphaNameList
|
|
*alpha_name_list;
|
|
NameList::Entry
|
|
*page,
|
|
*prev,
|
|
*entry;
|
|
|
|
//----------------------------------------
|
|
// test NotationFile part 1 - create file
|
|
//----------------------------------------
|
|
ini_file = new NotationFile;
|
|
Register_Object(ini_file);
|
|
Test( ini_file->GetModes() == DefaultOperationModes );
|
|
Test( ini_file->IsEmpty() );
|
|
Test( !ini_file->IsDirty() );
|
|
Test( !ini_file->IsMarkedLabOnly() );
|
|
|
|
Test( ini_file->PageCount() == 0 );
|
|
name_list = ini_file->MakePageList();
|
|
Register_Object(name_list);
|
|
Test( name_list->EntryCount() == 0 );
|
|
Unregister_Object(name_list);
|
|
delete name_list;
|
|
|
|
alpha_name_list = ini_file->MakeAlphaPageList();
|
|
Register_Object(alpha_name_list);
|
|
Test( alpha_name_list->EntryCount() == 0 );
|
|
Unregister_Object(alpha_name_list);
|
|
delete alpha_name_list;
|
|
|
|
ini_file->MarkLabOnly();
|
|
Test( !ini_file->IsEmpty() );
|
|
Test( ini_file->IsDirty() );
|
|
// Test( ini_file->WriteFile("notation.ini.tst") ); // EDO_DEBUG
|
|
Test( ini_file->IsMarkedLabOnly() );
|
|
Test( ini_file->PutModes(RelaxedOperationModes) == RelaxedOperationModes)
|
|
Test( ini_file->PageCount() == 0 );
|
|
Test( ini_file->ClearMode(RelaxedOperationModes) == RawOperationModes)
|
|
Test( ini_file->SetMode(DefaultOperationModes) == DefaultOperationModes)
|
|
Test_And_Dump( ini_file->PageCount() == 1, ini_file->PageCount() );
|
|
|
|
Test( ini_file->PageCount() == 1 );
|
|
name_list = ini_file->MakePageList();
|
|
Register_Object(name_list);
|
|
Test( name_list->EntryCount() == 1 );
|
|
page = name_list->GetFirstEntry();
|
|
Test( page == name_list->GetLastEntry() );
|
|
Test( !strcmp(page->GetName(), lab_only) );
|
|
Unregister_Object(name_list);
|
|
delete name_list;
|
|
|
|
alpha_name_list = ini_file->MakeAlphaPageList();
|
|
Register_Object(alpha_name_list);
|
|
Test( alpha_name_list->EntryCount() == 1 );
|
|
page = alpha_name_list->GetFirstEntry();
|
|
Test( page == alpha_name_list->GetLastEntry() );
|
|
Test( !strcmp(page->GetName(), lab_only) );
|
|
Unregister_Object(alpha_name_list);
|
|
delete alpha_name_list;
|
|
|
|
ini_file->SetEntry(page_2, entry_4, text_a);
|
|
|
|
Test( !ini_file->GetEntry(page_1, entry_1, &string_value) );
|
|
Test( !ini_file->GetEntry(page_2, entry_2, &string_value) );
|
|
Test( ini_file->GetEntry(page_2, entry_4, &string_value) );
|
|
Test( !strcmp(string_value, text_a) );
|
|
|
|
ini_file->SetEntry(page_2, entry_2, text_s);
|
|
ini_file->SetEntry(page_1, entry_5, text_i);
|
|
ini_file->SetEntry(_page9, entry_6, text_b);
|
|
ini_file->SetPage(page_8, "\t// this is page_8");
|
|
ini_file->SetEntry(page_2, entry_3, text_d);
|
|
ini_file->SetEntry(page_1, entry_4, text_b);
|
|
ini_file->SetEntry(_page9, entry_5, (int)True);
|
|
ini_file->SetEntry(page_8, entry_3, text_c);
|
|
ini_file->SetEntry(page_5, entry_5, text_a);
|
|
ini_file->SetLogicalEntry(_page9, entry_2, False);
|
|
ini_file->DeleteEntry(page_7, entry_7);
|
|
ini_file->DeleteEntry(page_8, entry_1);
|
|
ini_file->DeleteEntry(page_1, entry_5);
|
|
ini_file->SetEntry(_page9, entry_1, text_t);
|
|
ini_file->SetEntry(page_2, entry_3, text_c);
|
|
ini_file->SetEntry(page_1, entry_1, text_i);
|
|
ini_file->AppendEntry(page_5, entry_5, text_b);
|
|
ini_file->SetEntry(_page9, entry_3, text_f);
|
|
ini_file->SetEntry(page_8, entry_1, text_d);
|
|
ini_file->SetEntry(page_1, entry_9, text_s);
|
|
ini_file->AppendLogicalEntry(_page9, entry_9, True);
|
|
ini_file->SetEntry(page_8, entry_2, text_i);
|
|
ini_file->SetEntry(_page9, entry_4, (int)False);
|
|
|
|
// notation file should look like this:
|
|
// (lab_only, NULL, NULL)
|
|
// (page_2, entry_4, text_a)
|
|
// (page_2, entry_2, text_s)
|
|
// (page_2, entry_3, text_c)
|
|
// (page_1, entry_4, text_b)
|
|
// (page_1, entry_1, text_i)
|
|
// (page_1, entry_9, text_s)
|
|
// (_page9, entry_6, text_b)
|
|
// (_page9, entry_5, 1)
|
|
// (_page9, entry_2, False)
|
|
// (_page9, entry_1, text_t)
|
|
// (_page9, entry_3, text_f)
|
|
// (_page9, entry_9, True)
|
|
// (_page9, entry_4, 0)
|
|
// (page_8, entry_3, text_c)
|
|
// (page_8, entry_1, text_d)
|
|
// (page_8, entry_2, text_i)
|
|
// (page_5, entry_5, text_a)
|
|
// (page_5, entry_5, text_b)
|
|
|
|
Test_And_Dump( ini_file->EntryCount(page_1) == 3, ini_file->EntryCount(page_1) );
|
|
name_list = ini_file->MakeEntryList(page_1);
|
|
Register_Object(name_list);
|
|
Test( name_list->EntryCount() == 3 );
|
|
count = 0;
|
|
prev = NULL;
|
|
entry = name_list->GetFirstEntry();
|
|
while (entry)
|
|
{
|
|
count++;
|
|
prev = entry;
|
|
entry = entry->GetNextEntry();
|
|
}
|
|
Test( count == 3 );
|
|
Test( (entry = prev) != NULL);
|
|
Test( entry == name_list->GetLastEntry() );
|
|
Test( !strcmp(entry->GetName(), entry_9) );
|
|
Test( !strcmp((char *)entry->dataReference, text_s) );
|
|
Unregister_Object(name_list);
|
|
delete name_list;
|
|
|
|
alpha_name_list = ini_file->MakeAlphaEntryList(page_8);
|
|
Register_Object(alpha_name_list);
|
|
Test( alpha_name_list->EntryCount() == 3 );
|
|
count = 0;
|
|
prev = NULL;
|
|
entry = alpha_name_list->GetFirstEntry();
|
|
while (entry)
|
|
{
|
|
count++;
|
|
prev = entry;
|
|
entry = entry->GetNextEntry();
|
|
}
|
|
Test( count == 3 );
|
|
Test( (entry = prev) != NULL);
|
|
Test( entry == alpha_name_list->GetLastEntry() );
|
|
Test( !strcmp(entry->GetName(), entry_3) );
|
|
Test( !strcmp((char *)entry->dataReference, text_c) );
|
|
Unregister_Object(alpha_name_list);
|
|
delete alpha_name_list;
|
|
|
|
Test( ini_file->SetMode(IgnorePageCaseMode) == (DefaultOperationModes|IgnorePageCaseMode) );
|
|
Test( ini_file->PageExists("_pAgE9") );
|
|
name_list = ini_file->MakePageList("pAgE");
|
|
Register_Object(name_list);
|
|
Test( ini_file->PutModes(DefaultOperationModes) == DefaultOperationModes );
|
|
Test( name_list->EntryCount() == 4 );
|
|
page = name_list->GetFirstEntry();
|
|
page = page->GetNextEntry();
|
|
page = page->GetNextEntry();
|
|
page = page->GetNextEntry();
|
|
Test( page == name_list->GetLastEntry() );
|
|
Test( !strcmp(page->GetName(), page_5) );
|
|
Unregister_Object(name_list);
|
|
delete name_list;
|
|
|
|
Test( !ini_file->WriteFile() );
|
|
Test( ini_file->WriteFile(test_filename) );
|
|
Test( !ini_file->IsDirty() );
|
|
Unregister_Object(ini_file);
|
|
delete ini_file;
|
|
|
|
//---------------------------------------
|
|
// test NotationFile part 2 - check file
|
|
//---------------------------------------
|
|
|
|
// notation file should look like this:
|
|
// (lab_only, NULL, NULL)
|
|
// (page_2, entry_4, text_a)
|
|
// (page_2, entry_2, text_s)
|
|
// (page_2, entry_3, text_c)
|
|
// (page_1, entry_4, text_b)
|
|
// (page_1, entry_1, text_i)
|
|
// (page_1, entry_9, text_s)
|
|
// (_page9, entry_6, text_b)
|
|
// (_page9, entry_5, 1)
|
|
// (_page9, entry_2, False)
|
|
// (_page9, entry_1, text_t)
|
|
// (_page9, entry_3, text_f)
|
|
// (_page9, entry_9, True)
|
|
// (_page9, entry_4, 0)
|
|
// (page_8, entry_3, text_c)
|
|
// (page_8, entry_1, text_d)
|
|
// (page_8, entry_2, text_i)
|
|
// (page_5, entry_5, text_a)
|
|
// (page_5, entry_5, text_b)
|
|
|
|
ini_file = new NotationFile(test_filename);
|
|
Register_Object(ini_file);
|
|
|
|
ini_file->MarkLabOnly();
|
|
Test( !ini_file->IsDirty() );
|
|
// Test( ini_file->WriteFile("notation.ini.tst") ); // EDO_DEBUG
|
|
Test_And_Dump( ini_file->PageCount() == 6, ini_file->PageCount() );
|
|
Test( ini_file->SetMode(CleanPageListMode) == (DefaultOperationModes|CleanPageListMode) );
|
|
Test_And_Dump( ini_file->PageCount() == 5, ini_file->PageCount() );
|
|
Test( ini_file->ClearMode(CleanPageListMode) == DefaultOperationModes );
|
|
Test_And_Dump( ini_file->EntryCount(page_2) == 3, ini_file->EntryCount(page_2) );
|
|
Test_And_Dump( ini_file->EntryCount(page_1) == 3, ini_file->EntryCount(page_1) );
|
|
Test_And_Dump( ini_file->EntryCount(_page9) == 7, ini_file->EntryCount(_page9) );
|
|
Test_And_Dump( ini_file->EntryCount(page_8) == 3, ini_file->EntryCount(page_8) );
|
|
Test_And_Dump( ini_file->EntryCount(page_5) == 2, ini_file->EntryCount(page_5) );
|
|
|
|
name_list = ini_file->MakePageList();
|
|
Register_Object(name_list);
|
|
Test( name_list->EntryCount() == 6 );
|
|
entry = name_list->GetLastEntry();
|
|
Test( !strcmp(entry->GetName(), page_5) );
|
|
Unregister_Object(name_list);
|
|
delete name_list;
|
|
|
|
//-----------------
|
|
// write to memory
|
|
//-----------------
|
|
size = ini_file->SizeOfText();
|
|
Test( size > 10L );
|
|
buffer = new char[size];
|
|
Register_Pointer(buffer);
|
|
actual_size = ini_file->WriteText(buffer, 10L);
|
|
Test( actual_size == -1L );
|
|
actual_size = ini_file->WriteText(buffer, size);
|
|
Test( actual_size == size );
|
|
Unregister_Object(ini_file);
|
|
delete ini_file;
|
|
|
|
//------------------
|
|
// read from memory
|
|
//------------------
|
|
ini_file = new NotationFile();
|
|
Register_Object(ini_file);
|
|
|
|
ini_file->ReadText(buffer, size);
|
|
// Test( ini_file->WriteFile("notation.ini.tst") ); // EDO_DEBUG
|
|
Unregister_Pointer(buffer);
|
|
delete buffer;
|
|
|
|
Test( ini_file->IsMarkedLabOnly() );
|
|
Test( ini_file->PageCount() == 6 );
|
|
alpha_name_list = ini_file->MakeAlphaPageList();
|
|
Register_Object(alpha_name_list);
|
|
Test( alpha_name_list->EntryCount() == 6 );
|
|
entry = alpha_name_list->GetLastEntry();
|
|
Test( !strcmp(entry->GetName(), _page9) );
|
|
Unregister_Object(alpha_name_list);
|
|
delete alpha_name_list;
|
|
|
|
name_list = ini_file->MakeEntryList(page_5);
|
|
Register_Object(name_list);
|
|
Test_And_Dump( ini_file->EntryCount(page_5) == 2, ini_file->EntryCount(page_5) );
|
|
Test_And_Dump( name_list->EntryCount() == 2, name_list->EntryCount() );
|
|
entry = name_list->GetFirstEntry();
|
|
Test_And_Dump( !strcmp(entry->GetName(), entry_5), entry->GetName() );
|
|
Test( !strcmp((char *)entry->dataReference, text_a) );
|
|
entry = name_list->GetLastEntry();
|
|
Test( !strcmp(entry->GetName(), entry_5) );
|
|
Test( !strcmp((char *)entry->dataReference, text_b) );
|
|
Unregister_Object(name_list);
|
|
delete name_list;
|
|
|
|
Test( !ini_file->GetEntry(page_3, entry_2, &integer_value) );
|
|
Test( !ini_file->GetEntry(page_2, entry_5, &scalar_value) );
|
|
Test( ini_file->GetEntry(page_8, entry_1, &double_value) );
|
|
Test( (fabs(double_value - atof(text_d)) < (1.0e-10)) );
|
|
Test( ini_file->GetEntry(page_1, entry_1, &integer_value) );
|
|
Test( integer_value == atoi(text_i) );
|
|
Test( ini_file->GetEntry(page_2, entry_2, &scalar_value) );
|
|
Test( Close_Enough(scalar_value, atof(text_s)) );
|
|
Test( ini_file->GetEntry(page_1, entry_4, &string_value) );
|
|
Test( !strcmp(string_value, text_b) );
|
|
Test( ini_file->GetEntry(page_5, entry_5, &string_value) );
|
|
Test( !strcmp(string_value, text_a) );
|
|
Test( ini_file->GetLogicalEntry(_page9, entry_9, &logical_value) );
|
|
Test( logical_value );
|
|
Test( ini_file->GetLogicalEntry(_page9, entry_1, &logical_value) );
|
|
Test( logical_value );
|
|
Test( ini_file->GetLogicalEntry(_page9, entry_5, &logical_value) );
|
|
Test( logical_value );
|
|
Test( ini_file->GetLogicalEntry(_page9, entry_3, &logical_value) );
|
|
Test( !logical_value );
|
|
Test( ini_file->GetLogicalEntry(_page9, entry_2, &logical_value) );
|
|
Test( !logical_value );
|
|
Test( ini_file->GetLogicalEntry(_page9, entry_4, &logical_value) );
|
|
Test( !logical_value );
|
|
Test( !ini_file->IsDirty() );
|
|
|
|
ini_file->DeletePage(page_2);
|
|
Test( ini_file->IsDirty() );
|
|
Test( !ini_file->PageExists(page_2) );
|
|
|
|
ini_file->DeleteEntry(page_1, entry_1);
|
|
name_list = ini_file->MakeEntryList(page_1);
|
|
Register_Object(name_list);
|
|
Test( name_list->EntryCount() == 2 );
|
|
entry = name_list->GetFirstEntry();
|
|
Test( entry != NULL );
|
|
Test( !strcmp(entry->GetName(), entry_4) );
|
|
Test( !strcmp((char *)entry->dataReference, text_b) );
|
|
Unregister_Object(name_list);
|
|
delete name_list;
|
|
|
|
Test( ini_file->SetMode(IgnoreEntryCaseMode) == (DefaultOperationModes|IgnoreEntryCaseMode) );
|
|
alpha_name_list = ini_file->MakeAlphaEntryList(_page9, "eNtRy");
|
|
Register_Object(alpha_name_list);
|
|
Test( ini_file->ClearMode(IgnoreEntryCaseMode) == DefaultOperationModes );
|
|
Test( alpha_name_list->EntryCount() == 7 );
|
|
entry = alpha_name_list->GetFirstEntry();
|
|
Test( entry != NULL );
|
|
Test( !strcmp(entry->GetName(), entry_1) );
|
|
Test( !strcmp((char *)entry->dataReference, text_t) );
|
|
Unregister_Object(alpha_name_list);
|
|
delete alpha_name_list;
|
|
|
|
ini_file->DeleteStandardPages();
|
|
Test( ini_file->PageCount() == 2 );
|
|
Test( ini_file->IsMarkedLabOnly() );
|
|
Test( ini_file->PageExists(_page9) );
|
|
Test( !ini_file->PageExists(page_5) );
|
|
|
|
ini_file->Abort();
|
|
Test( !ini_file->IsDirty() );
|
|
|
|
ini_file->SetEntry(page_2, entry_4, text_a);
|
|
Test( ini_file->IsDirty() );
|
|
|
|
Unregister_Object(ini_file);
|
|
delete ini_file;
|
|
|
|
Tell(" NotationFile::TestClass() is not rigorous!\n");
|
|
return True;
|
|
}
|
|
|
|
//#############################################################################
|
|
//#############################################################################
|