diff --git a/supplemental/cron/health_srcdiff.conf.in b/supplemental/cron/health_srcdiff.conf.in index c663c5e..663da63 100644 --- a/supplemental/cron/health_srcdiff.conf.in +++ b/supplemental/cron/health_srcdiff.conf.in @@ -1,73 +1,6 @@ nodiff_files_src => [ - "account.cpp", - "avataruploader.cpp", - "c_archive.cpp", - "c_cache_obj.cpp", - "c_config.cpp", - "c_date_spelling.cpp", - "c_float.cpp", - "c_price_spelling.cpp", - "c_smsc.cpp", - "cactivator.cpp", - "ccgi.cpp", - "ccookie.cpp", - "cexception.cpp", - "cfiles.cpp", - "chtml.cpp", - "cmail.cpp", - "cmysql.cpp", - "crequest.cpp", - "csession.cpp", - "cstatistics.cpp", - "ctemplate.cpp", - "cuser.cpp", - "cvars.cpp", - "cvideoconverter.cpp", - "generalimageuploader.cpp", - "helpdesk.cpp", - "imageuploader.cpp", - "noauth.cpp", - "utilities1.cpp", - "utilities2.cpp", - "utilities_common.cpp", - - "account.h", - "avataruploader.h", - "c_archive.h", - "c_cache_obj.h", - "c_config.h", - "c_date_spelling.h", - "c_float.h", - "c_price_spelling.h", - "c_smsc.h", - "cactivator.h", - "ccgi.h", - "ccookie.h", - "cexception.h", - "cfiles.h", - "clog.h", - "chtml.h", - "cmail.h", - "cmysql.h", - "crequest.h", - "csession.h", - "cstatistics.h", - "ctemplate.h", - "cuser.h", - "cvars.h", - "cvideoconverter.h", - "generalimageuploader.h", - "helpdesk.h", - "imageuploader.h", - "noauth.h", - "utilities_common.h", - "utilities.h", - "localy.h.in", - - "cron_minute_pi.cpp", - "cron_daily_pi.cpp", - "cron_minute_pi.h", - "cron_daily_pi.h", + "tests/auto/autotest_c_price_spelling.cpp", + "system.cpp", "git_commit.pl", @@ -96,16 +29,15 @@ nodiff_files_src => [ "supplemental/config/CMakeLists.txt", + + ".github/actions/linters/.eslintrc.yaml", + ".github/actions/release-drafter/release-drafter.yml", + ".github/actions/spelling/only.txt", ".github/workflows/qa.yml", - ".github/workflows/sast.yml", - ".github/workflows/release-deploymnet.yml", ".github/workflows/release-drafter.yml", + ".github/workflows/sast.yml", ".github/workflows/spell_check.yml", ".github/workflows/super_linter.yml", - ".github/actions/release-drafter/release-drafter.yaml", - ".github/actions/spell_check/only.txt", - ".github/actions/spell_check/excludes.txt", - ".github/actions/linters/.eslintrc.yaml", ], @@ -115,9 +47,9 @@ nodiff_files_html => [ "helpdesk.css", "login.css", "admin/common.css", - "ru/pages/common.css", + "html/css/pages/common.css", - "faq.js", + "pi/faq.js", "session.js", "login.js", "email_change.js", @@ -168,14 +100,6 @@ nodiff_files_html => [ "admin_header.htmlt", "admin_chat_get_cnx_list.htmlt", "admin_chat_get_presence_cache.htmlt", - - ".github/workflows/release-drafter.yml", - ".github/workflows/spell_check.yml", - ".github/workflows/super_linter.yml", - ".github/actions/release-drafter/release-drafter.yaml", - ".github/actions/spell_check/only.txt", - ".github/actions/spell_check/excludes.txt", - ".github/actions/linters/.eslintrc.yaml", ], exclude_domains => [ diff --git a/supplemental/cron/health_srcdiff.pl b/supplemental/cron/health_srcdiff.pl index 9757d53..0d8b899 100755 --- a/supplemental/cron/health_srcdiff.pl +++ b/supplemental/cron/health_srcdiff.pl @@ -171,7 +171,7 @@ sub DiffFile } else { - PrintError("found ".($#files + 1)." x ".$curr_file." in ".$root_dir.", must be ".($#domains + 1)) if($DEBUG); + PrintError("found ".($#files + 1)." x ".$curr_file." in ".$root_dir.", must be ".($#domains + 1)); } } @@ -213,7 +213,7 @@ sub __find_sub { # --- skip build folder } - elsif($F =~ m/\/pi\//) + elsif($F =~ m/\/src\/pi\//) { # --- skip pi folder } diff --git a/tests/auto/autotest_c_price_spelling.cpp b/tests/auto/autotest_c_price_spelling.cpp new file mode 100644 index 0000000..492407e --- /dev/null +++ b/tests/auto/autotest_c_price_spelling.cpp @@ -0,0 +1,413 @@ +#include +#include +#include "ccgi.h" +#include "cmysql.h" +#include "cuser.h" +#include "cstatistics.h" +#include "utilities.h" +#include "utilities_common.h" +#include "c_price_spelling.h" +#include "localy.h" + +using namespace std; + +bool Test1() +{ + auto result = true; + auto error_message = ""s; + auto amount = -808; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + if(spelling == "минус восемьсот восемь рублей") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test2() +{ + auto result = true; + auto error_message = ""s; + auto amount = -276498.67; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + if(spelling == "минус двести семьдесят шесть тысяч четыреста девяносто восемь рублей шестьдесят семь копеек") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test3() +{ + auto result = true; + auto error_message = ""s; + auto amount = 324; + C_Price_Spelling price; + auto spelling = price.SpellRubles(amount); // --- spell just one word + + if(spelling == "рубля") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test4() +{ + auto result = true; + auto error_message = ""s; + auto amount = -0; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + if(spelling == "") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test5() +{ + auto result = true; + auto error_message = ""s; + auto amount = 1000000000000000 - 1; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + if(spelling == "девятьсот девяносто девять трилионов девятьсот девяносто девять миллиардов девятьсот девяносто девять миллионов девятьсот девяносто девять тысяч девятьсот девяносто девять рублей") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test6() +{ + auto result = true; + auto error_message = ""s; + auto amount = 67; + C_Price_Spelling price; + auto spelling = price.SpellCents(amount); // --- spell just one word + + if(spelling == "копеек") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test7() +{ + auto result = true; + auto error_message = ""s; + auto amount = 00019.00; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + if(spelling == "девятнадцать рублей") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test8() +{ + auto result = true; + auto error_message = ""s; + auto amount = 3.1; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + if(spelling == "три рубля десять копеек") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test9() +{ + auto result = true; + auto error_message = ""s; + double amount = 26.00; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + if(spelling == "двадцать шесть рублей") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test10() +{ + auto result = true; + auto error_message = ""s; + double amount = 26.01; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + if(spelling == "двадцать шесть рублей одна копейка") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test11() +{ + auto result = true; + auto error_message = ""s; + auto amount = 93.01; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + MESSAGE_DEBUG("", "", "price spellling: " + spelling); + + if(spelling == "девяносто три рубля одна копейка") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test12() +{ + auto result = true; + auto error_message = ""s; + auto amount = 74.02; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + MESSAGE_DEBUG("", "", "price spellling: " + spelling); + + if(spelling == "семьдесят четыре рубля две копейки") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test13() +{ + auto result = true; + auto error_message = ""s; + auto amount = 564.02; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + MESSAGE_DEBUG("", "", "price spellling: " + spelling); + + if(spelling == "пятьсот шестьдесят четыре рубля две копейки") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test14() +{ + auto result = true; + auto error_message = ""s; + auto amount = 276.02; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + MESSAGE_DEBUG("", "", "price spellling: " + spelling); + + if(spelling == "двести семьдесят шесть рублей две копейки") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test15() +{ + auto result = true; + auto error_message = ""s; + auto amount = 492.03; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + MESSAGE_DEBUG("", "", "price spellling: " + spelling); + + if(spelling == "четыреста девяносто два рубля три копейки") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +bool Test16() +{ + auto result = true; + auto error_message = ""s; + auto amount = 0963.04; + C_Price_Spelling price(amount); + auto spelling = price.Spelling(); + + MESSAGE_DEBUG("", "", "price spellling: " + spelling); + + if(spelling == "девятьсот шестьдесят три рубля четыре копейки") + { + + } + else + { + result = false; + cout << "failed on " << amount << endl; + } + + return result; +} + +vector func_v = { + Test1, + Test2, + Test3, + Test4, + Test5, + Test6, + Test7, + Test8, + Test9, + Test10, + Test11, + Test12, + Test13, + Test14, + Test15, + Test16, +}; + +bool RunTests() +{ + auto result = true; + + for(auto f: func_v) + { + result &= f(); + } + + return result; +} + +int main(void) +{ + CStatistics appStat; // --- CStatistics must be firts statement to measure end2end param's + CCgi indexPage(EXTERNAL_TEMPLATE); + CUser user; + CMysql db; + + { MESSAGE_DEBUG("", "", __FILE__); } + signal(SIGSEGV, crash_handler); + + auto testing_success = RunTests(); + + if(testing_success) + cout << "Test passed" << endl; + else + cout << "Test failed" << endl; + + + return(0); +} +