Compare commits

...
Author SHA1 Message Date
Michael Harding 189157b1c7 initialize_for_test changes (thanks eric) 2019-06-13 14:50:24 -04:00
2 changed files with 11 additions and 6 deletions

No files matched your search

+8 -4
View File
@@ -58,7 +58,7 @@ namespace interop {
// Functions used for interop to other languages // Functions used for interop to other languages
///////////////////////////////////////////////// /////////////////////////////////////////////////
std::string getbuffer_serialized_buffer; std::string getbuffer_serialized_buffer;
extern "C" BTS_EXPORT const char* get_buffer(const char* key_name, int& out_length) extern "C" BTS_EXPORT const char* get_buffer(const char* key_name, int& out_length)
{ {
@@ -69,7 +69,7 @@ extern "C" BTS_EXPORT const char* get_buffer(const char* key_name, int& out_leng
getbuffer_serialized_buffer.clear(); getbuffer_serialized_buffer.clear();
message.SerializePartialToString(&getbuffer_serialized_buffer); message.SerializePartialToString(&getbuffer_serialized_buffer);
out_length = getbuffer_serialized_buffer.size(); out_length = getbuffer_serialized_buffer.size();
return getbuffer_serialized_buffer.c_str(); return getbuffer_serialized_buffer.c_str();
} }
@@ -89,10 +89,14 @@ namespace internal {
// Functions used in testing // Functions used in testing
////////////////////////////////////////// //////////////////////////////////////////
extern "C" BTS_EXPORT void initialize_for_test(const std::string& values, bool print_errors) extern "C" BTS_EXPORT void initialize_for_test(const char* values, bool print_errors)
{ {
config_state.reset(); config_state.reset();
config_state.load_string(values, print_errors); config_state.load_string(std::string(values), print_errors);
}
void initialize_for_test(const std::string& value, bool print_errors) {
config_state.reset();
config_state.load_string(value, print_errors);
} }
extern "C" BTS_EXPORT void reset() extern "C" BTS_EXPORT void reset()
+3 -2
View File
@@ -22,7 +22,7 @@ namespace config {
// Load and initialize config. // Load and initialize config.
// This will be automatically called on the first key request but since loading config // This will be automatically called on the first key request but since loading config
// can result in network requests this function is available for applications that want to // can result in network requests this function is available for applications that want to
// manage pauses in execution. // manage pauses in execution.
// Ex: initialize() on a background thread so that config::get<T>() is fast on a UI thread // Ex: initialize() on a background thread so that config::get<T>() is fast on a UI thread
extern "C" BTS_EXPORT void initialize(); extern "C" BTS_EXPORT void initialize();
@@ -56,7 +56,8 @@ namespace config {
{ {
// Initialize configuration state from a string instead of from the filesystem. defaults.conf will still be loaded. // Initialize configuration state from a string instead of from the filesystem. defaults.conf will still be loaded.
// Calling this a second time clears all values from previous initialization // Calling this a second time clears all values from previous initialization
extern "C" BTS_EXPORT void initialize_for_test(const std::string& configuration, bool print_errors=true); extern "C" BTS_EXPORT void initialize_for_test(const char* configuration, bool print_errors=true);
void initialize_for_test(const std::string& configuration, bool print_errors=true);
// Releases all resources and returns config to factory defaults // Releases all resources and returns config to factory defaults
extern "C" BTS_EXPORT void reset(); extern "C" BTS_EXPORT void reset();