From 0697ee441f33730a58684ede8d5079a20393fd62 Mon Sep 17 00:00:00 2001 From: Adrien Bertrand Date: Mon, 15 Jul 2024 23:12:16 +0200 Subject: [PATCH] test ci --- cli/cli.cpp | 6 ++---- tests.cpp | 25 +++++++++++-------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/cli/cli.cpp b/cli/cli.cpp index 04fdd3a..a578de6 100644 --- a/cli/cli.cpp +++ b/cli/cli.cpp @@ -14,8 +14,6 @@ using namespace std; using namespace tivars; using namespace tivars::TypeHandlers; -using tivars::TypeHandlers::TH_Tokenized::lang::LANG_FR; -using tivars::TypeHandlers::TH_Tokenized::lang::LANG_EN; enum FileType { @@ -214,10 +212,10 @@ int main(int argc, char** argv) string langStr = result["lang"].as(); if (langStr == "en") { - contentOptions["lang"] = LANG_EN; + contentOptions["lang"] = TH_Tokenized::LANG_EN; } else if (langStr == "fr") { - contentOptions["lang"] = LANG_FR; + contentOptions["lang"] = TH_Tokenized::LANG_FR; } else { cout << langStr << " is not a valid language code" << endl; diff --git a/tests.cpp b/tests.cpp index e481618..b7b32f3 100644 --- a/tests.cpp +++ b/tests.cpp @@ -1,6 +1,6 @@ /* * Part of tivars_lib_cpp - * (C) 2015-2021 Adrien "Adriweb" Bertrand + * (C) 2015-2024 Adrien "Adriweb" Bertrand * https://github.com/adriweb/tivars_lib_cpp * License: MIT */ @@ -42,9 +42,6 @@ int main(int argc, char** argv) TIVarTypes::initTIVarTypesArray(); TH_Tokenized::initTokens(); - using tivars::TypeHandlers::TH_Tokenized::lang::LANG_FR; - using tivars::TypeHandlers::TH_Tokenized::lang::LANG_EN; - /* Tests */ assert(TIVarType{"ExactRealPi"}.getId() == 32); @@ -189,8 +186,8 @@ int main(int argc, char** argv) // Test lower alpha being the expected lowercase tokens, not special-meaning ones TIVarFile testPrgm = TIVarFile::createNew("Program", "INTERP"); testPrgm.setContentFromString("Disp \"abcdefghijklmnopqrstuvwxyz\""); - string detok_fr = testPrgm.getReadableContent({{"lang", LANG_FR}}); - string detok_en = testPrgm.getReadableContent({{"lang", LANG_EN}}); + string detok_fr = testPrgm.getReadableContent({{"lang", TH_Tokenized::LANG_FR}}); + string detok_en = testPrgm.getReadableContent({{"lang", TH_Tokenized::LANG_EN}}); string hex = testPrgm.getRawContentHexStr(); assert(detok_fr == "Disp \"abcdefghijklmnopqrstuvwxyz\""); assert(detok_en == "Disp \"abcdefghijklmnopqrstuvwxyz\""); @@ -201,8 +198,8 @@ int main(int argc, char** argv) // Test string interpolation behaviour TIVarFile testPrgm = TIVarFile::createNew("Program", "INTERP"); testPrgm.setContentFromString(R"(A and B:Disp "A and B":Send("SET SOUND eval(A and B) TIME 2)"); - string detok_fr = testPrgm.getReadableContent({{"lang", LANG_FR}}); - string detok_en = testPrgm.getReadableContent({{"lang", LANG_EN}}); + string detok_fr = testPrgm.getReadableContent({{"lang", TH_Tokenized::LANG_FR}}); + string detok_en = testPrgm.getReadableContent({{"lang", TH_Tokenized::LANG_EN}}); assert(detok_en == R"(A and B:Disp "A and B":Send("SET SOUND eval(A and B) TIME 2)"); assert(detok_fr == R"(A et B:Disp "A and B":Envoi("SET SOUND eval(A et B) TIME 2)"); } @@ -211,8 +208,8 @@ int main(int argc, char** argv) // Test tokenization exceptions TIVarFile testPrgm = TIVarFile::createNew("Program", "FOOBAR"); testPrgm.setContentFromString(R"(Disp "WHITE,ʟWHITE,prgmWHITE",WHITE,ʟWHITE:prgmWHITE:prgmABCDEF)"); - string detok_fr = testPrgm.getReadableContent({{"lang", LANG_FR}}); - string detok_en = testPrgm.getReadableContent({{"lang", LANG_EN}}); + string detok_fr = testPrgm.getReadableContent({{"lang", TH_Tokenized::LANG_FR}}); + string detok_en = testPrgm.getReadableContent({{"lang", TH_Tokenized::LANG_EN}}); assert(detok_en == R"(Disp "WHITE,ʟWHITE,prgmWHITE",WHITE,ʟWHITE:prgmWHITE:prgmABCDEF)"); assert(detok_fr == R"(Disp "WHITE,ʟWHITE,prgmWHITE",BLANC,ʟWHITE:prgmWHITE:prgmABCDEF)"); // While this is visually fine, the "prgm" inside the token should probably be the token, not p r g m ... @@ -222,8 +219,8 @@ int main(int argc, char** argv) // Test tokenization exceptions in an interpolated string TIVarFile testPrgm = TIVarFile::createNew("Program", "FOOBAR"); testPrgm.setContentFromString(R"(Send("SET SOUND eval(A and prgmWHITE) TIME 2)"); - string detok_fr = testPrgm.getReadableContent({{"lang", LANG_FR}}); - string detok_en = testPrgm.getReadableContent({{"lang", LANG_EN}}); + string detok_fr = testPrgm.getReadableContent({{"lang", TH_Tokenized::LANG_FR}}); + string detok_en = testPrgm.getReadableContent({{"lang", TH_Tokenized::LANG_EN}}); assert(detok_en == R"(Send("SET SOUND eval(A and prgmWHITE) TIME 2)"); assert(detok_fr == R"(Envoi("SET SOUND eval(A et prgmWHITE) TIME 2)"); } @@ -417,11 +414,11 @@ End)"; cout << "testPrgm.getHeader().entries_len = " << testPrgm.getHeader().entries_len << "\t testPrgm.size() - 57 == " << (testPrgm.size() - 57) << endl; assert(testPrgm.getHeader().entries_len == testPrgm.size() - 57); - string testPrgmcontent = testPrgm.getReadableContent({{"lang", LANG_FR}}); + string testPrgmcontent = testPrgm.getReadableContent({{"lang", TH_Tokenized::LANG_FR}}); TIVarFile newPrgm = TIVarFile::createNew("Program"); newPrgm.setContentFromString(testPrgmcontent); - string newPrgmcontent = newPrgm.getReadableContent({{"lang", LANG_FR}}); + string newPrgmcontent = newPrgm.getReadableContent({{"lang", TH_Tokenized::LANG_FR}}); assert(testPrgmcontent == newPrgmcontent); newPrgm.saveVarToFile("testData", "Program_new");