blob: 98c96c93cd12b7fe0090f6be4f71fc20fd38b65f [file] [log] [blame]
Scott Baker2c1c4822019-10-16 11:02:41 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package kvstore
17
18import (
19 "github.com/stretchr/testify/assert"
20 "testing"
Scott Baker2c1c4822019-10-16 11:02:41 -070021)
22
Scott Baker2c1c4822019-10-16 11:02:41 -070023func TestToStringWithString(t *testing.T) {
24 actualResult, _ := ToString("myString")
25 var expectedResult = "myString"
26
27 assert.Equal(t, expectedResult, actualResult)
28}
29
30func TestToStringWithEmpty(t *testing.T) {
31 actualResult, _ := ToString("")
32 var expectedResult = ""
33
34 assert.Equal(t, expectedResult, actualResult)
35}
36
37func TestToStringWithByte(t *testing.T) {
38 mByte := []byte("Hello")
39 actualResult, _ := ToString(mByte)
40 var expectedResult = "Hello"
41
42 assert.Equal(t, expectedResult, actualResult)
43}
44
45func TestToStringWithEmptyByte(t *testing.T) {
46 mByte := []byte("")
47 actualResult, _ := ToString(mByte)
48 var expectedResult = ""
49
50 assert.Equal(t, expectedResult, actualResult)
51}
52
53func TestToStringForErrorCase(t *testing.T) {
54 mInt := 200
55 actualResult, error := ToString(mInt)
56 var expectedResult = ""
57
58 assert.Equal(t, expectedResult, actualResult)
59 assert.NotEqual(t, error, nil)
60}