1 /**
2 * Copyright (c) 2021-2024 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 #include "libpandabase/utils/utils.h"
22
23 #include <gtest/gtest.h>
24
25 namespace ark::verifier::test {
26
Generator()27 std::string *Generator()
28 {
29 std::string str = "Generator";
30 static std::string curStr;
31 static int strPos = 0;
32 // NOLINTNEXTLINE(readability-magic-numbers)
33 if (strPos < 0x9) {
34 curStr = str[strPos];
35 strPos++;
36 return &curStr;
37 }
38 strPos = 0;
39 return nullptr;
40 }
41
TEST_F(VerifierTest,str)42 TEST_F(VerifierTest, str)
43 {
44 EXPECT_EQ(Join<std::string>(Generator), "G, e, n, e, r, a, t, o, r");
45 EXPECT_EQ(Join<std::string>(Generator, "."), "G.e.n.e.r.a.t.o.r");
46
47 EXPECT_EQ(NumToStr(-1456_I), "-1456");
48 EXPECT_EQ(NumToStr(0x1C, 0x10), "1c");
49 }
50
51 } // namespace ark::verifier::test
52