-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathtest_utils_serialize.c
More file actions
39 lines (29 loc) · 1.15 KB
/
test_utils_serialize.c
File metadata and controls
39 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include "parson/parson.h"
#include <greatest/greatest.h>
#include <featureflags.h>
#include <utils/serializer.h>
#include <utils/serializer/buffered_writer.h>
#define SERIALIZE_TEST_FILE "/data/data/com.bugsnag.android.ndk.test/cache/"
void bsg_update_next_run_info(bsg_environment *env);
TEST test_last_run_info_serialization(void) {
bsg_environment *env = calloc(1, sizeof(bsg_environment));
strcpy(env->last_run_info_path, SERIALIZE_TEST_FILE);
// update LastRunInfo with defaults
env->next_event.app.is_launching = false;
env->consecutive_launch_crashes = 1;
bsg_update_next_run_info(env);
ASSERT_STR_EQ("consecutiveLaunchCrashes=1\ncrashed=true\ncrashedDuringLaunch=false\0", env->next_last_run_info);
// update LastRunInfo with consecutive crashes
env->next_event.app.is_launching = true;
env->consecutive_launch_crashes = 7;
bsg_update_next_run_info(env);
ASSERT_STR_EQ("consecutiveLaunchCrashes=8\ncrashed=true\ncrashedDuringLaunch=true\0", env->next_last_run_info);
free(env);
PASS();
}
SUITE(suite_json_serialization) {
RUN_TEST(test_last_run_info_serialization);
}