SimpCfg: Test c++ string handling

This commit is contained in:
HanishKVC 2024-05-02 06:11:40 +05:30
parent 86e776c857
commit 56f19c7a68

View file

@ -16,6 +16,8 @@
#include <regex> #include <regex>
#include <variant> #include <variant>
#include <sstream> #include <sstream>
#include <format>
#include <cuchar>
#define SC_DEBUG #define SC_DEBUG
@ -301,11 +303,35 @@ public:
#ifdef SC_TEST_PRG #ifdef SC_TEST_PRG
#include <iostream>
void check_strings() {
std::string sT11 = "123";
std::string sT12 = "1अ3";
std::cout << std::format("string: [{}] len[{}] size[{}]", sT11, sT11.length(), sT11.size()) << std::endl;
std::cout << std::format("string: [{}] len[{}] size[{}]", sT12, sT12.length(), sT12.size()) << std::endl;
std::u8string sT21 = u8"123";
std::u8string sT22 = u8"1अ3";
std::wstring sT31 = L"1अ3";
std::wstring sT32 (sT22.begin(), sT22.end());
std::string sT21x (sT21.begin(), sT21.end());
std::string sT22x (sT22.begin(), sT22.end());
std::cout << std::format("u8string: [{}] len[{}] size[{}]", sT21x, sT21.length(), sT21.size()) << std::endl;
std::cout << std::format("u8string: [{}] len[{}] size[{}]", sT22x, sT22.length(), sT22.size()) << std::endl;
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
if (argc != 2) { if (argc != 2) {
LERRR_LN("USAGE:%s simp.cfg", argv[0]); LERRR_LN("USAGE:%s simp.cfg", argv[0]);
exit(1); exit(1);
} }
check_strings();
std::string fname {argv[1]}; std::string fname {argv[1]};
SimpCfg sc; SimpCfg sc;
sc.load(fname); sc.load(fname);