Skip to content

Commit

Permalink
test ci
Browse files Browse the repository at this point in the history
  • Loading branch information
adriweb committed Jul 15, 2024
1 parent 90fe493 commit 0697ee4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
6 changes: 2 additions & 4 deletions cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -214,10 +212,10 @@ int main(int argc, char** argv)
string langStr = result["lang"].as<string>();
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;
Expand Down
25 changes: 11 additions & 14 deletions tests.cpp
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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\"");
Expand All @@ -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)");
}
Expand All @@ -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 ...
Expand All @@ -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)");
}
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 0697ee4

Please sign in to comment.