/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ohos_types.h"
#include <securec.h>
#include "hctest.h"
#include "utils_config.h"
/**
* @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency
* @param : subsystem name is utils
* @param : module name is kvStore
* @param : test suit name is KvStoreFuncTestSuite
*/
LITE_TEST_SUIT(utils, kvStore, KvStoreFuncTestSuite);
/**
* @tc.setup : setup for all testcases
* @return : setup result, TRUE is success, FALSE is fail
*/
static BOOL KvStoreFuncTestSuiteSetUp(void)
{
return TRUE;
}
/**
* @tc.teardown : teardown for all testcases
* @return : teardown result, TRUE is success, FALSE is fail
*/
static BOOL KvStoreFuncTestSuiteTearDown(void)
{
return TRUE;
}
/**
* @tc.number : SUB_UTILS_KV_STORE_0100
* @tc.name : UtilsSetValue parameter legal test
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(KvStoreFuncTestSuite, testKvStoreSetValue001, Function | MediumTest | Level1)
{
char key[] = "rw.sys.version";
char value[] = "Hello world !";
int ret = UtilsSetValue(key, value);
TEST_ASSERT_EQUAL_INT(0, ret);
ret = UtilsDeleteValue(key);
TEST_ASSERT_EQUAL_INT(0, ret);
};
/**
* @tc.number : SUB_UTILS_KV_STORE_0200
* @tc.name : UtilsSetValue parameter legal test using key with underline
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(KvStoreFuncTestSuite, testKvStoreSetValue002, Function | MediumTest | Level1)
{
char key[] = "rw.sys.version_100";
char value[] = "Hello world !";
int ret = UtilsSetValue(key, value);
TEST_ASSERT_EQUAL_INT(0, ret);
ret = UtilsDeleteValue(key);
TEST_ASSERT_EQUAL_INT(0, ret);
};
RUN_TEST_SUITE(KvStoreFuncTestSuite);