[fdbmonitor] Ctests for envvars key-value extraction (#11562)
This commit is contained in:
parent
46e985acf3
commit
bc17127e36
|
@ -128,7 +128,17 @@ void testPathOps() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void testEnvVarUtils() {
|
void testEnvVarUtils() {
|
||||||
// Ensure validation passes for good inputs
|
// Ensure key-value extraction works
|
||||||
|
const std::pair<std::string, std::string> keyValuePair1{ "FOO", "BAR" };
|
||||||
|
assert(keyValuePair1 == EnvVarUtils::extractKeyAndValue("FOO=BAR"));
|
||||||
|
const std::pair<std::string, std::string> keyValuePair2{ "x", "y" };
|
||||||
|
assert(keyValuePair2 == EnvVarUtils::extractKeyAndValue("x=y"));
|
||||||
|
const std::pair<std::string, std::string> keyValuePair3{ "MALLOC_CONF",
|
||||||
|
"prof:true,lg_prof_interval:30,prof_prefix:jeprof.out" };
|
||||||
|
assert(keyValuePair3 ==
|
||||||
|
EnvVarUtils::extractKeyAndValue("MALLOC_CONF=prof:true,lg_prof_interval:30,prof_prefix:jeprof.out"));
|
||||||
|
|
||||||
|
// Ensure key-value validation passes for good inputs
|
||||||
assert(EnvVarUtils::keyValueValid("FOO=BAR", "FOO=BAR"));
|
assert(EnvVarUtils::keyValueValid("FOO=BAR", "FOO=BAR"));
|
||||||
assert(EnvVarUtils::keyValueValid("x=y", "FOO=BAR x=y"));
|
assert(EnvVarUtils::keyValueValid("x=y", "FOO=BAR x=y"));
|
||||||
assert(EnvVarUtils::keyValueValid("MALLOC_CONF=prof:true,lg_prof_interval:30,prof_prefix:jeprof.out",
|
assert(EnvVarUtils::keyValueValid("MALLOC_CONF=prof:true,lg_prof_interval:30,prof_prefix:jeprof.out",
|
||||||
|
@ -136,7 +146,7 @@ void testEnvVarUtils() {
|
||||||
assert(EnvVarUtils::keyValueValid("MALLOC_CONF=prof:true,lg_prof_interval:30,prof_prefix:jeprof.out",
|
assert(EnvVarUtils::keyValueValid("MALLOC_CONF=prof:true,lg_prof_interval:30,prof_prefix:jeprof.out",
|
||||||
"MALLOC_CONF=prof:true,lg_prof_interval:30,prof_prefix:jeprof.out FOO=BAR"));
|
"MALLOC_CONF=prof:true,lg_prof_interval:30,prof_prefix:jeprof.out FOO=BAR"));
|
||||||
|
|
||||||
// Ensure validation fails for bad inputs
|
// Ensure key-value validation fails for bad inputs
|
||||||
assert_msg(!EnvVarUtils::keyValueValid("", "FOO=BAR ="), "Key-Value can not be empty");
|
assert_msg(!EnvVarUtils::keyValueValid("", "FOO=BAR ="), "Key-Value can not be empty");
|
||||||
assert_msg(!EnvVarUtils::keyValueValid("FOO==BAR", "FOO==BAR"), "Only one equal sign allowed");
|
assert_msg(!EnvVarUtils::keyValueValid("FOO==BAR", "FOO==BAR"), "Only one equal sign allowed");
|
||||||
assert_msg(!EnvVarUtils::keyValueValid("BAZ=", "FOO=BAR BAZ="), "Value must be non-empty");
|
assert_msg(!EnvVarUtils::keyValueValid("BAZ=", "FOO=BAR BAZ="), "Value must be non-empty");
|
||||||
|
|
Loading…
Reference in New Issue