diff --git a/client/boinc_cmd.cpp b/client/boinc_cmd.cpp index 79a211a6c26..eb9833899d1 100644 --- a/client/boinc_cmd.cpp +++ b/client/boinc_cmd.cpp @@ -32,8 +32,9 @@ #include #include -using std::vector; -using std::string; +#include +#include +#include #include "gui_rpc_client.h" #include "error_numbers.h" @@ -43,6 +44,11 @@ using std::string; #include "url.h" #include "version.h" #include "common_defs.h" +#include "pretty_printer.h" + +using std::vector; +using std::string; +using std::map; void version(){ printf("boinccmd, built from %s \n", PACKAGE_STRING ); @@ -51,7 +57,7 @@ void version(){ void usage() { fprintf(stderr, "\n\ -usage: boinccmd [--host hostname] [--passwd passwd] [--unix_domain] command\n\n\ +usage: boinccmd [--host hostname] [--passwd passwd] [--unix_domain] [--json] command\n\n\ default hostname: localhost\n\ default password: contents of gui_rpc_auth.cfg\n\ Commands:\n\ @@ -165,11 +171,11 @@ void acct_mgr_do_rpc( int main(int argc, char** argv) { RPC_CLIENT rpc; - int i, retval, port=0; + int i, retval, port = 0; MESSAGES messages; NOTICES notices; - char passwd_buf[256], hostname_buf[256], *hostname=0; - char* passwd = passwd_buf, *p, *q; + char passwd_buf[256], hostname_buf[256], * hostname = 0; + char* passwd = passwd_buf, * p, * q; bool unix_domain = false; string msg; @@ -217,23 +223,23 @@ int main(int argc, char** argv) { fprintf(stderr, "invalid IPv6 syntax: %s\n", hostname_buf); exit(1); } - hostname = p+1; + hostname = p + 1; *q = 0; - port = atoi(q+1); + port = atoi(q + 1); } else { hostname = hostname_buf; p = strchr(hostname, ':'); if (p) { - q = strchr(p+1, ':'); + q = strchr(p + 1, ':'); if (!q) { - port = atoi(p+1); - *p=0; + port = atoi(p + 1); + *p = 0; } } } i++; } - if ((i version; + version["Major"] = vi.major; + version["Minor"] = vi.minor; + version["Release"] = vi.release; + + printer.insert("Client Version", version); + } + + printf("%s\n", printer.prettify(console_print).c_str()); + printer.clear(); } } else if (!strcmp(cmd, "--get_state")) { CC_STATE state; retval = rpc.get_state(state); - if (!retval) state.print(); + if (!retval) state.print(console_print); } else if (!strcmp(cmd, "--get_tasks")) { RESULTS results; retval = rpc.get_results(results); - if (!retval) results.print(); + if (!retval) results.print(console_print); } else if (!strcmp(cmd, "--get_old_tasks")) { vector ors; retval = rpc.get_old_results(ors); if (!retval) { - for (unsigned int j=0; j= argc || (argv[i][0] == '-')) { duration = 0; } else { @@ -405,16 +481,28 @@ int main(int argc, char** argv) { } if (!strcmp(op, "always")) { retval = rpc.set_run_mode(RUN_MODE_ALWAYS, duration); + printer.insert("Result", retval); } else if (!strcmp(op, "auto")) { retval = rpc.set_run_mode(RUN_MODE_AUTO, duration); + printer.insert("Result", retval); } else if (!strcmp(op, "never")) { retval = rpc.set_run_mode(RUN_MODE_NEVER, duration); + printer.insert("Result", retval); } else { - fprintf(stderr, "Unknown op %s\n", op); + string task_result = "Unknown operation "; + task_result += op; + printer.insert("Result", task_result); + fprintf(stderr, "%s\n", printer.prettify(console_print).c_str()); + done = true; + } + if (!done) { + printf("%s\n", printer.prettify(console_print).c_str()); } + printer.clear(); } else if (!strcmp(cmd, "--set_gpu_mode")) { char* op = next_arg(argc, argv, i); double duration; + auto done = false; if (i >= argc || (argv[i][0] == '-')) { duration = 0; } else { @@ -422,22 +510,37 @@ int main(int argc, char** argv) { } if (!strcmp(op, "always")) { retval = rpc.set_gpu_mode(RUN_MODE_ALWAYS, duration); + printer.insert("Result", retval); } else if (!strcmp(op, "auto")) { retval = rpc.set_gpu_mode(RUN_MODE_AUTO, duration); + printer.insert("Result", retval); } else if (!strcmp(op, "never")) { retval = rpc.set_gpu_mode(RUN_MODE_NEVER, duration); + printer.insert("Result", retval); } else { - fprintf(stderr, "Unknown op %s\n", op); + string task_result = "Unknown operation "; + task_result += op; + printer.insert("Result", task_result); + fprintf(stderr, "%s\n", printer.prettify(console_print).c_str()); + done = true; } + if (!done) { + printf("%s\n", printer.prettify(console_print).c_str()); + } + printer.clear(); } else if (!strcmp(cmd, "--set_host_info")) { HOST_INFO h; memset(&h, 0, sizeof(h)); char* pn = next_arg(argc, argv, i); safe_strcpy(h.product_name, pn); retval = rpc.set_host_info(h); + printer.insert("Result", retval); + printf("%s\n", printer.prettify(console_print).c_str()); + printer.clear(); } else if (!strcmp(cmd, "--set_network_mode")) { char* op = next_arg(argc, argv, i); double duration; + auto done = false; if (i >= argc || (argv[i][0] == '-')) { duration = 0; } else { @@ -445,17 +548,28 @@ int main(int argc, char** argv) { } if (!strcmp(op, "always")) { retval = rpc.set_network_mode(RUN_MODE_ALWAYS, duration); + printer.insert("Result", retval); } else if (!strcmp(op, "auto")) { retval = rpc.set_network_mode(RUN_MODE_AUTO, duration); + printer.insert("Result", retval); } else if (!strcmp(op, "never")) { retval = rpc.set_network_mode(RUN_MODE_NEVER, duration); + printer.insert("Result", retval); } else { - fprintf(stderr, "Unknown op %s\n", op); + string task_result = "Unknown operation "; + task_result += op; + printer.insert("Result", task_result); + fprintf(stderr, "%s\n", printer.prettify(console_print).c_str()); + done = true; + } + if (!done) { + printf("%s\n", printer.prettify(console_print).c_str()); } + printer.clear(); } else if (!strcmp(cmd, "--get_proxy_settings")) { GR_PROXY_INFO pi; retval = rpc.get_proxy_settings(pi); - if (!retval) pi.print(); + if (!retval) pi.print(console_print); } else if (!strcmp(cmd, "--set_proxy_settings")) { GR_PROXY_INFO pi; pi.http_server_name = next_arg(argc, argv, i); @@ -471,11 +585,16 @@ int main(int argc, char** argv) { if (pi.http_user_name.size()) pi.use_http_authentication = true; if (pi.socks_server_name.size()) pi.use_socks_proxy = true; retval = rpc.set_proxy_settings(pi); + printer.insert("Result", retval); + printf("%s\n", printer.prettify(console_print).c_str()); + printer.clear(); } else if (!strcmp(cmd, "--get_message_count")) { int seqno; retval = rpc.get_message_count(seqno); if (!retval) { - printf("Greatest message sequence number: %d\n", seqno); + printer.insert("Greatest message sequence number", seqno); + printf("%s\n", printer.prettify(console_print).c_str()); + printer.clear(); } } else if (!strcmp(cmd, "--get_messages")) { int seqno; @@ -487,16 +606,33 @@ int main(int argc, char** argv) { retval = rpc.get_messages(seqno, messages); if (!retval) { unsigned int j; + vector printers; for (j=0; j printers; for (j=0; j #include +#include +#include #include "cc_config.h" #include "common_defs.h" @@ -50,6 +52,11 @@ #include "network.h" #include "notice.h" #include "prefs.h" +#include "pretty_printer.h" + +using std::string; +using std::map; +using std::pair; struct GUI_URL { std::string name; @@ -57,7 +64,7 @@ struct GUI_URL { std::string url; int parse(XML_PARSER&); - void print(); + pair> get(); }; // statistics at a specific day @@ -184,8 +191,8 @@ struct PROJECT { PROJECT(); int parse(XML_PARSER&); - void print(); - void print_disk_usage(); + pretty_printer get(); + pretty_printer get_disk_usage(); void clear(); void get_name(std::string&); @@ -201,7 +208,7 @@ struct APP { APP(); int parse(XML_PARSER&); - void print(); + pretty_printer get() const; void clear(); }; @@ -226,7 +233,7 @@ struct APP_VERSION { int parse(XML_PARSER&); int parse_coproc(XML_PARSER&); int parse_file_ref(XML_PARSER&); - void print(); + pretty_printer get() const; void clear(); }; @@ -245,7 +252,7 @@ struct WORKUNIT { WORKUNIT(); int parse(XML_PARSER&); - void print(); + pretty_printer get(); void clear(); }; @@ -310,7 +317,7 @@ struct RESULT { RESULT(); int parse(XML_PARSER&); - void print(); + pretty_printer get(); void clear(); }; @@ -340,7 +347,7 @@ struct FILE_TRANSFER { FILE_TRANSFER(); int parse(XML_PARSER&); - void print(); + pretty_printer get(); void clear(); }; @@ -354,7 +361,7 @@ struct MESSAGE { MESSAGE(); int parse(XML_PARSER&); - void print(); + pretty_printer get() const; void clear(); }; @@ -375,12 +382,12 @@ struct GR_PROXY_INFO { std::string socks5_user_passwd; bool socks5_remote_dns; - std::string noproxy_hosts; + std::string noproxy_hosts; GR_PROXY_INFO(); int parse(XML_PARSER&); - void print(); + void print(const bool& console_print); void clear(); }; @@ -418,7 +425,7 @@ struct CC_STATE { RESULT* lookup_result(PROJECT*, const char* name); RESULT* lookup_result(const char* url, const char* name); - void print(); + void print(const bool& console_print); void clear(); int parse(XML_PARSER&); inline bool have_gpu() { @@ -433,8 +440,8 @@ struct PROJECTS { PROJECTS(){} - void print(); - void print_urls(); + void print(const bool& console_print); + void print_urls(const bool& console_print); void clear(); }; @@ -447,7 +454,7 @@ struct DISK_USAGE { DISK_USAGE(){clear();} - void print(); + void print(const bool& console_print); void clear(); }; @@ -456,7 +463,7 @@ struct RESULTS { RESULTS(){} - void print(); + void print(const bool& console_print); void clear(); }; @@ -465,7 +472,7 @@ struct FILE_TRANSFERS { FILE_TRANSFERS(); - void print(); + void print(const bool& console_print); void clear(); }; @@ -474,7 +481,7 @@ struct MESSAGES { MESSAGES(); - void print(); + void print(const bool& console_print) const; void clear(); }; @@ -500,7 +507,7 @@ struct ACCT_MGR_INFO { ACCT_MGR_INFO(); int parse(XML_PARSER&); - void print(); + void print(const bool& console_print) const; void clear(); }; @@ -554,7 +561,7 @@ struct PROJECT_CONFIG { bool sched_stopped; // scheduler disabled bool web_stopped; // DB-driven web functions disabled int min_client_version; - std::string error_msg; + std::string error_msg; bool terms_of_use_is_html; std::string terms_of_use; // if present, show this text in an "accept terms of use?" dialog @@ -568,7 +575,7 @@ struct PROJECT_CONFIG { int parse(XML_PARSER&); void clear(); - void print(); + void print(const bool& console_print) const; }; struct ACCOUNT_IN { @@ -591,14 +598,14 @@ struct ACCOUNT_IN { struct ACCOUNT_OUT { int error_num; - std::string error_msg; + std::string error_msg; std::string authenticator; ACCOUNT_OUT(); int parse(XML_PARSER&); void clear(); - void print(); + void print(const bool& console_print) const; }; struct CC_STATUS { @@ -608,15 +615,15 @@ struct CC_STATUS { int task_suspend_reason; // bitmap, see common_defs.h int task_mode; // always/auto/never; see common_defs.h int task_mode_perm; // same, but permanent version - double task_mode_delay; // time until perm becomes actual + double task_mode_delay; // time until perm becomes actual int gpu_suspend_reason; int gpu_mode; int gpu_mode_perm; - double gpu_mode_delay; + double gpu_mode_delay; int network_suspend_reason; int network_mode; int network_mode_perm; - double network_mode_delay; + double network_mode_delay; bool disallow_attach; bool simple_gui_only; int max_event_log_lines; @@ -625,13 +632,13 @@ struct CC_STATUS { int parse(XML_PARSER&); void clear(); - void print(); + void print(const bool& console_print) const; }; struct SIMPLE_GUI_INFO { std::vector projects; std::vector results; - void print(); + void print(const bool& console_print); }; struct DAILY_XFER { @@ -645,7 +652,7 @@ struct DAILY_XFER { struct DAILY_XFER_HISTORY { std::vector daily_xfers; int parse(XML_PARSER&); - void print(); + void print(const bool& console_print); }; // Keep this consistent with client/result.h @@ -661,7 +668,7 @@ struct OLD_RESULT { double create_time; int parse(XML_PARSER&); - void print(); + pair get(); }; struct RPC_CLIENT { @@ -768,7 +775,7 @@ struct RPC_CLIENT { int get_app_config(const char* url, APP_CONFIGS& conf); int set_app_config(const char* url, APP_CONFIGS& conf); int get_daily_xfer_history(DAILY_XFER_HISTORY&); - int set_language(const char*); + int set_language(const char*); }; struct RPC { diff --git a/lib/gui_rpc_client_print.cpp b/lib/gui_rpc_client_print.cpp index ecfaae8da89..43a25dbe292 100644 --- a/lib/gui_rpc_client_print.cpp +++ b/lib/gui_rpc_client_print.cpp @@ -33,6 +33,10 @@ #include #endif +#include +#include +#include + #include "diagnostics.h" #include "error_numbers.h" #include "md5_file.h" @@ -41,211 +45,313 @@ #include "parse.h" #include "str_util.h" #include "util.h" +#include "pretty_printer.h" #include "gui_rpc_client.h" using std::string; +using std::map; +using std::pair; using std::vector; -void DAILY_XFER_HISTORY::print() { - for (unsigned int i=0; i +string format(const string& format_string, T arguments) { + const auto size = snprintf(nullptr, 0, format_string.c_str(), arguments) + 1; + auto buf = vector(size); + sprintf(buf.data(), format_string.c_str(), arguments); + + return buf.data(); +} + +// Helper function to print groups of structs +template +void print_group(const string& group_name, vector& items, const bool& console_print, pretty_printer& printer, const bool& print_printer = true) { + if (console_print) { + printf("\n======== %s ========\n", group_name.c_str()); + for (unsigned int i = 0; i < items.size(); i++) { + pretty_printer item_printer = items.at(i)->get(); + item_printer.change_spacing(1); + + printf("%d) -----------\n", i + 1); + printf("%s\n", item_printer.prettify(true).c_str()); + } + + } else { + if (items.empty()) return; + vector printers; + printers.reserve(items.size()); + for (const auto item : items) { + printers.push_back(item->get()); + } + + printer.insert(group_name, printers); + if (print_printer) { + printf("%s\n", printer.prettify(console_print).c_str()); + } + } +} + +void DAILY_XFER_HISTORY::print(const bool& console_print) { + if (daily_xfers.empty()) { + printf("\n"); + return; + } + + pretty_printer printer(0); + for (const auto& xfer : daily_xfers) { char buf[256]; - time_t t = dx.when*86400; + time_t t = xfer.when * 86400; struct tm* tm = localtime(&t); - strftime(buf, sizeof(buf)-1, "%d-%b-%Y", tm); - printf("%s: %.0f bytes uploaded, %.0f bytes downloaded\n", - buf, dx.up, dx.down - ); + strftime(buf, sizeof(buf) - 1, "%d-%b-%Y", tm); + + map info; + info["bytes uploaded"] = xfer.up; + info["bytes downloaded"] = xfer.down;; + printer.insert(buf, info); } + + printf("%s\n", printer.prettify(console_print).c_str()); } -void GUI_URL::print() { - printf( - "GUI URL:\n" - " name: %s\n" - " description: %s\n" - " URL: %s\n", - name.c_str(), description.c_str(), url.c_str() - ); +pair> GUI_URL::get() { + map result; + result["description"] = description; + result["URL"] = url; + + return pair>(name, result); } -void PROJECT::print_disk_usage() { - printf(" master URL: %s\n", master_url); - printf(" disk usage: %.2fMB\n", disk_usage/MEGA); +pretty_printer PROJECT::get_disk_usage() { + pretty_printer result; + result.insert("master URL", master_url); + result.insert("disk usage", format("%.2fMB", disk_usage / MEGA)); + return result; } -void PROJECT::print() { - unsigned int i; - - printf(" name: %s\n", project_name.c_str()); - printf(" master URL: %s\n", master_url); - printf(" user_name: %s\n", user_name.c_str()); - printf(" team_name: %s\n", team_name.c_str()); - printf(" resource share: %f\n", resource_share); - printf(" user_total_credit: %f\n", user_total_credit); - printf(" user_expavg_credit: %f\n", user_expavg_credit); - printf(" host_total_credit: %f\n", host_total_credit); - printf(" host_expavg_credit: %f\n", host_expavg_credit); - printf(" nrpc_failures: %d\n", nrpc_failures); - printf(" master_fetch_failures: %d\n", master_fetch_failures); - printf(" master fetch pending: %s\n", master_url_fetch_pending?"yes":"no"); - printf(" scheduler RPC pending: %s\n", sched_rpc_pending?"yes":"no"); - printf(" trickle upload pending: %s\n", trickle_up_pending?"yes":"no"); - printf(" attached via Account Manager: %s\n", attached_via_acct_mgr?"yes":"no"); - printf(" ended: %s\n", ended?"yes":"no"); - printf(" suspended via GUI: %s\n", suspended_via_gui?"yes":"no"); - printf(" don't request more work: %s\n", dont_request_more_work?"yes":"no"); - printf(" disk usage: %.2fMB\n", disk_usage/MEGA); - time_t foo = (time_t)last_rpc_time; - printf(" last RPC: %s\n", ctime(&foo)); - printf(" project files downloaded: %f\n", project_files_downloaded_time); - for (i=0; i> urls; + for (auto url: gui_urls) { + urls[url.get().first] = url.get().second; } - printf(" jobs succeeded: %d\n", njobs_success); - printf(" jobs failed: %d\n", njobs_error); - printf(" elapsed time: %f\n", elapsed_time); - printf(" cross-project ID: %s\n", external_cpid); + result.insert("GUI URLs", urls); + + result.insert("jobs succeeded", njobs_success); + result.insert("jobs failed", njobs_error); + result.insert("elapsed time", elapsed_time); + result.insert("cross-project ID", external_cpid); + + return result; } -void APP::print() { - printf(" name: %s\n", name); - printf(" Project: %s\n", project->project_name.c_str()); +pretty_printer APP::get() const { + pretty_printer result; + + result.insert("name", name); + result.insert("Project", project->project_name.c_str()); + + return result; } -void APP_VERSION::print() { - printf(" project: %s\n", project->project_name.c_str()); - printf(" application: %s\n", app->name); - printf(" platform: %s\n", platform); +pretty_printer APP_VERSION::get() const { + pretty_printer result(3); + + result.insert("project", project->project_name.c_str()); + result.insert("application", app->name); + result.insert("platform", platform); if (strlen(plan_class)) { - printf(" plan class: %s\n", plan_class); + result.insert("plan class", plan_class); } - printf(" version: %.2f\n", version_num/100.0); + result.insert("version", version_num / 100.0); if (avg_ncpus != 1) { - printf(" avg #CPUS: %.3f\n", avg_ncpus); + result.insert("avg #CPUS", avg_ncpus); } if (gpu_type != PROC_TYPE_CPU) { - printf(" coprocessor type: %s\n", proc_type_name(gpu_type)); - printf(" coprocessor usage: %.3f\n", gpu_usage); + result.insert("coprocessor type", proc_type_name(gpu_type)); + result.insert("coprocessor usage", gpu_usage); } - printf(" estimated GFLOPS: %.2f\n", flops/1e9); - printf(" filename: %s\n", exec_filename); + result.change_decimal(2); + result.insert("estimated GFLOPS", flops/1e9); + result.insert("filename", exec_filename); + + return result; } -void WORKUNIT::print() { - printf(" name: %s\n", name); - printf(" FP estimate: %e\n", rsc_fpops_est); - printf(" FP bound: %e\n", rsc_fpops_bound); - printf(" memory bound: %.2f MB\n", rsc_memory_bound/MEGA); - printf(" disk bound: %.2f MB\n", rsc_disk_bound/MEGA); +pretty_printer WORKUNIT::get() { + pretty_printer result; + + result.insert("name", name); + result.insert("FP estimate", format("%e", rsc_fpops_est)); + result.insert("FP bound", format("%e", rsc_fpops_bound)); + result.insert("memory bound", format("%.2f MB", rsc_memory_bound / MEGA)); + result.insert("disk bound", format("%.2f MB", rsc_disk_bound / MEGA)); if (!job_keywords.empty()) { - printf(" keywords:\n"); - for (unsigned int i=0; i keywords; + for (const auto& i : job_keywords.keywords) { + keywords.emplace_back(i.name); } + result.insert("keywords", keywords); } + + return result; } -void RESULT::print() { - printf(" name: %s\n", name); - printf(" WU name: %s\n", wu_name); - printf(" project URL: %s\n", project_url); - time_t foo = (time_t)received_time; - printf(" received: %s", ctime(&foo)); +pretty_printer RESULT::get() { + pretty_printer result; + + result.insert("name", name); + result.insert("WU name", wu_name); + result.insert("project URL", project_url); + + time_t foo = (time_t) received_time; + auto time_string = string(ctime(&foo)); + if (time_string.back() == '\n') { + time_string.pop_back(); + } + result.insert("received", time_string); + foo = (time_t)report_deadline; - printf(" report deadline: %s", ctime(&foo)); - printf(" ready to report: %s\n", ready_to_report?"yes":"no"); - printf(" state: %s\n", result_client_state_string(state)); - printf(" scheduler state: %s\n", result_scheduler_state_string(scheduler_state)); - printf(" active_task_state: %s\n", active_task_state_string(active_task_state)); - //printf(" stderr_out: %s\n", stderr_out.c_str()); - printf(" app version num: %d\n", version_num); - printf(" resources: %s\n", strlen(resources)?resources:"1 CPU"); + time_string = string(ctime(&foo)); + if (time_string.back() == '\n') { + time_string.pop_back(); + } + result.insert("report deadline", time_string); + + result.insert("ready to report", ready_to_report); + result.insert("state", result_client_state_string(state)); + result.insert("scheduler state", result_scheduler_state_string(scheduler_state)); + result.insert("active_task_state", active_task_state_string(active_task_state)); + //result.insert("stderr_out", stderr_out.c_str()); + result.insert("app version num", version_num); + result.insert("resources", strlen(resources) ? resources : "1 CPU"); // stuff for jobs that are not yet completed // if (state <= RESULT_FILES_DOWNLOADED) { if (suspended_via_gui) { - printf(" suspended via GUI: yes\n"); + result.insert("suspended via GUI", true); } - printf(" estimated CPU time remaining: %f\n", estimated_cpu_time_remaining); - printf(" elapsed task time: %f\n", elapsed_time); + result.insert("estimated CPU time remaining", estimated_cpu_time_remaining); } // stuff for jobs that are running or have run // if (scheduler_state > CPU_SCHED_UNINITIALIZED) { - printf(" slot: %d\n", slot); - printf(" PID: %d\n", pid); - printf(" CPU time at last checkpoint: %f\n", checkpoint_cpu_time); - printf(" current CPU time: %f\n", current_cpu_time); - printf(" fraction done: %f\n", fraction_done); - printf(" swap size: %.0f MB\n", swap_size/MEGA); - printf(" working set size: %.0f MB\n", working_set_size_smoothed/MEGA); + result.insert("slot", slot); + result.insert("PID", pid); + result.insert("CPU time at last checkpoint", checkpoint_cpu_time); + result.insert("current CPU time", current_cpu_time); + result.insert("fraction done", fraction_done); + result.insert("swap size", format("%.0f MB", swap_size / MEGA)); + result.insert("working set size", format("%.0f MB", working_set_size_smoothed / MEGA)); if (bytes_sent || bytes_received) { - printf(" bytes sent: %.0f received: %.0f\n", - bytes_sent, bytes_received - ); + result.change_decimal(0); + result.insert("bytes sent", bytes_sent); + result.insert("bytes received", bytes_received); } } // stuff for completed jobs // if (state > RESULT_FILES_DOWNLOADED) { - printf(" final CPU time: %f\n", final_cpu_time); - printf(" final elapsed time: %f\n", final_elapsed_time); - printf(" exit_status: %d\n", exit_status); - printf(" signal: %d\n", signal); + result.insert("final CPU time", final_cpu_time); + result.insert("final elapsed time", final_elapsed_time); + result.insert("exit_status", exit_status); + result.insert("signal", signal); } + + return result; } -void FILE_TRANSFER::print() { - printf(" name: %s\n", name.c_str()); - printf(" direction: %s\n", is_upload?"upload":"download"); - printf(" sticky: %s\n", sticky?"yes":"no"); - printf(" xfer active: %s\n", xfer_active?"yes":"no"); - printf(" time_so_far: %f\n", time_so_far); - printf(" bytes_xferred: %f\n", bytes_xferred); - printf(" xfer_speed: %f\n", xfer_speed); +pretty_printer FILE_TRANSFER::get() { + pretty_printer result; + + result.insert("name", name.c_str()); + result.insert("direction", is_upload?"upload":"download"); + result.insert("sticky", sticky); + result.insert("xfer active", xfer_active); + result.insert("time_so_far", time_so_far); + result.insert("bytes_xferred", bytes_xferred); + result.insert("xfer_speed", xfer_speed); + + return result; } -void MESSAGE::print() { - printf("%s %d %d %s\n", - project.c_str(), priority, timestamp, body.c_str() - ); +pretty_printer MESSAGE::get() const { + pretty_printer result; + result.insert("Project", project.c_str()); + result.insert("Priority", priority); + result.insert("Timestamp", timestamp); + result.insert("Body", body.c_str()); + + return result; } -void GR_PROXY_INFO::print() { - printf("HTTP server name: %s\n",this->http_server_name.c_str()); - printf("HTTP server port: %d\n",this->http_server_port); - printf("HTTP user name: %s\n",this->http_user_name.c_str()); - //printf("HTTP user password: %s\n",this->http_user_passwd.c_str()); - printf("SOCKS server name: %s\n",this->socks_server_name.c_str()); - printf("SOCKS server port: %d\n",this->socks_server_port); - printf("SOCKS5 user name: %s\n",this->socks5_user_name.c_str()); - //printf("SOCKS5 user password: %s\n",this->socks5_user_passwd.c_str()); - printf("no proxy hosts: %s\n",this->noproxy_hosts.c_str()); +void GR_PROXY_INFO::print(const bool& console_print) { + pretty_printer result; + + result.insert("HTTP server name",this->http_server_name.c_str()); + result.insert("HTTP server port",this->http_server_port); + result.insert("HTTP user name",this->http_user_name.c_str()); + //result.insert("HTTP user password",this->http_user_passwd.c_str()); + result.insert("SOCKS server name",this->socks_server_name.c_str()); + result.insert("SOCKS server port",this->socks_server_port); + result.insert("SOCKS5 user name",this->socks5_user_name.c_str()); + //result.insert("SOCKS5 user password",this->socks5_user_passwd.c_str()); + result.insert("no proxy hosts",this->noproxy_hosts.c_str()); + + printf("%s\n", result.prettify(console_print).c_str()); } -void HOST_INFO::print() { - printf(" timezone: %d\n", timezone); - printf(" domain name: %s\n", domain_name); - printf(" IP addr: %s\n", ip_addr); - printf(" #CPUS: %d\n", p_ncpus); - printf(" CPU vendor: %s\n", p_vendor); - printf(" CPU model: %s\n", p_model); - printf(" CPU FP OPS: %f\n", p_fpops); - printf(" CPU int OPS: %f\n", p_iops); - //printf(" CPU mem BW: %f\n", p_membw); - printf(" OS name: %s\n", os_name); - printf(" OS version: %s\n", os_version); - printf(" mem size: %f\n", m_nbytes); - printf(" cache size: %f\n", m_cache); - printf(" swap size: %f\n", m_swap); - printf(" disk size: %f\n", d_total); - printf(" disk free: %f\n", d_free); +void HOST_INFO::print(const bool& console_print) { + pretty_printer result; + + result.insert("timezone", timezone); + result.insert("domain name", domain_name); + result.insert("IP addr", ip_addr); + result.insert("#CPUS", p_ncpus); + result.insert("CPU vendor", p_vendor); + result.insert("CPU model", p_model); + result.insert("CPU FP OPS", p_fpops); + result.insert("CPU int OPS", p_iops); + //result.insert("CPU mem BW", p_membw); + result.insert("OS name", os_name); + result.insert("OS version", os_version); + result.insert("mem size", m_nbytes); + result.insert("cache size", m_cache); + result.insert("swap size", m_swap); + result.insert("disk size", d_total); + result.insert("disk free", d_free); // Show GPU info. // This is harder than it should be, @@ -257,254 +363,260 @@ void HOST_INFO::print() { COPROC_NVIDIA& cn = coprocs.nvidia; if (cn.count) { cn.description(buf, sizeof(buf)); - printf(" NVIDIA GPU: %s\n", buf); + result.insert("NVIDIA GPU", buf); if (cn.count > 1) { - printf(" Count: %d\n", cn.count); + result.insert("Count", cn.count); } if (cn.have_opencl) { cn.opencl_prop.is_used = COPROC_USED; cn.opencl_prop.peak_flops = cn.peak_flops; cn.opencl_prop.opencl_available_ram = cn.available_ram; cn.opencl_prop.description(buf, sizeof(buf), "NVIDIA"); - printf(" %s\n", buf); + const string& buf_string = buf; + result.insert("OpenCL", buf_string.substr(8, buf_string.size())); } } COPROC_ATI &ca = coprocs.ati; if (ca.count) { ca.description(buf, sizeof(buf)); - printf(" AMD GPU: %s\n", buf); + result.insert("AMD GPU", buf); if (ca.count > 1) { - printf(" Count: %d\n", ca.count); + result.insert("Count", ca.count); } if (ca.have_opencl) { ca.opencl_prop.peak_flops = ca.peak_flops; ca.opencl_prop.opencl_available_ram = ca.available_ram; ca.opencl_prop.is_used = COPROC_USED; ca.opencl_prop.description(buf, sizeof(buf), "AMD"); - printf(" %s\n", buf); + const string& buf_string = buf; + result.insert("OpenCL", buf_string.substr(8, buf_string.size())); } } COPROC_INTEL &ci = coprocs.intel_gpu; if (ci.count) { - printf(" Intel GPU\n"); + result.insert("Intel GPU", buf); if (ci.count > 1) { - printf(" Count: %d\n", ci.count); + result.insert("Count", ci.count); } if (ci.have_opencl) { ci.opencl_prop.peak_flops = ci.peak_flops; ci.opencl_prop.opencl_available_ram = ci.opencl_prop.global_mem_size; ci.opencl_prop.is_used = COPROC_USED; ci.opencl_prop.description(buf, sizeof(buf), "Intel GPU"); - printf(" %s\n", buf); + const string& buf_string = buf; + result.insert("OpenCL", buf_string.substr(8, buf_string.size())); } } -} -void SIMPLE_GUI_INFO::print() { - unsigned int i; - printf("======== Projects ========\n"); - for (i=0; iprint(); - } - printf("\n======== Tasks ========\n"); - for (i=0; iprint(); + if (console_print) { + result.change_spacing(1); } + printf("%s\n", result.prettify(console_print).c_str()); } -void TIME_STATS::print() { - printf(" now: %f\n", now); - printf(" on_frac: %f\n", on_frac); - printf(" connected_frac: %f\n", connected_frac); - printf(" cpu_and_network_available_frac: %f\n", cpu_and_network_available_frac); - printf(" active_frac: %f\n", active_frac); - printf(" gpu_active_frac: %f\n", gpu_active_frac); - time_t foo = (time_t)client_start_time; - printf(" client_start_time: %s\n", ctime(&foo)); - printf(" previous_uptime: %f\n", previous_uptime); - printf(" session_active_duration: %f\n", session_active_duration); - printf(" session_gpu_active_duration: %f\n", session_gpu_active_duration); - foo = (time_t)total_start_time; - printf(" total_start_time: %s\n", ctime(&foo)); - printf(" total_duration: %f\n", total_duration); - printf(" total_active_duration: %f\n", total_active_duration); - printf(" total_gpu_active_duration: %f\n", total_gpu_active_duration); +void SIMPLE_GUI_INFO::print(const bool& console_print) { + pretty_printer printer; + print_group("Projects", projects, console_print, printer, false); + print_group("Tasks", results, console_print, printer); } -void CC_STATE::print() { - unsigned int i; - printf("======== Projects ========\n"); - for (i=0; iprint(); - } - printf("\n======== Applications ========\n"); - for (i=0; iprint(); - } - printf("\n======== Application versions ========\n"); - for (i=0; iprint(); +pretty_printer TIME_STATS::get() { + pretty_printer result; + result.insert("now", now); + result.insert("on_frac", on_frac); + result.insert("connected_frac", connected_frac); + result.insert("cpu_and_network_available_frac", cpu_and_network_available_frac); + result.insert("active_frac", active_frac); + result.insert("gpu_active_frac", gpu_active_frac); + + time_t foo = (time_t)client_start_time; + auto time_string = string(ctime(&foo)); + if (time_string.back() == '\n') { + time_string.pop_back(); } - printf("\n======== Workunits ========\n"); - for (i=0; iprint(); + result.insert("client_start_time", time_string); + + result.insert("previous_uptime", previous_uptime); + result.insert("session_active_duration", session_active_duration); + result.insert("session_gpu_active_duration", session_gpu_active_duration); + + foo = (time_t)total_start_time; + time_string = string(ctime(&foo)); + if (time_string.back() == '\n') { + time_string.pop_back(); } - printf("\n======== Tasks ========\n"); - for (i=0; iprint(); + result.insert("total_start_time", time_string); + + result.insert("total_duration", total_duration); + result.insert("total_active_duration", total_active_duration); + result.insert("total_gpu_active_duration", total_gpu_active_duration); + + return result; +} + +void CC_STATE::print(const bool& console_print) { + pretty_printer status_printer; + + print_group("Projects", projects, console_print, status_printer, false); + print_group("Applications", apps, console_print, status_printer, false); + print_group("Application versions", app_versions, console_print, status_printer, false); + print_group("Workunits", wus, console_print, status_printer, false); + print_group("Tasks", results, console_print, status_printer, false); + + if (console_print) { + printf("\n======== Time stats ========\n"); + auto time_stats_printer = time_stats.get(); + time_stats_printer.change_spacing(1); + + printf("%s\n", time_stats_printer.prettify(true).c_str()); + } else { + status_printer.insert("Time stats", time_stats.get()); + printf("%s\n", status_printer.prettify().c_str()); } - printf("\n======== Time stats ========\n"); - time_stats.print(); } -void print_status( - const char* name, int reason, int mode, int mode_perm, double delay -) { - printf("%s status\n", name); +pretty_printer print_status (int reason, int mode, int mode_perm, double delay) { + pretty_printer printer; + if (reason) { - printf(" suspended: %s\n", suspend_reason_string(reason)); + printer.insert("status", "suspended"); + printer.insert("reason", suspend_reason_string(reason)); } else { - printf(" not suspended\n"); + printer.insert("status", "not suspended"); } - printf( - " current mode: %s\n" - " perm mode: %s\n" - " perm becomes current in %.0f sec\n", - run_mode_string(mode), - run_mode_string(mode_perm), - delay - ); + printer.insert("current mode", run_mode_string(mode)); + printer.insert("perm mode", run_mode_string(mode_perm)); + printer.insert("perm becomes current in", format("%.0f sec", delay)); + + return printer; } -void CC_STATUS::print() { - printf("network connection status: %s\n", - network_status_string(network_status) - ); - print_status("CPU", +void CC_STATUS::print(const bool& console_print) const { + pretty_printer result; + result.insert("network connection status", network_status_string(network_status)); + + result.insert("CPU Status", print_status( task_suspend_reason, task_mode, task_mode_perm, task_mode_delay - ); - print_status("GPU", + )); + result.insert("GPU Status", print_status( gpu_suspend_reason, gpu_mode, gpu_mode_perm, gpu_mode_delay - ); - print_status("Network", + )); + result.insert("Network Status", print_status( network_suspend_reason, network_mode, network_mode_perm, network_mode_delay - ); + )); + + printf("%s\n", result.prettify(console_print).c_str()); } -void PROJECTS::print() { - unsigned int i; - printf("======== Projects ========\n"); - for (i=0; iprint(); - } +void PROJECTS::print(const bool& console_print) { + pretty_printer printer; + print_group("Projects", projects, console_print, printer); } -void PROJECTS::print_urls() { - unsigned int i; - for (i=0; imaster_url); +void PROJECTS::print_urls(const bool& console_print) { + pretty_printer printer; + for (const auto& project : projects) { + printer.insert(project->project_name, project->master_url); } + printf("%s\n", printer.prettify(console_print).c_str()); } -void DISK_USAGE::print() { - unsigned int i; - printf("======== Disk usage ========\n"); - printf("total: %.2fMB\n", d_total/MEGA); - printf("free: %.2fMB\n", d_free/MEGA); - for (i=0; iprint_disk_usage(); +void DISK_USAGE::print(const bool& console_print) { + if (console_print) { + printf("======== Disk usage ========\n"); + printf("total: %.2fMB\n", d_total / MEGA); + printf("free: %.2fMB\n", d_free / MEGA); + + for (unsigned int i = 0; i < projects.size(); i++) { + printf("%d) -----------\n", i + 1); + printf("%s\n", projects.at(i)->get_disk_usage().prettify(true).c_str()); + } + + } else { + pretty_printer printer; + + map disk_usage; + disk_usage["total"] = format("%.2fMB", d_total / MEGA); + disk_usage["free"] = format("%.2fMB", d_free / MEGA); + printer.insert("Disk usage", disk_usage); + + vector printers; + for (const auto& project : projects) { + printers.push_back(project->get_disk_usage()); + } + printer.insert("Projects", printers); + + printf("%s\n", printer.prettify(console_print).c_str()); } } -void RESULTS::print() { - unsigned int i; - printf("\n======== Tasks ========\n"); - for (i=0; iprint(); - } +void RESULTS::print(const bool& console_print) { + pretty_printer printer; + print_group("Tasks", results, console_print, printer); } -void FILE_TRANSFERS::print() { - unsigned int i; - printf("\n======== File transfers ========\n"); - for (i=0; iprint(); - } +void FILE_TRANSFERS::print(const bool& console_print) { + pretty_printer printer; + print_group("File transfers", file_transfers, console_print, printer); } -void MESSAGES::print() { - unsigned int i; - printf("\n======== Messages ========\n"); - for (i=0; iprint(); +void MESSAGES::print(const bool& console_print) const { + vector message_vector; + for (const auto& message : messages) { + message_vector.push_back(message); } + + pretty_printer printer; + print_group("Messages", message_vector, console_print, printer); } -void PROJECT_CONFIG::print() { - printf( - "uses_username: %d\n" - "name: %s\n" - "min_passwd_length: %d\n", - uses_username, - name.c_str(), - min_passwd_length - ); +void PROJECT_CONFIG::print(const bool& console_print) const { + pretty_printer printer; + printer.insert("use_username", uses_username); + printer.insert("name", name.c_str()); + printer.insert("min_passwd_length", min_passwd_length); + + printf("%s\n", printer.prettify(console_print).c_str()); } -void ACCOUNT_OUT::print() { +void ACCOUNT_OUT::print(const bool& console_print) const { + pretty_printer printer; if (error_num) { - printf("error in account lookup: %s\n", boincerror(error_num)); + printer.insert("error in account lookup", boincerror(error_num)); } else { - printf("account key: %s\n", authenticator.c_str()); + printer.insert("account key", authenticator.c_str()); } + + printf("%s\n", printer.prettify(console_print).c_str()); } -void OLD_RESULT::print() { - printf( - "task %s:\n" - " project URL: %s\n" - " app name: %s\n" - " exit status: %d\n" - " elapsed time: %f sec\n" - " completed time: %s\n" - " reported time: %s\n", - result_name, - project_url, - app_name, - exit_status, - elapsed_time, - time_to_string(completed_time), - time_to_string(create_time) - ); +pair OLD_RESULT::get() { + pretty_printer printer; + printer.insert("project_url", project_url); + printer.insert("app name", app_name); + printer.insert("exit status", exit_status); + printer.insert("elapsed time", elapsed_time); + printer.insert("completed time", time_to_string(completed_time)); + printer.insert("reported time", time_to_string(create_time)); + + return pair(result_name, printer); } -void ACCT_MGR_INFO::print() { - printf( - "Account manager info:\n" - " Name: %s\n" - " URL: %s\n", - acct_mgr_name.c_str(), - acct_mgr_url.c_str() - ); +void ACCT_MGR_INFO::print(const bool& console_print) const { + map info; + info["Name"] = acct_mgr_name; + info["URL"] = acct_mgr_url; + + pretty_printer printer; + printer.insert("Account manager info", info); + printf("%s\n", printer.prettify(console_print).c_str()); } diff --git a/lib/hostinfo.h b/lib/hostinfo.h index a41aed47841..82355c0ae9e 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -110,7 +110,7 @@ class HOST_INFO { int write(MIOFILE&, bool include_net_info, bool include_coprocs); int parse_cpu_benchmarks(FILE*); int write_cpu_benchmarks(FILE*); - void print(); + void print(const bool& console_print); bool host_is_running_on_batteries(); long user_idle_time(bool check_all_logins); diff --git a/lib/pretty_printer.cpp b/lib/pretty_printer.cpp new file mode 100644 index 00000000000..0c6a0414de6 --- /dev/null +++ b/lib/pretty_printer.cpp @@ -0,0 +1,320 @@ +#include +#include +#include + +#include "pretty_printer.h" + +using std::string; + +pretty_printer::pretty_printer(const int& decimal_spots, const int& spacing) : decimal_(decimal_spots), cur_spacing_(spacing), spacing_(spacing) {} + +string pretty_printer::prettify(const bool& console_print) { + std::ostringstream result; + + if (console_print) { + this->cur_spacing_ -= spacing_; + result << string(this->cur_spacing_, ' '); + } else { + result << "{\n" << string(this->cur_spacing_, ' '); + } + + auto in_string = false; + auto cur_count = 0; + + for (string::size_type i = 0; i < this->json_string_.size(); i++) { + const auto cursor = this->json_string_.at(i); + + switch (cursor) { + case '\\': + result << cursor << this->json_string_.at(++i); + break; + + case '#': + cur_count++; + + if (cur_count == 3) { + // Custom trigger to detect maps and vectors that were saved as strings + cur_count = 0; + + auto current = result.str(); + + result.clear(); + result.str(""); + + if (in_string) { + // Remove ### and " + in_string ? in_string = false : in_string = true; + result << current.substr(0, current.size() - 3); + + } else { + // Remove ###, skip ", and trigger in_string + result << current.substr(0, current.size() - 2); + i++; + } + + break; + } + + result << cursor; + break; + + case '"': + in_string ? in_string = false : in_string = true; + + if (!console_print) { + result << cursor; + } + + break; + + case ':': + result << cursor; + + if (!in_string) { + result << " "; + } + + break; + + case '[': + if (!in_string) { + this->cur_spacing_ += this->spacing_; + + if (console_print) { + result << "\n" << string(this->cur_spacing_, ' '); + } else { + result << "[\n" << string(this->cur_spacing_, ' '); + } + + break; + } + + result << cursor; + break; + + case ']': + if (!in_string) { + this->cur_spacing_ -= this->spacing_; + if (!console_print) { + result << "\n" << string(this->cur_spacing_, ' ') << "]"; + } + + break; + } + + result << cursor; + break; + + case ',': + if (!in_string) { + if (console_print) { + result << "\n" << string(this->cur_spacing_, ' '); + } else { + result << ",\n" << string(this->cur_spacing_, ' '); + } + + break; + } + + result << cursor; + break; + + case '{': + if (!in_string) { + this->cur_spacing_ += this->spacing_; + if (console_print) { + result << "\n" << string(this->cur_spacing_, ' '); + } else { + result << "{\n" << string(this->cur_spacing_, ' '); + } + + break; + } + + result << cursor; + break; + + case '}': + if (!in_string) { + this->cur_spacing_ -= this->spacing_; + if (!console_print) { + result << "\n" << string(this->cur_spacing_, ' ') << "}"; + } + + break; + } + + result << cursor; + break; + + default: + result << cursor; + } + } + + auto result_string = result.str(); + + // Finalize and restore to start state + if (console_print) { + this->cur_spacing_ += spacing_; + } else { + result_string += "\n}"; + } + + return result_string; +} + +int pretty_printer::insert(const pretty_printer& printer) { + if (this->json_string_.empty()) { + this->json_string_ = printer.raw(); + } else { + this->json_string_ += "," + printer.raw(); + } + + return 0; +} + +int pretty_printer::insert(const string& key, const string& value) { + const auto size = snprintf(nullptr, 0, R"("%s":"%s")", key.c_str(), value.c_str()) + 1; + auto buf = vector(size); + + sprintf(buf.data(), R"("%s":"%s")", key.c_str(), value.c_str()); + + if (!this->json_string_.empty()) { + this->json_string_ += ","; + } + + this->json_string_ += buf.data(); + + return 0; +} + +int pretty_printer::insert(const string& key, const char value) { + const auto size = snprintf(nullptr, 0, R"("%s":"%c")", key.c_str(), value) + 1; + auto buf = vector(size); + + sprintf(buf.data(), R"("%s":"%c")", key.c_str(), value); + + if (!this->json_string_.empty()) { + this->json_string_ += ","; + } + + this->json_string_ += buf.data(); + + return 0; +} + +int pretty_printer::insert(const string& key, const double& value) { + const auto size = snprintf(nullptr, 0, "\"%s\":%.*f", key.c_str(), this->decimal_, value) + 1; + auto buf = vector(size); + + sprintf(buf.data(), "\"%s\":%.*f", key.c_str(), this->decimal_, value); + + if (!this->json_string_.empty()) { + this->json_string_ += ","; + } + + this->json_string_ += buf.data(); + + return 0; +} + +int pretty_printer::insert(const string& key, const unsigned long long& value) { + const auto size = snprintf(nullptr, 0, "\"%s\":%s", key.c_str(), std::to_string(value).c_str()) + 1; + auto buf = vector(size); + + sprintf(buf.data(), "\"%s\":%s", key.c_str(), std::to_string(value).c_str()); + + if (!this->json_string_.empty()) { + this->json_string_ += ","; + } + + this->json_string_ += buf.data(); + + return 0; +} + +int pretty_printer::insert(const string& key, const long long& value) { + const auto size = snprintf(nullptr, 0, "\"%s\":%s", key.c_str(), std::to_string(value).c_str()) + 1; + auto buf = vector(size); + + sprintf(buf.data(), "\"%s\":%s", key.c_str(), std::to_string(value).c_str()); + + if (!this->json_string_.empty()) { + this->json_string_ += ","; + } + + this->json_string_ += buf.data(); + + return 0; +} + +int pretty_printer::insert(const string& key, const long& value) { + const auto size = snprintf(nullptr, 0, "\"%s\":%s", key.c_str(), std::to_string(value).c_str()) + 1; + auto buf = vector(size); + + sprintf(buf.data(), "\"%s\":%s", key.c_str(), std::to_string(value).c_str()); + + if (!this->json_string_.empty()) { + this->json_string_ += ","; + } + + this->json_string_ += buf.data(); + + return 0; +} + +int pretty_printer::insert(const string& key, const int& value) { + const auto size = snprintf(nullptr, 0, "\"%s\":%s", key.c_str(), std::to_string(value).c_str()) + 1; + auto buf = vector(size); + + sprintf(buf.data(), "\"%s\":%s", key.c_str(), std::to_string(value).c_str()); + + if (!this->json_string_.empty()) { + this->json_string_ += ","; + } + + this->json_string_ += buf.data(); + + return 0; +} + +int pretty_printer::insert(const string& key, const bool& value) { + const auto size = snprintf(nullptr, 0, "\"%s\":false", key.c_str()) + 1; + auto buf = vector(size); + + if (value) { + sprintf(buf.data(), "\"%s\":true", key.c_str()); + } else { + sprintf(buf.data(), "\"%s\":false", key.c_str()); + } + + if (!this->json_string_.empty()) { + this->json_string_ += ","; + } + + this->json_string_ += buf.data(); + return 0; +} + +int pretty_printer::insert(const string& key) { + const auto size = snprintf(nullptr, 0, "\"%s\":null", key.c_str()) + 1; + auto buf = vector(size); + + sprintf(buf.data(), "\"%s\":null", key.c_str()); + + if (!this->json_string_.empty()) { + this->json_string_ += ","; + } + + this->json_string_ += buf.data(); + + return 0; +} + +int pretty_printer::clear() { + this->json_string_ = ""; + this->cur_spacing_ = this->spacing_; + + return 0; +} \ No newline at end of file diff --git a/lib/pretty_printer.h b/lib/pretty_printer.h new file mode 100644 index 00000000000..d9b45c00e38 --- /dev/null +++ b/lib/pretty_printer.h @@ -0,0 +1,153 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +using std::string; +using std::vector; + +class pretty_printer { + string json_string_ = ""; + int decimal_; + + int cur_spacing_; + const int spacing_; + +public: + explicit pretty_printer(const int& decimal_spots = 2, const int& spacing = 3); + ~pretty_printer() = default; + pretty_printer(const pretty_printer& printer) = default; + + template + explicit pretty_printer(std::map& map, const int& decimal_spots = 2, const int& spacing = 3) : decimal_(decimal_spots), cur_spacing_(spacing), spacing_(spacing) { + const string prettified = inner_prettify(map); + this->json_string_ = prettified.substr(4, prettified.size() - 8); + } + + string prettify(const bool& console_print = false); + string raw() const { return this->json_string_; } + + int insert(const pretty_printer& printer); + + int insert(const string& key, const string& value); + + int insert(const string& key, const char* value) { return this->insert(key, string(value)); } + + int insert(const string& key, const char value); + + int insert(const string& key, const pretty_printer& printer) { return this->insert(key, string("###{" + printer.raw() + "}###")); } + + int insert(const string& key, const double& value); + + int insert(const string& key, const unsigned long long& value); + + int insert(const string& key, const long long& value); + + int insert(const string& key, const long& value); + + int insert(const string& key, const int& value); + + int insert(const string& key, const bool& value); + + int insert(const string& key); + + int clear(); + + int change_spacing(const int& factor = 1) noexcept { + this->cur_spacing_ += this->spacing_ * factor; + + if (this->cur_spacing_ < 0) { + this->cur_spacing_ = 0; + return 1; + } + + return 0; + } + + int change_decimal(const int& decimal) noexcept { + this->decimal_ = decimal; + return 0; + } + +private: + template + static string inner_prettify(vector inputs) { + std::ostringstream result; + result << "###["; + + for (auto input : inputs) { + result << inner_prettify(input) << ","; + } + + const auto result_string = result.str(); + + if (result_string.size() < 2) { + return ""; + } + + return result_string.substr(0, result_string.size() - 1) + "]###"; + } + + template + static string inner_prettify(std::map map) { + auto result = std::make_unique(); + + for (auto& element : map) { + result->insert(inner_prettify(element.first), inner_prettify(element.second)); + } + + std::ostringstream final; + final << "###{" << result->json_string_ << "}###"; + + return final.str(); + } + + template + static T inner_prettify(std::unique_ptr& value) { + return value.get(); + } + + template + static T inner_prettify(const T& value) noexcept { + return value; + } + + static string inner_prettify(const pretty_printer& printer) { + return "{" + printer.raw() + "}"; + } + +public: + template + static string prettify(vector inputs) { + return inner_prettify(inputs); + } + + template + int insert(const string& key, const std::map& map) { + this->insert(key, inner_prettify(map)); + + return 0; + } + + template + int insert(const string& key, const vector& vec) { + this->insert(key, inner_prettify(vec)); + + return 0; + } + + + template + static string prettify(std::map& map) { + return pretty_printer(map).raw(); + } + + template + static T prettify(const T& value) noexcept { + return value; + } +}; diff --git a/lib/pretty_printer_tests.cpp b/lib/pretty_printer_tests.cpp new file mode 100644 index 00000000000..f7356d0f669 --- /dev/null +++ b/lib/pretty_printer_tests.cpp @@ -0,0 +1,333 @@ +#include +#include "../lib/pretty_printer.h" +#include +#include + +using std::string; +using std::map; +using std::pair; +using std::vector; + +map> results; +vector order; + +pretty_printer A; +int passed; +int total; + +int all_passed = 0; +int all_total = 0; + +void test(const string& name, const string& expected, const bool& console = false, const bool& clear = true, pretty_printer& printer = A) { + total++; + all_total++; + + if (expected == printer.prettify(console)) { + passed++; + all_passed++; + + printf("%s test passed\n", name.c_str()); + } else { + printf("%s test failed\n", name.c_str()); + printf("Expected:\n%s\n\nActual:\n%s\n\n", expected.c_str(), printer.prettify(console).c_str()); + } + + if (clear) { + printer.clear(); + } +} + +void finalize(string name) { + results.insert(pair>(name, pair(passed, total))); + order.push_back(name); + + passed = total = 0; +} + +int run_tests() { + string expected; + + printf("\nNUMBERS\n"); + passed = total = 0; + + A.insert("Key", 0); + test("Zero", "{\n \"Key\": 0\n}"); + + A.insert("Key", 1); + test("Positive", "{\n \"Key\": 1\n}"); + + A.insert("Key", 14155324355633456215); + test("Huge Positive", "{\n \"Key\": 14155324355633456215\n}"); + + A.insert("Key", 1234123423135321421); + test("Large Positive", "{\n \"Key\": 1234123423135321421\n}"); + + A.insert("Key", -1234123423135321421); + test("Large Negative", "{\n \"Key\": -1234123423135321421\n}"); + + A.insert("Key", 0.012321412); + test("Positive Decimal", "{\n \"Key\": 0.01\n}"); + + A.insert("Key", -0.012321412); + test("Negative Decimal", "{\n \"Key\": -0.01\n}"); + + A.insert("Key", 0.013242352532352343242321412); + test("Large Positive Decimal", "{\n \"Key\": 0.01\n}"); + + A.insert("Key", -0.013242352532352343242321412); + test("Large Negative Decimal", "{\n \"Key\": -0.01\n}"); + + finalize("Numbers"); + + printf("\nSTRINGS\n"); + + A.insert("Key", "abc"); + test("Basic String", "{\n \"Key\": \"abc\"\n}"); + + A.insert("Key", "AbvsaAYghsa"); + test("String Case", "{\n \"Key\": \"AbvsaAYghsa\"\n}"); + + A.insert("Key", 'a'); + test("Char", "{\n \"Key\": \"a\"\n}"); + + A.insert("Key", 'A'); + test("Char Capital", "{\n \"Key\": \"A\"\n}"); + + A.insert("Key", "'A'"); + test("Single Quotes", "{\n \"Key\": \"'A'\"\n}"); + + A.insert("Key", "abc\\\"bc A\\\""); + test("Double Quotes", "{\n \"Key\": \"abc\\\"bc A\\\"\"\n}"); + + A.insert("Key", "abc\\\"bc A\\\""); + test("Double Quotes Extra", "{\n \"Key\": \"abc\\\"bc A\\\"\"\n}"); + + A.insert("Key", "dsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfh"); + test("Very Long String", "{\n \"Key\": \"dsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfh\"\n}"); + + A.insert("Key", "?.,,./<>!@#$%^&*()_+-="); + test("Special Characters", "{\n \"Key\": \"?.,,./<>!@#$%^&*()_+-=\"\n}"); + + finalize("Strings"); + + + printf("\nARRAYS\n"); + + A.insert("Key", pretty_printer::prettify(vector{1, 2, 3})); + test("Int array", "{\n \"Key\": [\n 1,\n 2,\n 3\n ]\n}"); + + A.insert("Key", pretty_printer::prettify(vector{1, 2, 3})); + A.insert("Key_2", pretty_printer::prettify(vector{4, 5, 6})); + test("Extra Int array", "{\n \"Key\": [\n 1,\n 2,\n 3\n ],\n \"Key_2\": [\n 4,\n 5,\n 6\n ]\n}"); + + finalize("Arrays"); + + + printf("\nMISC\n"); + passed = total = 0; + + A.insert("Key", false); + test("False", "{\n \"Key\": false\n}"); + + A.insert("Key", true); + test("True", "{\n \"Key\": true\n}"); + + A.insert("Key"); + test("Null", "{\n \"Key\": null\n}"); + + finalize("Misc"); + + printf("\nRECURSIVE\n"); + + if (true) { + map map_test; + map_test["abc"] = 2; + + A.insert("Key", map_test); + test("Basic Map", "{\n \"Key\": {\n \"abc\": 2\n }\n}"); + } + + if (true) { + map>>> map_test; + map i; + i["first"] = 1; + map> j; + j["second"] = i; + map>> k; + k["third"] = j; + + map_test["out"] = k; + + test("Recursive Maps", "{\n \"out\": {\n \"third\": {\n \"second\": {\n \"first\": 1\n }\n }\n }\n}", false, true, pretty_printer(map_test)); + } + + if (true) { + map>>> map_test; + map i; + i["first"] = 1; + map l; + l["other"] = 2; + map> j; + j["second"] = i; + j["other_second"] = l; + map>> k; + k["third"] = j; + + map_test["out"] = k; + + test("Recursive Maps Extra", "{\n \"out\": {\n \"third\": {\n \"other_second\": {\n \"other\": 2\n },\n \"second\": {\n \"first\": 1\n }\n }\n }\n}", false, true, pretty_printer(map_test)); + } + + finalize("Recursive"); + + printf("\nConsole\n"); + + printf("\nNUMBERS\n"); + + A.insert("Key", 0); + test("Zero", "Key: 0", true); + + A.insert("Key", 1); + test("Positive", "Key: 1", true); + + A.insert("Key", 14155324355633456215); + test("Huge Positive", "Key: 14155324355633456215", true); + + A.insert("Key", 1234123423135321421); + test("Large Positive", "Key: 1234123423135321421", true); + + A.insert("Key", -1234123423135321421); + test("Large Negative", "Key: -1234123423135321421", true); + + A.insert("Key", 0.012321412); + test("Positive Decimal", "Key: 0.01", true); + + A.insert("Key", -0.012321412); + test("Negative Decimal", "Key: -0.01", true); + + A.insert("Key", 0.013242352532352343242321412); + test("Large Positive Decimal", "Key: 0.01", true); + + A.insert("Key", -0.013242352532352343242321412); + test("Large Negative Decimal", "Key: -0.01", true); + + finalize("Console Numbers"); + + printf("\nSTRINGS\n"); + + A.insert("Key", "abc"); + test("Basic String", "Key: abc", true); + + A.insert("Key", "AbvsaAYghsa"); + test("String Case", "Key: AbvsaAYghsa", true); + + A.insert("Key", 'a'); + test("Char", "Key: a", true); + + A.insert("Key", 'A'); + test("Char Capital", "Key: A", true); + + A.insert("Key", "'A'"); + test("Single Quotes", "Key: 'A'", true); + + A.insert("Key", "abc\\\"bc A\\\""); + test("Double Quotes Extra", "Key: abc\\\"bc A\\\"", true); + + A.insert("Key", "dsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfh"); + test("Very Long String", "Key: dsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfhdsffuighuyighsdzuifhuilhsteiryjuhhjklghuiosfhuisezhiulhgdiugtdhslkjhjhuxdghfkjdhdjkxlfh", true); + + A.insert("Key", "?.,,./<>!@#$%^&*()_+-="); + test("Special Characters", "Key: ?.,,./<>!@#$%^&*()_+-=", true); + + finalize("Console Strings"); + + + printf("\nARRAYS\n"); + + A.insert("Key", pretty_printer::prettify(vector{1, 2, 3})); + test("Int array", "Key:\n 1\n 2\n 3", true); + + A.insert("Key", pretty_printer::prettify(vector{1, 2, 3})); + A.insert("Key_2", pretty_printer::prettify(vector{4, 5, 6})); + test("Extra Int array", "Key:\n 1\n 2\n 3\nKey_2:\n 4\n 5\n 6", true); + + finalize("Console Arrays"); + + + printf("\nMISC\n"); + + A.insert("Key", false); + test("False", "Key: false", true); + + A.insert("Key", true); + test("True", "Key: true", true); + + A.insert("Key"); + test("Null", "Key: null", true); + + finalize("Console Misc"); + + + + printf("\nRECURSIVE\n"); + + if (true) { + map map_test; + map_test["abc"] = 2; + + A.insert("Key", map_test); + test("Basic Map", "Key:\n abc: 2", true); + } + + if (true) { + map>>> map_test; + map i; + i["first"] = 1; + map> j; + j["second"] = i; + map>> k; + k["third"] = j; + + map_test["out"] = k; + + test("Recursive Maps", "out:\n third:\n second:\n first: 1", true, true, pretty_printer(map_test)); + } + + if (true) { + map>>> map_test; + map i; + i["first"] = 1; + map l; + l["other"] = 2; + map> j; + j["second"] = i; + j["other_second"] = l; + map>> k; + k["third"] = j; + + map_test["out"] = k; + + test("Recursive Maps Extra", "out:\n third:\n other_second:\n other: 2\n second:\n first: 1", true, true, pretty_printer(map_test)); + } + + + finalize("Console Recursive"); + + // Display results + printf("\n"); + for (auto& suite : order) { + auto& result = results[suite]; + printf("%s - Passed: %d/%d\n", suite.c_str(), result.first, result.second); + } + + const double success = static_cast(all_passed) / all_total * 100; + printf("\nTests Passed: %d/%d - %.2f%%", all_passed, all_total, success); + + if (all_passed != all_total) { + printf(" (%d Failed)", all_total - all_passed); + } + + printf("\n"); + + return 0; +} diff --git a/win_build/libboinc_vs2013.vcxproj b/win_build/libboinc_vs2013.vcxproj index 8c89f4b6701..d65df6a6745 100644 --- a/win_build/libboinc_vs2013.vcxproj +++ b/win_build/libboinc_vs2013.vcxproj @@ -230,6 +230,7 @@ + @@ -296,6 +297,8 @@ CompileAsCpp CompileAsCpp + + diff --git a/win_build/libboinc_vs2019.vcxproj b/win_build/libboinc_vs2019.vcxproj index 12169c55006..e44793cee9e 100644 --- a/win_build/libboinc_vs2019.vcxproj +++ b/win_build/libboinc_vs2019.vcxproj @@ -135,6 +135,7 @@ + @@ -192,6 +193,8 @@ CompileAsCpp + +