File: command_line_option.cpp

package info (click to toggle)
mir 2.20.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,636 kB
  • sloc: cpp: 174,574; xml: 13,422; ansic: 8,221; python: 1,337; sh: 874; makefile: 216; javascript: 37
file content (48 lines) | stat: -rw-r--r-- 1,876 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright © Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 or 3 as
 * published by the Free Software Foundation.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "miral/command_line_option.h"

#include <gtest/gtest.h>

using namespace miral;
using namespace testing;

TEST(CommandLineOption, can_take_lambdas)
{
    // ambiguous between all four possible 3-parameter overloads
    auto bool_flag = miral::ConfigurationOption(
        [](bool /*is_set*/) {}, "bool", "Set a boolean flag");

    // ambiguous between `void(bool)`, `void(mir::optional_value<bool> const&)`
    // and `void(mir::optional_value<int> const&)`
    auto optional_bool_flag = miral::ConfigurationOption(
        [](mir::optional_value<bool> const& /*value*/) {}, "optional-bool", "Set an optional boolean flag");

    // ambiguous between `void(bool)` vs. `void(mir::optional_value<int> const&)`
    auto optional_int_flag = miral::ConfigurationOption(
        [](mir::optional_value<int> const& /*value*/) {}, "optional-int", "Set an optional int flag");

    // works
    auto optional_string_flag = miral::ConfigurationOption(
        [](mir::optional_value<std::string> const& /*value*/) {}, "optional-string", "Set an optional string flag");
}

TEST(CommandLineOption, can_take_repeated_strings)
{
    auto foo = miral::ConfigurationOption(
        [](std::vector<std::string> const&) {}, "option", "can be repeated");
}