1 /*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 * Copyright (c) 2015 Runtime Inc
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8 #include "settings_test.h"
9
ZTEST(settings_config,test_config_getset_int64)10 ZTEST(settings_config, test_config_getset_int64)
11 {
12 char name[80];
13 char tmp[64];
14 int rc;
15 int64_t new_val64;
16
17 new_val64 = 0x8012345678901234;
18 strcpy(name, "myfoo/mybar64");
19 rc = settings_runtime_set(name, &new_val64, sizeof(int64_t));
20 zassert_true(rc == 0, "can't set value");
21 zassert_true(test_set_called == 1, "the SET handler wasn't called");
22 zassert_equal(val64, 0x8012345678901234,
23 "SET handler: was called with wrong parameters");
24 ctest_clear_call_state();
25
26 strcpy(name, "myfoo/mybar64");
27 rc = settings_runtime_get(name, tmp, sizeof(tmp));
28 zassert_equal(rc, sizeof(int64_t), "the key value should been available");
29 zassert_true(test_get_called == 1, "the GET handler wasn't called");
30 memcpy(&new_val64, tmp, sizeof(int64_t));
31 zassert_equal(new_val64, 0x8012345678901234,
32 "unexpected value fetched %d", tmp);
33 ctest_clear_call_state();
34
35 new_val64 = 1;
36 strcpy(name, "myfoo/mybar64");
37 rc = settings_runtime_set(name, &new_val64, sizeof(int64_t));
38 zassert_true(rc == 0, "can't set value");
39 zassert_true(test_set_called == 1, "the SET handler wasn't called");
40 zassert_equal(val64, 1,
41 "SET handler: was called with wrong parameters");
42 ctest_clear_call_state();
43
44 strcpy(name, "myfoo/mybar64");
45 rc = settings_runtime_get(name, tmp, sizeof(tmp));
46 zassert_equal(rc, sizeof(int64_t), "the key value should been available");
47 zassert_true(test_get_called == 1, "the GET handler wasn't called");
48 memcpy(&new_val64, tmp, sizeof(int64_t));
49 zassert_equal(new_val64, 1,
50 "unexpected value fetched %d", tmp);
51 ctest_clear_call_state();
52 }
53