file_dialog.tests.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <planet/sdl/file_dialog.hpp>

#include <felspar/test.hpp>


namespace {


    auto const suite = felspar::testsuite("sdl-file-dialog");


    auto const decode = suite.test(
            "first_selected_path",
            [](auto check) {

A nullptr list is SDL's way of reporting an error.

16
17
18
19
                check(planet::sdl::first_selected_path(nullptr).has_value())
                        == false;
            },
            [](auto check) {

A pointer to nullptr means the user chose nothing.

21
22
23
24
25
26
27
28
29
30
31
                char const *const cancelled[] = {nullptr};
                check(planet::sdl::first_selected_path(cancelled).has_value())
                        == false;
            },
            [](auto check) {
                char const *const chosen[] = {"project.bw-project", nullptr};
                auto const path = planet::sdl::first_selected_path(chosen);
                check(path.has_value()) == true;
                check(path.value().string()) == "project.bw-project";
            },
            [](auto check) {

Only the first entry is taken for a single-select dialog.

33
34
35
36
37
38
39
                char const *const many[] = {"first", "second", nullptr};
                check(planet::sdl::first_selected_path(many).value().string())
                        == "first";
            });


}