From: Fred T. Hamster Date: Sat, 7 Feb 2026 23:14:38 +0000 (-0500) Subject: adding in test for ini configurator X-Git-Tag: 2.140.190^2~29 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=dd72fc11998d30e66475d619ca6e442725230877;p=feisty_meow.git adding in test for ini configurator and some more fixes for the upgrader script --- diff --git a/nucleus/library/tests_application/test_ini_configurator.cpp b/nucleus/library/tests_application/test_ini_configurator.cpp deleted file mode 100644 index 477fe915..00000000 --- a/nucleus/library/tests_application/test_ini_configurator.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/*****************************************************************************\ -* * -* Name : test_ini_configurator * -* Author : Chris Koeritz * -* * -******************************************************************************* -* Copyright (c) 1998-$now By Author. This program is free software; you can * -* redistribute it and/or modify it under the terms of the GNU General Public * -* License as published by the Free Software Foundation; either version 2 of * -* the License or (at your option) any later version. This is online at: * -* http://www.fsf.org/copyleft/gpl.html * -* Please send any updates to: fred@gruntose.com * -\*****************************************************************************/ - -const int test_iterations = 10; - -//#define DEBUG_INI_CONFIGURATOR_TEST - // uncomment for debugging version. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef DEBUG_INI_CONFIGURATOR_TEST - #include -#endif - -HOOPLE_STARTUP_CODE; - -using namespace geometric; - -typedef float_plus frunkle; - -#define WHERE __WHERE__.s() - -const char *INI_SECTION = "t_ini_configurator"; - -int main(int formal(argc), char *formal(argv)[]) -{ - ini_configurator ini("t_ini_configurator.ini", ini_configurator::AUTO_STORE); - -console_logger out; -out.log(istring("ini file resides in: ") + ini.name()); - -out.log(istring("exe directory is currently: ") + path_configuration::application_directory()); - - for (int i = 0; i < test_iterations; i++) { // outer loop bracket. - // beginning of test sets. - { - // first test set. - const char *TEST_NAME = "first test: rectangle"; - // this tests whether rectangle storage works. - screen_rectangle default_rectangle(10, 289, 388, 191); - ini.delete_entry(INI_SECTION, "window_size"); - screen_rectangle win_size; - istring tmp = ini.load(INI_SECTION, "window_size", - default_rectangle.text_form()); - win_size.from_text(tmp); - if (win_size != default_rectangle) - deadly_error(INI_SECTION, TEST_NAME, - "rectangle not equal to default"); - screen_rectangle new_size(23, 49, 129, 93); - ini.store(INI_SECTION, "window_size", new_size.text_form()); - screen_rectangle current_size; - tmp = ini.load(INI_SECTION, "window_size", - default_rectangle.text_form()); - current_size.from_text(tmp); - if (current_size != new_size) - deadly_error(INI_SECTION, TEST_NAME, - "rectangle not equal to second size stored"); - } - { - // second test set. - const char *TEST_NAME = "second test: string"; - istring junk("this is a junky string to be stored as bytes...."); - byte_array to_store(junk.length() + 1, (byte *)junk.observe()); - istring as_bytes; - byte_format::bytes_to_string(to_store, as_bytes); - ini.store("test_of_byte_store", "test1", as_bytes); - istring blort = "blort_fest!"; - istring rettle = ini.load("test_of_byte_store", "test1", blort); - byte_array found_byte; - byte_format::string_to_bytes(rettle, found_byte); - istring found_junk((const char *)found_byte.observe()); - if (rettle == blort) - deadly_error(INI_SECTION, TEST_NAME, - "ini_configurator load failed: default was used"); - else if (found_junk != junk) - deadly_error(INI_SECTION, TEST_NAME, - "ini_configurator load failed: result differed from original"); - } - { - // third test set. - const char *TEST_NAME = "third test: frunkle"; - frunkle def_frunkle(3.14159265358); - istring def_text(istring::SPRINTF, "%f", def_frunkle.value()); - ini.store(INI_SECTION, TEST_NAME, def_text); - istring found_string = ini.load(INI_SECTION, TEST_NAME, "9949494.3"); - frunkle found_frunkle = found_string.convert(0.0); - if (found_frunkle == frunkle(9949494.3)) - deadly_error(INI_SECTION, TEST_NAME, - "ini_configurator load failed: default was used"); - if (found_frunkle != def_frunkle) - deadly_error(INI_SECTION, TEST_NAME, - "ini_configurator load failed: saved value differed"); - } - { - // fourth test set. - const char *TEST_NAME = "fourth test: frunkle"; - frunkle def_frunkle(1487335673.1415926535834985987); - istring def_text(istring::SPRINTF, "%f", def_frunkle.value()); - ini.store("test", "frunkle_test", def_text); - istring found_string = ini.load("test", "frunkle_test", "9949494.3"); - frunkle found_frunkle = found_string.convert(0.0); - if (found_frunkle == frunkle(9949494.3)) - deadly_error(INI_SECTION, TEST_NAME, - "ini_configurator load failed: wrong default was used"); - if (found_frunkle != def_frunkle) - deadly_error(INI_SECTION, TEST_NAME, - "ini_configurator load failed: saved value differed"); - } - { - // fifth test set. - const char *TEST_NAME = "fifth test: bytes"; - istring urp("urp"); - istring junk("this is a junky string to be stored as bytes...."); - byte_array default_bytes(urp.length() + 1, (byte *)urp.observe()); - istring defbytes_string; - byte_format::bytes_to_string(default_bytes, defbytes_string); - byte_array found; - istring tmp = ini.load("test_of_byte_store", "test1", defbytes_string); - byte_format::string_to_bytes(tmp, found); - istring string_found = (char *)found.observe(); - if (string_found == urp) - deadly_error(INI_SECTION, TEST_NAME, - "ini_configurator load_bytes failed: default was used"); - if (string_found.length() != junk.length()) - deadly_error(INI_SECTION, TEST_NAME, - "ini_configurator load_bytes failed: array lengths differ"); - if (string_found != junk) - deadly_error(INI_SECTION, TEST_NAME, - "ini_configurator load_bytes failed: arrays differ"); - } - { - // sixth test set. - const char *TEST_NAME = "sixth test: blank string"; - ini.delete_entry("test_of_blank_string", "test1"); - istring blank(""); - istring fund = ini.load("test_of_blank_string", "test1", blank); - if (fund != blank) - deadly_error(INI_SECTION, TEST_NAME, "ini_configurator load string " - "with blank default failed: didn't return blank"); - ini.delete_entry("test_of_blank_string", "test1"); - istring non_blank("blinkblankblunk"); - fund = ini.load("test_of_blank_string", "test1", non_blank); - if (fund != non_blank) - deadly_error(INI_SECTION, TEST_NAME, "ini_configurator load string " - "with non-blank default failed: didn't return default"); - fund = ini.load("test_of_blank_string", "test1", blank); - if (fund != non_blank) - deadly_error(INI_SECTION, TEST_NAME, "ini_configurator load string " - "with blank default failed: returned wrong string"); - } - } - - istring to_print("ini_configurator:: works for those functions tested."); - guards::alert_message(to_print.s()); - return 0; -} - diff --git a/nucleus/library/tests_configuration/makefile b/nucleus/library/tests_configuration/makefile index 04995769..61f335a2 100644 --- a/nucleus/library/tests_configuration/makefile +++ b/nucleus/library/tests_configuration/makefile @@ -2,7 +2,7 @@ include cpp/variables.def PROJECT = tests_configuration TYPE = test -TARGETS = test_section_manager.exe test_tokenizer.exe +TARGETS = test_ini_configurator.exe test_section_manager.exe test_tokenizer.exe LOCAL_LIBS_USED = unit_test application loggers configuration textual timely filesystem \ structures basis RUN_TARGETS = $(ACTUAL_TARGETS) diff --git a/nucleus/library/tests_configuration/test_ini_configurator.cpp b/nucleus/library/tests_configuration/test_ini_configurator.cpp new file mode 100644 index 00000000..fc84fda7 --- /dev/null +++ b/nucleus/library/tests_configuration/test_ini_configurator.cpp @@ -0,0 +1,178 @@ +/*****************************************************************************\ +* * +* Name : test_ini_configurator * +* Author : Chris Koeritz * +* * +******************************************************************************* +* Copyright (c) 1998-$now By Author. This program is free software; you can * +* redistribute it and/or modify it under the terms of the GNU General Public * +* License as published by the Free Software Foundation; either version 2 of * +* the License or (at your option) any later version. This is online at: * +* http://www.fsf.org/copyleft/gpl.html * +* Please send any updates to: fred@gruntose.com * +\*****************************************************************************/ + +const int test_iterations = 10; + +//#define DEBUG_INI_CONFIGURATOR_TEST + // uncomment for debugging version. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG_INI_CONFIGURATOR_TEST + #include +#endif + +HOOPLE_STARTUP_CODE; + +using namespace geometric; + +typedef double_plus frunkle; + +#define WHERE __WHERE__.s() + +const char *INI_SECTION = "t_ini_configurator"; + +int main(int formal(argc), char *formal(argv)[]) +{ + ini_configurator ini("t_ini_configurator.ini", ini_configurator::AUTO_STORE); + +console_logger out; +out.log(astring("ini file resides in: ") + ini.name()); + +out.log(astring("exe directory is currently: ") + application_configuration::application_directory()); + + for (int i = 0; i < test_iterations; i++) { // outer loop bracket. + // beginning of test sets. + { + // first test set. + const char *TEST_NAME = "first test: rectangle"; + // this tests whether rectangle storage works. + screen_rectangle default_rectangle(10, 289, 388, 191); + ini.delete_entry(INI_SECTION, "window_size"); + screen_rectangle win_size; + astring tmp = ini.load(INI_SECTION, "window_size", + default_rectangle.text_form()); + win_size.from_text(tmp); + if (win_size != default_rectangle) + deadly_error(INI_SECTION, TEST_NAME, + "rectangle not equal to default"); + screen_rectangle new_size(23, 49, 129, 93); + ini.store(INI_SECTION, "window_size", new_size.text_form()); + screen_rectangle current_size; + tmp = ini.load(INI_SECTION, "window_size", + default_rectangle.text_form()); + current_size.from_text(tmp); + if (current_size != new_size) + deadly_error(INI_SECTION, TEST_NAME, + "rectangle not equal to second size stored"); + } + { + // second test set. + const char *TEST_NAME = "second test: string"; + astring junk("this is a junky string to be stored as bytes...."); + byte_array to_store(junk.length() + 1, (byte *)junk.observe()); + astring as_bytes; + byte_formatter::bytes_to_string(to_store, as_bytes); + ini.store("test_of_byte_store", "test1", as_bytes); + astring blort = "blort_fest!"; + astring rettle = ini.load("test_of_byte_store", "test1", blort); + byte_array found_byte; + byte_formatter::string_to_bytes(rettle, found_byte); + astring found_junk((const char *)found_byte.observe()); + if (rettle == blort) + deadly_error(INI_SECTION, TEST_NAME, + "ini_configurator load failed: default was used"); + else if (found_junk != junk) + deadly_error(INI_SECTION, TEST_NAME, + "ini_configurator load failed: result differed from original"); + } + { + // third test set. + const char *TEST_NAME = "third test: frunkle"; + frunkle def_frunkle(3.14159265358); + astring def_text(astring::SPRINTF, "%f", def_frunkle.value()); + ini.store(INI_SECTION, TEST_NAME, def_text); + astring found_string = ini.load(INI_SECTION, TEST_NAME, "9949494.3"); + frunkle found_frunkle = found_string.convert(0.0); + if (found_frunkle == frunkle(9949494.3)) + deadly_error(INI_SECTION, TEST_NAME, + "ini_configurator load failed: default was used"); + if (found_frunkle != def_frunkle) + deadly_error(INI_SECTION, TEST_NAME, + "ini_configurator load failed: saved value differed"); + } + { + // fourth test set. + const char *TEST_NAME = "fourth test: frunkle"; + frunkle def_frunkle(1487335673.1415926535834985987); + astring def_text(astring::SPRINTF, "%f", def_frunkle.value()); + ini.store("test", "frunkle_test", def_text); + astring found_string = ini.load("test", "frunkle_test", "9949494.3"); + frunkle found_frunkle = found_string.convert(0.0); + if (found_frunkle == frunkle(9949494.3)) + deadly_error(INI_SECTION, TEST_NAME, + "ini_configurator load failed: wrong default was used"); + if (found_frunkle != def_frunkle) + deadly_error(INI_SECTION, TEST_NAME, + "ini_configurator load failed: saved value differed"); + } + { + // fifth test set. + const char *TEST_NAME = "fifth test: bytes"; + astring urp("urp"); + astring junk("this is a junky string to be stored as bytes...."); + byte_array default_bytes(urp.length() + 1, (byte *)urp.observe()); + astring defbytes_string; + byte_formatter::bytes_to_string(default_bytes, defbytes_string); + byte_array found; + astring tmp = ini.load("test_of_byte_store", "test1", defbytes_string); + byte_formatter::string_to_bytes(tmp, found); + astring string_found = (char *)found.observe(); + if (string_found == urp) + deadly_error(INI_SECTION, TEST_NAME, + "ini_configurator load_bytes failed: default was used"); + if (string_found.length() != junk.length()) + deadly_error(INI_SECTION, TEST_NAME, + "ini_configurator load_bytes failed: array lengths differ"); + if (string_found != junk) + deadly_error(INI_SECTION, TEST_NAME, + "ini_configurator load_bytes failed: arrays differ"); + } + { + // sixth test set. + const char *TEST_NAME = "sixth test: blank string"; + ini.delete_entry("test_of_blank_string", "test1"); + astring blank(""); + astring fund = ini.load("test_of_blank_string", "test1", blank); + if (fund != blank) + deadly_error(INI_SECTION, TEST_NAME, "ini_configurator load string " + "with blank default failed: didn't return blank"); + ini.delete_entry("test_of_blank_string", "test1"); + astring non_blank("blinkblankblunk"); + fund = ini.load("test_of_blank_string", "test1", non_blank); + if (fund != non_blank) + deadly_error(INI_SECTION, TEST_NAME, "ini_configurator load string " + "with non-blank default failed: didn't return default"); + fund = ini.load("test_of_blank_string", "test1", blank); + if (fund != non_blank) + deadly_error(INI_SECTION, TEST_NAME, "ini_configurator load string " + "with blank default failed: returned wrong string"); + } + } + + astring to_print("ini_configurator:: works for those functions tested."); + critical_events::alert_message(to_print.s()); + return 0; +} + diff --git a/nucleus/library/tests_filesystem/test_dirtree_fcopy.cpp b/nucleus/library/tests_filesystem/test_dirtree_fcopy.cpp index 37c8b52c..07c2f3db 100644 --- a/nucleus/library/tests_filesystem/test_dirtree_fcopy.cpp +++ b/nucleus/library/tests_filesystem/test_dirtree_fcopy.cpp @@ -54,12 +54,21 @@ int test_fcopy::execute() { FUNCDEF("execute"); +/* if (application::_global_argc < 3) non_continuable_error(class_name(), "command line", "this program needs two " "parameters:\na directory for the source and one for the target."); - - astring source_dir = application::_global_argv[1]; - astring target_dir = application::_global_argv[2]; +*/ + astring source_dir; + astring target_dir; + if (application::_global_argc < 3) { + // special default for testing--just use part of our own hierarchy to compare. + source_dir = environment::get("FEISTY_MEOW_SCRIPTS"); + target_dir = environment::get("FEISTY_MEOW_SCRIPTS"); + } else { + source_dir = application::_global_argv[1]; + target_dir = application::_global_argv[2]; + } // read the source location. log(astring("Scanning source tree at \"") + source_dir + "\""); @@ -151,7 +160,7 @@ int test_fcopy::execute() // //compare with source tree read before. - guards::alert_message("directory_tree file transfer:: works for those functions tested."); + critical_events::alert_message("directory_tree file transfer:: works for those functions tested."); return 0; } diff --git a/scripts/buildor/upgrade_hoople_to_feistymeow.sh b/scripts/buildor/upgrade_hoople_to_feistymeow.sh index 2f0d9ef7..515b9819 100644 --- a/scripts/buildor/upgrade_hoople_to_feistymeow.sh +++ b/scripts/buildor/upgrade_hoople_to_feistymeow.sh @@ -152,6 +152,7 @@ standards and usages." | sed -e 's/__argc/application::_global_argc/g' \ | sed -e 's/application_shell(static_class_name())/application_shell()/g' \ | sed -e 's/guards::alert_message/critical_events::alert_message/g' \ + | sed -e 's/^#include *$/#include /g' \ | sed -e 's/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/[\/]*/\/\/\/\/\/\/\/\/\/\/\/\/\/\//g' \ >"$tempfile"