summaryrefslogtreecommitdiff
path: root/tests/unit/plugins/xfer/test-xfer-file.cpp
blob: ee868eadf6e605afc823a62e6dffc6759774d03c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 * test-xfer-file.cpp - test xfer file functions
 *
 * Copyright (C) 2022-2024 Sébastien Helleu <flashcode@flashtux.org>
 *
 * This file is part of WeeChat, the extensible chat client.
 *
 * WeeChat is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * WeeChat is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WeeChat.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "CppUTest/TestHarness.h"

extern "C"
{
#include "src/plugins/xfer/xfer-file.h"
}

TEST_GROUP(XferFile)
{
};

/*
 * Tests functions:
 *   xfer_file_search_crc32
 */

TEST(XferFile, SearchCrc32)
{
    POINTERS_EQUAL(NULL, xfer_file_search_crc32 (NULL));
    POINTERS_EQUAL(NULL, xfer_file_search_crc32 (""));
    POINTERS_EQUAL(NULL, xfer_file_search_crc32 ("a"));
    POINTERS_EQUAL(NULL, xfer_file_search_crc32 ("z"));
    POINTERS_EQUAL(NULL, xfer_file_search_crc32 ("123456781234abcd"));
    POINTERS_EQUAL(NULL, xfer_file_search_crc32 ("test_filename"));

    /* valid CRC32 */
    STRCMP_EQUAL("1234abcd", xfer_file_search_crc32 ("test_1234abcd"));
    STRCMP_EQUAL("1234aBCd", xfer_file_search_crc32 ("test_1234aBCd"));
    STRCMP_EQUAL("1234abcd_test", xfer_file_search_crc32 ("1234abcd_test"));
    STRCMP_EQUAL("1234Abcd_test", xfer_file_search_crc32 ("1234Abcd_test"));
    STRCMP_EQUAL("12345678", xfer_file_search_crc32 ("1234abcd_12345678"));
}

/*
 * Tests functions:
 *   xfer_file_resume
 */

TEST(XferFile, Resume)
{
    /* TODO: write tests */
}

/*
 * Tests functions:
 *   xfer_file_check_suffix
 */

TEST(XferFile, CheckSuffix)
{
    /* TODO: write tests */
}

/*
 * Tests functions:
 *   xfer_file_find_suffix
 */

TEST(XferFile, FindSuffix)
{
    /* TODO: write tests */
}

/*
 * Tests functions:
 *   xfer_file_find_filename
 */

TEST(XferFile, FindFilename)
{
    /* TODO: write tests */
}

/*
 * Tests functions:
 *   xfer_file_calculate_speed
 */

TEST(XferFile, CalculateSpeed)
{
    /* TODO: write tests */
}