[ox] Make ox::String::String(const char*) explicit

This commit is contained in:
2023-12-01 22:36:24 -06:00
parent e9822bf124
commit 1a1c8ae6cc
13 changed files with 83 additions and 105 deletions

View File

@@ -14,7 +14,7 @@
static std::map<ox::String, ox::Error(*)()> tests = {
{
"malloc",
ox::String("malloc"),
[] {
ox::Buffer buff(ox::units::MB);
ox::heapmgr::initHeap(&buff[0], &buff[buff.size()-1]);
@@ -26,7 +26,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"itoa",
ox::String("itoa"),
[]() {
ox::Array<char, 10> buff;
ox::CharBuffWriter bw(buff);
@@ -42,31 +42,31 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"ABCDEFG != HIJKLMN",
ox::String("ABCDEFG != HIJKLMN"),
[]() {
return OxError(ox_memcmp("ABCDEFG", "HIJKLMN", 7) >= 0);
}
},
{
"HIJKLMN != ABCDEFG",
ox::String("HIJKLMN != ABCDEFG"),
[]() {
return OxError(ox_memcmp("HIJKLMN", "ABCDEFG", 7) <= 0);
}
},
{
"ABCDEFG == ABCDEFG",
ox::String("ABCDEFG == ABCDEFG"),
[]() {
return OxError(ox_memcmp("ABCDEFG", "ABCDEFG", 7) != 0);
}
},
{
"ABCDEFGHI == ABCDEFG",
ox::String("ABCDEFGHI == ABCDEFG"),
[]() {
return OxError(ox_memcmp("ABCDEFGHI", "ABCDEFG", 7) != 0);
}
},
{
"BString",
ox::String("BString"),
[]() {
ox::BString<5> s;
s += "A";
@@ -82,7 +82,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"String",
ox::String("String"),
[]() {
ox::String s;
s += "A";
@@ -113,7 +113,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"Vector",
ox::String("Vector"),
[] {
ox::Vector<int> v;
oxAssert(v.size() == 0, "Initial Vector size not 0");
@@ -130,7 +130,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"HashMap",
ox::String("HashMap"),
[] {
ox::HashMap<const char*, int> si;
si["asdf"] = 42;
@@ -146,7 +146,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"Serialize-Int",
ox::String("Serialize-Int"),
[] {
using BA = ox::Array<char, 4>;
const auto actual = ox::serialize<uint32_t>(256).unwrap();
@@ -163,7 +163,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"BufferWriter",
ox::String("BufferWriter"),
[] {
ox::Buffer b;
ox::BufferWriter w(&b);
@@ -180,7 +180,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"FromHex",
ox::String("FromHex"),
[] {
oxExpect(ox::detail::fromHex("01").unwrap(), 0x01);
oxExpect(ox::detail::fromHex("02").unwrap(), 0x02);
@@ -203,7 +203,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"ToHex",
ox::String("ToHex"),
[] {
oxExpect(ox::detail::toHex(0x01), "01");
oxExpect(ox::detail::toHex(0x02), "02");
@@ -223,7 +223,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"UUID",
ox::String("UUID"),
[] {
constexpr ox::StringView uuidStr = "8d814442-f46e-4cc3-8edc-ca3c01cc86db";
oxRequire(uuid, ox::UUID::fromString(uuidStr));
@@ -234,7 +234,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"UUID::generate",
ox::String("UUID::generate"),
[] {
ox::UUID::seedGenerator({1234, 4321});
oxExpect(ox::UUID::generate().unwrap().toString(), "5c3f4b5e-ccbf-4727-7f03-3053dedc8827");
@@ -244,7 +244,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
}
},
{
"StringSplit",
ox::String("StringSplit"),
[] {
ox::StringView sv = "ab.cd";
auto list = ox::split(sv, ".");
@@ -314,7 +314,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
int main(int argc, const char **args) {
if (argc > 1) {
auto testName = args[1];
auto testName = ox::String(args[1]);
if (tests.find(testName) != tests.end()) {
oxAssert(tests[testName](), "Test returned Error");
return 0;