mirror of https://github.com/orefkov/simstr.git
- Updated to version 1.6.3
- e_subst has been rewritten and no longer requires specifying the format string twice. - Added the e_int method for formatting integers. - Bug fixes and code optimizations. - Benchmarks and tests added. - Updated documentation and benchmark results. - Обновлена версия на 1.6.3 - e_subst переделан и теперь не требует указывать форматную строку дважды. - Добавлен метод e_int для форматирования целых чисел. - Исправлены ошибки, оптимизирован код. - Добавлены бенчмарки и тесты. - Обновлена документация и результаты бенчмарков.
This commit is contained in:
parent
15c78e65f9
commit
317a4c5994
|
|
@ -5,7 +5,7 @@ include(FetchContent)
|
|||
|
||||
project(
|
||||
simstr
|
||||
VERSION 1.6.2
|
||||
VERSION 1.6.3
|
||||
DESCRIPTION "Yet another modern C++ string library"
|
||||
HOMEPAGE_URL "https://github.com/orefkov/simstr"
|
||||
LANGUAGES CXX
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ cmake_minimum_required (VERSION 3.15)
|
|||
add_executable(benchStr bench_str.cpp bench.h)
|
||||
target_link_libraries(benchStr simstr::simstr benchmark::benchmark)
|
||||
target_compile_features(benchStr PUBLIC cxx_std_23)
|
||||
target_compile_definitions(benchStr PRIVATE SIMSTR_VERSION="${PROJECT_VERSION}")
|
||||
|
||||
add_executable(process_result process_result.cpp)
|
||||
target_link_libraries(process_result simstr_simstr)
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
#target_link_options(benchStr PRIVATE -sSTACK_SIZE=1048576 -sINITIAL_MEMORY=128MB -sALLOW_MEMORY_GROWTH=0)
|
||||
set_target_properties (benchStr PROPERTIES SUFFIX .html)
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ void ConcatSimToSimHexS(benchmark::State& state) {
|
|||
for (auto _: state) {
|
||||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||||
benchmark::DoNotOptimize(s1);
|
||||
stringa str = e_subst(S_FRM("{}{} end"), s1, e_hex<HexFlags::Short>(i));
|
||||
stringa str = e_subst("{}{} end", s1, e_hex<HexFlags::Short>(i));
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
|
|
@ -176,13 +176,58 @@ void ConcatSimToSimHexVS(benchmark::State& state) {
|
|||
BENCHMARK(__)->Name("----- Concatenate string + Hex Number + \"Literal\" ---------")->Repetitions(1);
|
||||
BENCHMARK(ConcatStdToFmtHex) ->Name("Concat std::string and format hex number and literal to std::string");
|
||||
BENCHMARK(ConcatAllFmtToHex) ->Name("std::format std::string and hex number by literal to std::string");
|
||||
BENCHMARK(ConcatStdToCharsHex) ->Name("Concat std::string and std::tochars and string to std::string");
|
||||
BENCHMARK(ConcatStdToCharsHex) ->Name("Concat std::string and std::to_chars and string to std::string");
|
||||
BENCHMARK(ConcatSimToStdHex) ->Name("Concat std::string and hex number and literal by StrExpr to std::string");
|
||||
BENCHMARK(ConcatSimToSimHex) ->Name("Concat stringa and hex number and literal by StrExpr to simstr::stringa");
|
||||
BENCHMARK(ConcatSimToSimHexC) ->Name("Concat stringa and hex number and literal by e_concat to simstr::stringa");
|
||||
BENCHMARK(ConcatSimToSimHexS) ->Name("Subst stringa and hex number by e_subst literal to simstr::stringa");
|
||||
BENCHMARK(ConcatSimToSimHexVS) ->Name("Subst stringa and hex number by e_vsubst stra to simstr::stringa");
|
||||
|
||||
void SubstSimToSimBin(benchmark::State& state) {
|
||||
static bool first = true;
|
||||
for (auto _: state) {
|
||||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||||
stringa str = e_subst("art {} end", e_int<8, f::w<10> | f::p | f::z>(i));
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FormatStdToStdBin(benchmark::State& state) {
|
||||
for (auto _: state) {
|
||||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||||
std::string str = std::format("art {:#010o} end", i);
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VSubstSimToSimBin(benchmark::State& state) {
|
||||
ssa pattern = "art {} end";
|
||||
for (auto _: state) {
|
||||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||||
stringa str = e_vsubst(pattern, e_int<8, f::w<10> | f::p | f::z>(i));
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VFormatStdToStdBin(benchmark::State& state) {
|
||||
std::string_view pattern = "art {:#010o} end";
|
||||
static bool first = true;
|
||||
for (auto _: state) {
|
||||
for (unsigned i = 1; i <= 100'000; i *= 10) {
|
||||
std::string str = std::vformat(pattern, std::make_format_args(i));
|
||||
benchmark::DoNotOptimize(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
BENCHMARK(__)->Name("----- format/vformat and subst/vsubst octal number ---------")->Repetitions(1);
|
||||
BENCHMARK(SubstSimToSimBin) ->Name("e_subst(\"art {} end\", e_int<8, f::w<10> | f::p | f::z>(i))");
|
||||
BENCHMARK(FormatStdToStdBin) ->Name("std::format(\"art {:#010o} end\", i)");
|
||||
BENCHMARK(VSubstSimToSimBin) ->Name("e_vsubst(pattern, e_int<8, f::w<10> | f::p | f::z>(i))");
|
||||
BENCHMARK(VFormatStdToStdBin) ->Name("std::vformat(pattern, std::make_format_args(i))");
|
||||
|
||||
void ConcatStdToStdS(benchmark::State& state) {
|
||||
std::string s1 = "start ";
|
||||
for (auto _: state) {
|
||||
|
|
@ -2343,7 +2388,10 @@ BENCHMARK(BuildFuncNameSimStr) ->Name("Build func full name stringa;");
|
|||
BENCHMARK(BuildFuncNameSimStr1) ->Name("Build func full name stringa 1;");
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
char arg1[] = "--benchmark_repetitions=10", arg2[] = "--benchmark_report_aggregates_only=true";
|
||||
std::cout << "Benchmarks of simstr, version " SIMSTR_VERSION << "\n"
|
||||
<< "Sources: https://github.com/orefkov/simstr\n"
|
||||
<< "Results: https://orefkov.github.io/simstr/results.html\n" << std::endl;
|
||||
char arg1[] = "--benchmark_repetitions=4", arg2[] = "--benchmark_report_aggregates_only=true";
|
||||
char* my_params[] = {argv[0], arg1, arg2};
|
||||
if (argc < 2) {
|
||||
argc = 3;
|
||||
|
|
|
|||
|
|
@ -265,6 +265,7 @@
|
|||
}
|
||||
});
|
||||
</script>
|
||||
</head><body><div class="header"><h2>SimStr benchmarks results</h2>
|
||||
</head><body><div class="header"><h2>simstr benchmarks results</h2>
|
||||
<div style="font-size:16pt;margin:20px;text-align:center"><a href="https://github.com/orefkov/simstr">simstr</a> is a powerful and convenient library for productive work with strings in C++.</div>
|
||||
<span>All times in ns.</span>
|
||||
<span><a href="https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp">Source for benchmarks</a></span>
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ void write_platforms_cpu(out_t& out, const results_vector& results) {
|
|||
size_t rp = r.cpu_info_.find('(') + 1, lp = r.cpu_info_.find(')', rp);
|
||||
ssa shortCpuInfo = r.cpu_info_.from_to(rp, lp);
|
||||
ssa cpuInfo = r.cpu_info_(lp + 2);
|
||||
out.append_formatted(R"--(
|
||||
out += e_subst(R"--(
|
||||
<li><span class="platform">{}</span><span class="tooltip">{}<span class="tooltiptext">{}</span></span> Include in charts: <input type="checkbox" id="pl{}" checked onchange="buildCharts()"/></li>)--",
|
||||
r.platform_, shortCpuInfo, cpuInfo, counter++);
|
||||
script += "'" + e_repl(r.platform_.to_str(), "'", "\\'") + "'" + e_choice(&r == &results.back(), "]", ",");
|
||||
|
|
|
|||
1024
bench/results.html
1024
bench/results.html
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -48,7 +48,7 @@ PROJECT_NAME = "simstr"
|
|||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 1.6.2
|
||||
PROJECT_NUMBER = 1.6.3
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewers a
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ PROJECT_NAME = "simstr"
|
|||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 1.6.2
|
||||
PROJECT_NUMBER = 1.6.3
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewers a
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* (c) Проект "SimStr", Александр Орефков orefkov@gmail.com
|
||||
* ver. 1.6.2
|
||||
* ver. 1.6.3
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* (c) Проект "SimStr", Александр Орефков orefkov@gmail.com
|
||||
* ver. 1.6.2
|
||||
* ver. 1.6.3
|
||||
* Классы для работы со строками
|
||||
* (c) Project "SimStr", Aleksandr Orefkov orefkov@gmail.com
|
||||
* ver. 1.6.2
|
||||
* ver. 1.6.3
|
||||
* Classes for working with strings
|
||||
*/
|
||||
|
||||
|
|
@ -3822,6 +3822,7 @@ class decl_empty_bases cestring :
|
|||
public null_terminated<K, lstring<K, N>>
|
||||
//, public from_utf_convertible<K, lstring<K, N, forShared, Allocator>>
|
||||
{
|
||||
public:
|
||||
using symb_type = K;
|
||||
using my_type = cestring<K, N>;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
[](https://github.com/orefkov/simstr/actions/workflows/cmake-multi-platform.yml)
|
||||
|
||||
Version 1.6.2.
|
||||
Version 1.6.3.
|
||||
|
||||
<h2>Speed up your work with strings by 2-10 times!</h2>
|
||||
|
||||
|
|
@ -323,8 +323,8 @@ function(add_simstr)
|
|||
simstr
|
||||
GIT_REPOSITORY https://github.com/orefkov/simstr.git
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_TAG tags/rel1.6.2 # Specify the desired release
|
||||
FIND_PACKAGE_ARGS NAMES simstr 1.6.2
|
||||
GIT_TAG tags/rel1.6.3 # Specify the desired release
|
||||
FIND_PACKAGE_ARGS NAMES simstr 1.6.3
|
||||
)
|
||||
FetchContent_MakeAvailable(simstr)
|
||||
endfunction()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
[](https://github.com/orefkov/simstr/actions/workflows/cmake-multi-platform.yml)
|
||||
|
||||
Версия 1.6.2.
|
||||
Версия 1.6.3.
|
||||
|
||||
<h2>Ускорь работу со строками в 2-10 раз!</h2>
|
||||
|
||||
|
|
@ -324,8 +324,8 @@ function(add_simstr)
|
|||
simstr
|
||||
GIT_REPOSITORY https://github.com/orefkov/simstr.git
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_TAG tags/rel1.6.2 # Укажите нужный релиз
|
||||
FIND_PACKAGE_ARGS NAMES simstr 1.6.2
|
||||
GIT_TAG tags/rel1.6.3 # Укажите нужный релиз
|
||||
FIND_PACKAGE_ARGS NAMES simstr 1.6.3
|
||||
)
|
||||
FetchContent_MakeAvailable(simstr)
|
||||
endfunction()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* ver. 1.6.2
|
||||
* ver. 1.6.3
|
||||
* (c) Проект "SimStr", Александр Орефков orefkov@gmail.com
|
||||
* Реализация строковых функций
|
||||
* (c) Project "SimStr", Aleksandr Orefkov orefkov@gmail.com
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* ver. 1.6.2
|
||||
* ver. 1.6.3
|
||||
* (c) Проект "SimStr", Александр Орефков orefkov@gmail.com
|
||||
* Тесты simstr
|
||||
* (c) Project "SimStr", Aleksandr Orefkov orefkov@gmail.com
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "../include/simstr/strexpr.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <format>
|
||||
#include <list>
|
||||
|
||||
using namespace std::literals;
|
||||
|
|
@ -325,12 +326,12 @@ TEST(StrExpr, Concat) {
|
|||
TEST(StrExpr, Subst) {
|
||||
const auto ttt = "test"_ss;
|
||||
int ii = 3;
|
||||
std::string t = e_subst(S_FRM("Test {{--}} {}=, {}"), ttt, ii);
|
||||
std::string t = e_subst("Test {{--}} {}=, {}", ttt, ii);
|
||||
EXPECT_EQ(t, "Test {--} test=, 3");
|
||||
t = e_subst(S_FRM("Test {2}={1}, {2}, {1}"), "test", 2);
|
||||
t = e_subst("Test {2}={1}, {2}, {1}", "test", 2);
|
||||
EXPECT_EQ(t, "Test 2=test, 2, test");
|
||||
|
||||
std::u16string u16t = e_subst(S_FRM(u"Test {}={}, {}"), u"test", 2, u"test"sv);
|
||||
std::u16string u16t = e_subst(u"Test {}={}, {}", u"test", 2, u"test"sv);
|
||||
EXPECT_EQ(u16t, u"Test test=2, test");
|
||||
}
|
||||
|
||||
|
|
@ -344,4 +345,58 @@ TEST(StrExpr, VSubst) {
|
|||
EXPECT_EQ(t, "abc-abc-abc-abc-abc-abc-abc-abc");
|
||||
}
|
||||
|
||||
TEST(StrExpr, EInt) {
|
||||
std::string kk = eea + e_int<10, f::c | f::w<10> | f::f<'_'> | f::sp>(123);
|
||||
EXPECT_EQ(kk, "___+123___");
|
||||
std::u16string uk = eeu + e_int<2, f::p>(123);
|
||||
EXPECT_EQ(uk, u"0b1111011");
|
||||
|
||||
kk = eea + e_int<2, f::p | f::w<11> | f::z>(123);
|
||||
std::string kf = std::format("{:#011b}", 123);
|
||||
|
||||
EXPECT_EQ(kk, kf);
|
||||
|
||||
kk = eea + e_int<2, f::p | f::w<11> | f::z>(-123);
|
||||
kf = std::format("{:#011b}", -123);
|
||||
EXPECT_EQ(kk, kf);
|
||||
|
||||
kk = eea + e_int<2, f::p | f::w<11> | f::z | f::sp>(123);
|
||||
kf = std::format("{:+#011b}", 123);
|
||||
EXPECT_EQ(kk, kf);
|
||||
|
||||
kk = eea + e_int<2, f::p | f::w<11> | f::z | f::sp>(-123);
|
||||
kf = std::format("{:+#011b}", -123);
|
||||
EXPECT_EQ(kk, kf);
|
||||
|
||||
kk = eea + e_int<2, f::p | f::w<11> | f::z | f::ss>(123);
|
||||
kf = std::format("{: #011b}", 123);
|
||||
EXPECT_EQ(kk, kf);
|
||||
|
||||
kk = eea + e_int<2, f::p | f::w<11> | f::z | f::ss>(-123);
|
||||
kf = std::format("{: #011b}", -123);
|
||||
EXPECT_EQ(kk, kf);
|
||||
|
||||
kk = eea + e_int<2, f::w<11> | f::r | f::f<'_'>| f::ss>(-123);
|
||||
kf = std::format("{:_> 11b}", -123);
|
||||
EXPECT_EQ(kk, kf);
|
||||
|
||||
kk = eea + e_int<2, f::w<11> | f::r | f::f<'_'>| f::ss>(123);
|
||||
kf = std::format("{:_> 11b}", 123);
|
||||
EXPECT_EQ(kk, kf);
|
||||
|
||||
kk = eea + e_int<2, f::p | f::w<11> | f::r | f::f<'_'>| f::ss>(123);
|
||||
kf = std::format("{:_> #11b}", 123);
|
||||
EXPECT_EQ(kk, kf);
|
||||
|
||||
//EXPECT_EQ(kk, "0b001111011");
|
||||
//std::cout << std::format("'{:+#011b}'\n", 123);
|
||||
|
||||
//std::cout << std::format("'{:+#011b}'\n", -123);
|
||||
//EXPECT_EQ(kk, std::format("{:#011b}", -123));
|
||||
|
||||
std::u32string uu = eeuu + e_int<16, f::wp | f::p | f::u | f::z/* | f::r*/>(123, 9);
|
||||
EXPECT_EQ(uu, U"0x000007B");
|
||||
}
|
||||
|
||||
|
||||
} // namespace simstr::tests
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* ver. 1.6.2
|
||||
* ver. 1.6.3
|
||||
* (c) Проект "SimStr", Александр Орефков orefkov@gmail.com
|
||||
* Тесты simstr
|
||||
* (c) Project "SimStr", Aleksandr Orefkov orefkov@gmail.com
|
||||
|
|
@ -1995,7 +1995,7 @@ TEST(SimStr, EFill) {
|
|||
TEST(SimStr, Subst) {
|
||||
int from = 1, total = 100;
|
||||
bool success = true;
|
||||
lstringu<100> u16t = e_subst(S_FRM(u"Test {} from {}, {}."), from, total, e_choice(success, u"success", u"fail"));
|
||||
lstringu<100> u16t = e_subst(u"Test {} from {}, {}.", from, total, e_choice(success, u"success", u"fail"));
|
||||
EXPECT_EQ(u16t, u"Test 1 from 100, success.");
|
||||
}
|
||||
|
||||
|
|
@ -2003,7 +2003,8 @@ void check_equal(stra a, stra b) {
|
|||
EXPECT_EQ(a, b);
|
||||
}
|
||||
|
||||
inline constexpr cestring<char, 100> ce_sample = "sample " + e_subst(S_FRM("test = {}"), e_hex(10)) + ", done";
|
||||
#ifndef _MSC_VER
|
||||
inline constexpr cestring<char, 100> ce_sample = "sample " + e_subst("test = {}", e_hex(10)) + ", done";
|
||||
|
||||
TEST(SimStr, ConstEval) {
|
||||
constexpr cestring<char, 100> ce_empty;
|
||||
|
|
@ -2030,10 +2031,10 @@ TEST(SimStr, ConstEval) {
|
|||
constexpr cestring<char, 100> ce_expr = "test = "_ss + 10 + " times";
|
||||
static_assert(ce_expr == "test = 10 times");
|
||||
|
||||
constexpr cestring<char, 100> ce_subst = e_subst(S_FRM("test = {}"), 10);
|
||||
constexpr cestring<char, 100> ce_subst = e_subst("test = {}", 10);
|
||||
static_assert(ce_subst == "test = 10");
|
||||
|
||||
constexpr cestring<char, 100> ce_hex = e_subst(S_FRM("test = {}"), e_hex(10));
|
||||
constexpr cestring<char, 100> ce_hex = e_subst("test = {}", e_hex(10));
|
||||
static_assert(ce_hex == "test = 0x0000000A");
|
||||
|
||||
constexpr cestring<char, 100> ce_concat = e_concat("", "test = ", 10, " times");
|
||||
|
|
@ -2054,9 +2055,9 @@ TEST(SimStr, ConstEval) {
|
|||
constexpr cestring<char, 100> ce_repl = e_repl("test", "e", "--");
|
||||
static_assert(ce_repl == "t--st");
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace simstr::tests
|
||||
|
||||
TEST(SimStr, StrNoNamespace) {
|
||||
std::string str = "test";
|
||||
std::string test = +str + " = " + 10;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* ver. 1.6.2
|
||||
* ver. 1.6.3
|
||||
* (c) Проект "SimStr", Александр Орефков orefkov@gmail.com
|
||||
* Тесты simstr
|
||||
* (c) Project "SimStr", Aleksandr Orefkov orefkov@gmail.com
|
||||
|
|
@ -69,7 +69,7 @@ TEST(ToStrExpr, CheckExclamation) {
|
|||
EXPECT_EQ(test, "Msg is <Happy Birthday!!!>");
|
||||
|
||||
const add_exclamation cmsg{"Happy Birthday", 0};
|
||||
test = e_subst(S_FRM("Msg is <{}>"), cmsg);
|
||||
test = e_subst("Msg is <{}>", cmsg);
|
||||
EXPECT_EQ(test, "Msg is <Happy Birthday>");
|
||||
}
|
||||
//! [Method1]
|
||||
|
|
@ -149,7 +149,7 @@ TEST(ToStrExpr, CheckCarInfo) {
|
|||
EXPECT_EQ(test, "Car is <Model: Ford, Year: 2021>");
|
||||
|
||||
ci.year++;
|
||||
test = e_subst(S_FRM("Car is <{}>"), ci);
|
||||
test = e_subst("Car is <{}>", ci);
|
||||
EXPECT_EQ(test, "Car is <Model: Ford, Year: 2022>");
|
||||
}
|
||||
//! [Method2]
|
||||
|
|
@ -216,7 +216,7 @@ TEST(ToStrExpr, CheckAnimal) {
|
|||
test = e_concat("", "<", dog, ">");
|
||||
EXPECT_EQ(test, "<Animal: Dog, Sound: Woof>");
|
||||
|
||||
test = e_subst(S_FRM("\\_{}_/"), animal{"Snake", "Pssstt"});
|
||||
test = e_subst("\\_{}_/", animal{"Snake", "Pssstt"});
|
||||
EXPECT_EQ(test, "\\_Animal: Snake, Sound: Pssstt_/");
|
||||
}
|
||||
//! [Method3]
|
||||
|
|
@ -268,7 +268,7 @@ TEST(ToStrExpr, CheckTest) {
|
|||
t = e_concat("", "<", t2, ">");
|
||||
EXPECT_EQ(t, "<test 8 from 12>");
|
||||
|
||||
t = e_subst(S_FRM("<{}>"), test{99, 100});
|
||||
t = e_subst("<{}>", test{99, 100});
|
||||
EXPECT_EQ(t, "<test 99 from 100>");
|
||||
|
||||
// Проверим работу для не char
|
||||
|
|
@ -296,12 +296,13 @@ TEST(ToStrExpr, SubstCustom) {
|
|||
const auto ttt = "test"_ss;
|
||||
int ii = 3;
|
||||
const test tr{10, 10};
|
||||
std::string t = e_subst(S_FRM("Test {{--}} {}={}, {}"), ttt, tr, ii);
|
||||
std::string t = e_subst("Test {{--}} {}={}, {}", ttt, tr, ii);
|
||||
EXPECT_EQ(t, "Test {--} test=test 10 from 10, 3");
|
||||
t = e_subst(S_FRM("Test {2}={1}, {2}, {1}"), "test", 2);
|
||||
t = e_subst("Test {2}={1}, {2}, {1}", "test", 2);
|
||||
EXPECT_EQ(t, "Test 2=test, 2, test");
|
||||
|
||||
std::u16string u16t = e_subst(S_FRM(u"Test {}={}, {}"), u"test", 2, u"test"sv);
|
||||
std::u16string u16t = e_subst(u"Test {}={}, {}", u"test", 2, u"test"sv);
|
||||
EXPECT_EQ(u16t, u"Test test=2, test");
|
||||
}
|
||||
|
||||
} // namespace simstr::tests
|
||||
|
|
|
|||
Loading…
Reference in New Issue