1 /**
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <string>
17
18 #include "util/str.h"
19
20 #include "util/tests/verifier_test.h"
21
22 #include <gtest/gtest.h>
23
24 namespace panda::verifier::test {
25
Generator()26 std::string *Generator()
27 {
28 std::string str = "Generator";
29 static std::string cur_str;
30 static int str_pos = 0;
31 if (str_pos < 0x9) {
32 cur_str = str[str_pos];
33 str_pos++;
34 return &cur_str;
35 }
36 str_pos = 0;
37 return nullptr;
38 }
39
TEST_F(VerifierTest,str)40 TEST_F(VerifierTest, str)
41 {
42 EXPECT_EQ(Join<std::string>(Generator), "G, e, n, e, r, a, t, o, r");
43 EXPECT_EQ(Join<std::string>(Generator, "."), "G.e.n.e.r.a.t.o.r");
44
45 EXPECT_EQ(NumToStr(-1456), "-1456");
46 EXPECT_EQ(NumToStr(0x1C, 0x10), "1c");
47 }
48
49 } // namespace panda::verifier::test