1 /*
2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific prior written
16 * permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "xts_io.h"
32
33 LITE_TEST_SUIT(IO, IoOther, IoOtherTestSuite);
34
IoOtherTestSuiteSetUp(void)35 static BOOL IoOtherTestSuiteSetUp(void)
36 {
37 return TRUE;
38 }
39
IoOtherTestSuiteTearDown(void)40 static BOOL IoOtherTestSuiteTearDown(void)
41 {
42 return TRUE;
43 }
44
45 /**
46 * @tc.number SUB_KERNEL_IO_OTHER_0900
47 * @tc.name strptime basic function test
48 * @tc.desc [C- SOFTWARE -0200]
49 */
50 LITE_TEST_CASE(IoOtherTestSuite, testStrptime, Function | MediumTest | Level1)
51 {
52 struct tm tm;
53 memset_s(&tm, sizeof(struct tm), 0, sizeof(struct tm));
54 char *ret = strptime("2020-10-29 21:24:00abc", "%Y-%m-%d %H:%M:%S", &tm);
55 ICUNIT_ASSERT_STRING_EQUAL(ret, "abc", ret);
56 ICUNIT_ASSERT_EQUAL(tm.tm_year, 120, tm.tm_year); /* 120 common data for test, no special meaning */
57 ICUNIT_ASSERT_EQUAL(tm.tm_mon, 9, tm.tm_mon); /* 9 common data for test, no special meaning */
58 ICUNIT_ASSERT_EQUAL(tm.tm_mday, 29, tm.tm_mday); /* 29 common data for test, no special meaning */
59 ICUNIT_ASSERT_EQUAL(tm.tm_hour, 21, tm.tm_hour); /* 21 common data for test, no special meaning */
60 ICUNIT_ASSERT_EQUAL(tm.tm_min, 24, tm.tm_min); /* 24 common data for test, no special meaning */
61
62 ret = strptime("14 Oct October 20 09:24:00 Sat Saturday 363", "%d %b %B %y %I:%M:%S %a %A %j", &tm);
63 ICUNIT_ASSERT_STRING_EQUAL(ret, "", ret);
64 ICUNIT_ASSERT_EQUAL(tm.tm_year, 120, tm.tm_year); /* 120 common data for test, no special meaning */
65 ICUNIT_ASSERT_EQUAL(tm.tm_mon, 9, tm.tm_mon); /* 9 common data for test, no special meaning */
66 ICUNIT_ASSERT_EQUAL(tm.tm_mday, 14, tm.tm_mday); /* 14 common data for test, no special meaning */
67 ICUNIT_ASSERT_EQUAL(tm.tm_hour, 9, tm.tm_hour); /* 9 common data for test, no special meaning */
68 ICUNIT_ASSERT_EQUAL(tm.tm_wday, 6, tm.tm_wday); /* 6 common data for test, no special meaning */
69 ICUNIT_ASSERT_EQUAL(tm.tm_yday, 362, tm.tm_yday); /* 362 common data for test, no special meaning */
70 return 0;
71 }
72
73 RUN_TEST_SUITE(IoOtherTestSuite);
74
XtsIoOtherTest(void)75 void XtsIoOtherTest(void)
76 {
77 RUN_ONE_TESTCASE(testStrptime);
78 }
79