#undef NDEBUG
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# define NOMINMAX
# define _CRT_SECURE_NO_WARNINGS
#endif
#include "sentry.h"
#include <assert.h>
#include <string.h>
#include "sentry_json.h"
#include "sentry_path.h"
#include "sentry_value.h"
int
main(int argc, char **argv)
{
if (argc != 2) {
return 1;
}
const char *filename = argv[1];
sentry_path_t *path = sentry__path_from_str(filename);
size_t buf_len = 0;
char *buf = sentry__path_read_to_buffer(path, &buf_len);
sentry__path_free(path);
if (!buf) {
return 0;
}
sentry_value_t value = sentry__value_from_json(buf, buf_len);
sentry_free(buf);
sentry_jsonwriter_t *jw = sentry__jsonwriter_new(NULL);
sentry__jsonwriter_write_value(jw, value);
size_t serialized1_len = 0;
char *serialized1 = sentry__jsonwriter_into_string(jw, &serialized1_len);
sentry_value_decref(value);
value = sentry__value_from_json(serialized1, serialized1_len);
jw = sentry__jsonwriter_new(NULL);
sentry__jsonwriter_write_value(jw, value);
size_t serialized2_len = 0;
char *serialized2 = sentry__jsonwriter_into_string(jw, &serialized2_len);
sentry_value_decref(value);
assert(serialized1_len == serialized2_len
&& memcmp(serialized1, serialized2, serialized1_len) == 0);
sentry_free(serialized1);
sentry_free(serialized2);
return 0;
}