plptools
Loading...
Searching...
No Matches
plpdirenttests.cc
Go to the documentation of this file.
1/*
2 * This file is part of plptools.
3 *
4 * Copyright (c) 2026 Jason Morley <hello@jbmorley.co.uk>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * along with this program; if not, see <https://www.gnu.org/licenses/>.
18 *
19 */
20#include "config.h"
21
22#include <stdlib.h>
23#include <stdio.h>
24
25#include "doctest.h"
26#include "plpdirent.h"
27#include "rfsv.h"
28
29TEST_CASE("PlpDirent::getPath") {
30
31 SUBCASE("Directory name with no trailing backslash") {
32 PlpDirent dirent(0, 0, 0, 0, "C:\\Projects", "foo.txt");
33 CHECK(dirent.isDirectory() == false);
34 std::string name = dirent.getName();
35 CHECK(name == "foo.txt");
36 CHECK(dirent.getPath() == "C:\\Projects\\foo.txt");
37 }
38
39 SUBCASE("Directory name with trailing backslash") {
40 PlpDirent dirent(0, 0, 0, 0, "C:\\Projects\\", "foo.txt");
41 CHECK(dirent.isDirectory() == false);
42 std::string name = dirent.getName();
43 CHECK(name == "foo.txt");
44 CHECK(dirent.getPath() == "C:\\Projects\\foo.txt");
45 }
46
47 SUBCASE("Empty directory name") {
48 PlpDirent dirent(0, 0, 0, 0, "", "foo.txt");
49 CHECK(dirent.isDirectory() == false);
50 std::string name = dirent.getName();
51 CHECK(name == "foo.txt");
52 CHECK(dirent.getPath() == "foo.txt");
53 }
54
55 SUBCASE("Directory dirent must have trailing backslash") {
56 PlpDirent dirent(0, RFSV::PSI_A_DIR, 0, 0, "M:\\", "FOO");
57 CHECK(dirent.isDirectory() == true);
58 std::string name = dirent.getName();
59 CHECK(name == "FOO");
60 CHECK(dirent.getPath() == "M:\\FOO\\");
61 }
62
63}
A class, representing a directory entry of the Psion.
Definition: plpdirent.h:79
std::string getPath() const
Definition: plpdirent.cc:93
const char * getName() const
Retrieve the file name of a directory entry.
Definition: plpdirent.cc:102
bool isDirectory() const
Determine if the directory entry represents a directory.
Definition: plpdirent.cc:79
@ PSI_A_DIR
Definition: rfsv.h:202
#define SUBCASE(name)
Definition: doctest.h:2946
#define CHECK(...)
Definition: doctest.h:2970
#define TEST_CASE(name)
Definition: doctest.h:2937