1 /******************************************************************************
2 * Copyright (c) 2016, Hobu Inc. (info@hobu.co)
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following
8 * conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided
15 * with the distribution.
16 * * Neither the name of Hobu, Inc. nor the
17 * names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior
19 * written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 * OF SUCH DAMAGE.
33 ****************************************************************************/
34
35 #include <pdal/pdal_test_main.hpp>
36
37 #include <pdal/Kernel.hpp>
38
39 #include "Support.hpp"
40
41 namespace pdal
42 {
43
44 /**
45 class TestKernel : public Kernel
46 {
47 public:
48 virtual std::string getName()
49 { return "TestKernel"; }
50 int execute()
51 { return 0; }
52 bool test_parseStageOption(std::string o, std::string& stage,
53 std::string& option, std::string& value)
54 { return Kernel::parseStageOption(o, stage, option, value); }
55 }
56 **/
57
TEST(KernelTest,parseOption)58 TEST(KernelTest, parseOption)
59 {
60 std::string stage;
61 std::string option;
62 std::string value;
63 Kernel::ParseStageResult res;
64
65 res = Kernel::test_parseStageOption("--readers.p2g.foobar=baz",
66 stage, option, value);
67 EXPECT_EQ(res, Kernel::ParseStageResult::Ok);
68 EXPECT_EQ(stage, "readers.p2g");
69 EXPECT_EQ(option, "foobar");
70 EXPECT_EQ(value, "baz");
71
72 res = Kernel::test_parseStageOption("--readers.2pg.foobar=baz",
73 stage, option, value);
74 EXPECT_EQ(res, Kernel::ParseStageResult::Unknown);
75
76 res = Kernel::test_parseStageOption("--read1ers.las.foobar=baz",
77 stage, option, value);
78 EXPECT_EQ(res, Kernel::ParseStageResult::Unknown);
79
80 res = Kernel::test_parseStageOption("--readers.p2g.foobar",
81 stage, option, value);
82 EXPECT_EQ(res, Kernel::ParseStageResult::Ok);
83 EXPECT_EQ(value, "");
84
85 res = Kernel::test_parseStageOption("--readers.p2g.foobar=",
86 stage, option, value);
87 EXPECT_EQ(res, Kernel::ParseStageResult::Invalid);
88
89 res = Kernel::test_parseStageOption("--readers.p2g.foobar!",
90 stage, option, value);
91 EXPECT_EQ(res, Kernel::ParseStageResult::Invalid);
92 }
93
94 }
95