| 1 | /* |
| 2 | * Copyright (C) 2018 Edward d'Auvergne |
| 3 | * |
| 4 | * This file is part of the program FlightGear. |
| 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 |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | #pragma once |
| 22 | |
| 23 | #include <cppunit/TestFixture.h> |
| 24 | #include <cppunit/extensions/HelperMacros.h> |
| 25 | |
| 26 | #include "test_suite/FGTestApi/testGlobals.hxx" |
| 27 | |
| 28 | #include "Main/options.hxx" |
| 29 | |
| 30 | // The system tests. |
| 31 | class OptionsTests : public CppUnit::TestFixture |
| 32 | { |
| 33 | // Set up the test suite. |
| 34 | CPPUNIT_TEST_SUITE(OptionsTests); |
| 35 | CPPUNIT_TEST(testLoadDefaultAircraft); |
| 36 | CPPUNIT_TEST(testOptionAircraftWithAircraftDir); |
| 37 | CPPUNIT_TEST(testOptionAircraftUnqualified); |
| 38 | CPPUNIT_TEST(testOptionAircraftFullyQualified); |
| 39 | CPPUNIT_TEST(testOptionAircraftWithFGAircraft); |
| 40 | |
| 41 | CPPUNIT_TEST(testDisableSound); |
| 42 | CPPUNIT_TEST(testDisableSoundByFalseWithSpaceSeparator); |
| 43 | CPPUNIT_TEST(testDisableSoundBy0WithSpaceSeparator); |
| 44 | CPPUNIT_TEST(testDisableSoundByNoWithSpaceSeparator); |
| 45 | CPPUNIT_TEST(testDisableSoundByFalseWithEqualSeparator); |
| 46 | CPPUNIT_TEST(testDisableSoundBy0WithEqualSeparator); |
| 47 | CPPUNIT_TEST(testDisableSoundByNoWithEqualSeparator); |
| 48 | |
| 49 | CPPUNIT_TEST(testEnableSound); |
| 50 | CPPUNIT_TEST(testEnableSoundWithoutValue); |
| 51 | CPPUNIT_TEST(testEnableSoundWithIncorrectValue); |
| 52 | CPPUNIT_TEST(testEnableSoundByTrueWithSpaceSeparator); |
| 53 | CPPUNIT_TEST(testEnableSoundBy1WithSpaceSeparator); |
| 54 | CPPUNIT_TEST(testEnableSoundByYesWithSpaceSeparator); |
| 55 | CPPUNIT_TEST(testEnableSoundWithoutValueWithSpaceSeparator); |
| 56 | CPPUNIT_TEST(testEnableSoundWithIncorrectValueWithEqualSeparator); |
| 57 | CPPUNIT_TEST(testEnableSoundByTrueWithEqualSeparator); |
| 58 | CPPUNIT_TEST(testEnableSoundBy1WithEqualSeparator); |
| 59 | CPPUNIT_TEST(testEnableSoundByYesWithEqualSeparator); |
| 60 | |
| 61 | CPPUNIT_TEST(testDisableFreeze); |
| 62 | CPPUNIT_TEST(testDisableFreezeByFalseWithSpaceSeparator); |
| 63 | CPPUNIT_TEST(testDisableFreezeBy0WithSpaceSeparator); |
| 64 | CPPUNIT_TEST(testDisableFreezeByNoWithSpaceSeparator); |
| 65 | CPPUNIT_TEST(testDisableFreezeByFalseWithEqualSeparator); |
| 66 | CPPUNIT_TEST(testDisableFreezeBy0WithEqualSeparator); |
| 67 | CPPUNIT_TEST(testDisableFreezeByNoWithEqualSeparator); |
| 68 | |
| 69 | CPPUNIT_TEST(testEnableFreeze); |
| 70 | CPPUNIT_TEST(testEnableFreezeWithoutValue); |
| 71 | CPPUNIT_TEST(testEnableFreezeWithIncorrectValue); |
| 72 | CPPUNIT_TEST(testEnableFreezeByTrueWithSpaceSeparator); |
| 73 | CPPUNIT_TEST(testEnableFreezeBy1WithSpaceSeparator); |
| 74 | CPPUNIT_TEST(testEnableFreezeByYesWithSpaceSeparator); |
| 75 | CPPUNIT_TEST(testEnableFreezeWithoutValueWithEqualSeparator); |
| 76 | CPPUNIT_TEST(testEnableFreezeWithIncorrectValueWithEqualSeparator); |
| 77 | CPPUNIT_TEST(testEnableFreezeByTrueWithEqualSeparator); |
| 78 | CPPUNIT_TEST(testEnableFreezeBy1WithEqualSeparator); |
| 79 | CPPUNIT_TEST(testEnableFreezeByYesWithEqualSeparator); |
| 80 | |
| 81 | CPPUNIT_TEST(testPropWithEqualSeparator); |
| 82 | CPPUNIT_TEST(testPropWithSpaceSeparator); |
| 83 | |
| 84 | CPPUNIT_TEST(testMetarWithEqualSeparator); |
| 85 | CPPUNIT_TEST(testMetarWithSpaceSeparator); |
| 86 | |
| 87 | CPPUNIT_TEST(testXmlFileBetweenOptions); |
| 88 | CPPUNIT_TEST(testGetArgValueWithSpaceSeparator); |
| 89 | CPPUNIT_TEST(testGetArgValueWithEqualSeparator); |
| 90 | CPPUNIT_TEST(testCheckForArgEnable); |
| 91 | CPPUNIT_TEST(testCheckForArgEnableByTrueWithSpaceSeparator); |
| 92 | CPPUNIT_TEST(testCheckForArgEnableByTrueWithEqualSeparator); |
| 93 | CPPUNIT_TEST(testCheckForArgDisableByFalseWithSpaceSeparator); |
| 94 | CPPUNIT_TEST(testCheckForArgDisableByFalseWithEqualSeparator); |
| 95 | CPPUNIT_TEST(testCheckForArgDisableMissingOption); |
| 96 | CPPUNIT_TEST(testCheckForArgEnableMissingOption); |
| 97 | |
| 98 | CPPUNIT_TEST(testIsBoolOptionEnable); |
| 99 | CPPUNIT_TEST(testIsBoolOptionEnableWithoutValue); |
| 100 | CPPUNIT_TEST(testIsBoolOptionEnableWithIncorrectValue); |
| 101 | CPPUNIT_TEST(testIsBoolOptionEnableByTrueWithSpaceSeparator); |
| 102 | CPPUNIT_TEST(testIsBoolOptionEnableBy1WithSpaceSeparator); |
| 103 | CPPUNIT_TEST(testIsBoolOptionEnableByYesWithSpaceSeparator); |
| 104 | CPPUNIT_TEST(testIsBoolOptionEnableWithoutValueWithEqualSeparator); |
| 105 | CPPUNIT_TEST(testIsBoolOptionEnableWithIncorrectValueWithEqualSeparator); |
| 106 | CPPUNIT_TEST(testIsBoolOptionEnableByTrueWithEqualSeparator); |
| 107 | CPPUNIT_TEST(testIsBoolOptionEnableBy1WithEqualSeparator); |
| 108 | CPPUNIT_TEST(testIsBoolOptionEnableByYesWithEqualSeparator); |
| 109 | CPPUNIT_TEST(testIsBoolOptionEnableMissingOption); |
| 110 | |
| 111 | CPPUNIT_TEST(testIsBoolOptionDisable); |
| 112 | CPPUNIT_TEST(testIsBoolOptionDisableByFalseWithSpaceSeparator); |
| 113 | CPPUNIT_TEST(testIsBoolOptionDisableBy0WithSpaceSeparator); |
| 114 | CPPUNIT_TEST(testIsBoolOptionDisableByNoWithSpaceSeparator); |
| 115 | CPPUNIT_TEST(testIsBoolOptionDisableByFalseWithEqualSeparator); |
| 116 | CPPUNIT_TEST(testIsBoolOptionDisableBy0WithEqualSeparator); |
| 117 | CPPUNIT_TEST(testIsBoolOptionDisableByNoWithEqualSeparator); |
| 118 | CPPUNIT_TEST(testIsBoolOptionDisableMissingOption); |
| 119 | |
| 120 | CPPUNIT_TEST_SUITE_END(); |
| 121 | |
| 122 | flightgear::Options* runProcessOptions(const char* argv[]); |
| 123 | int getElementsNumber(const char* argv[]); |
| 124 | |
| 125 | public: |
| 126 | // Set up function for each test. |
| 127 | void setUp(); |
| 128 | |
| 129 | // Clean up after each test. |
| 130 | void tearDown(); |
| 131 | |
| 132 | // The tests. |
| 133 | void testOptionAircraftWithAircraftDir(); |
| 134 | void testOptionAircraftUnqualified(); |
| 135 | void testOptionAircraftFullyQualified(); |
| 136 | void testOptionAircraftWithFGAircraft(); |
| 137 | void testLoadDefaultAircraft(); |
| 138 | |
| 139 | void testDisableSound(); |
| 140 | void testDisableSoundByFalseWithSpaceSeparator(); |
| 141 | void testDisableSoundBy0WithSpaceSeparator(); |
| 142 | void testDisableSoundByNoWithSpaceSeparator(); |
| 143 | void testDisableSoundByFalseWithEqualSeparator(); |
| 144 | void testDisableSoundBy0WithEqualSeparator(); |
| 145 | void testDisableSoundByNoWithEqualSeparator(); |
| 146 | |
| 147 | void testEnableSound(); |
| 148 | void testEnableSoundWithoutValue(); |
| 149 | void testEnableSoundWithIncorrectValue(); |
| 150 | void testEnableSoundByTrueWithSpaceSeparator(); |
| 151 | void testEnableSoundBy1WithSpaceSeparator(); |
| 152 | void testEnableSoundByYesWithSpaceSeparator(); |
| 153 | void testEnableSoundWithoutValueWithSpaceSeparator(); |
| 154 | void testEnableSoundWithIncorrectValueWithEqualSeparator(); |
| 155 | void testEnableSoundByTrueWithEqualSeparator(); |
| 156 | void testEnableSoundBy1WithEqualSeparator(); |
| 157 | void testEnableSoundByYesWithEqualSeparator(); |
| 158 | |
| 159 | void testDisableFreeze(); |
| 160 | void testDisableFreezeByFalseWithSpaceSeparator(); |
| 161 | void testDisableFreezeBy0WithSpaceSeparator(); |
| 162 | void testDisableFreezeByNoWithSpaceSeparator(); |
| 163 | void testDisableFreezeByFalseWithEqualSeparator(); |
| 164 | void testDisableFreezeBy0WithEqualSeparator(); |
| 165 | void testDisableFreezeByNoWithEqualSeparator(); |
| 166 | |
| 167 | void testEnableFreeze(); |
| 168 | void testEnableFreezeWithoutValue(); |
| 169 | void testEnableFreezeWithIncorrectValue(); |
| 170 | void testEnableFreezeByTrueWithSpaceSeparator(); |
| 171 | void testEnableFreezeBy1WithSpaceSeparator(); |
| 172 | void testEnableFreezeByYesWithSpaceSeparator(); |
| 173 | void testEnableFreezeWithoutValueWithEqualSeparator(); |
| 174 | void testEnableFreezeWithIncorrectValueWithEqualSeparator(); |
| 175 | void testEnableFreezeByTrueWithEqualSeparator(); |
| 176 | void testEnableFreezeBy1WithEqualSeparator(); |
| 177 | void testEnableFreezeByYesWithEqualSeparator(); |
| 178 | |
| 179 | void testPropWithEqualSeparator(); |
| 180 | void testPropWithSpaceSeparator(); |
| 181 | |
| 182 | void testMetarWithEqualSeparator(); |
| 183 | void testMetarWithSpaceSeparator(); |
| 184 | |
| 185 | void testXmlFileBetweenOptions(); |
| 186 | void testGetArgValueWithSpaceSeparator(); |
| 187 | void testGetArgValueWithEqualSeparator(); |
| 188 | |
| 189 | void testCheckForArgEnable(); |
| 190 | void testCheckForArgEnableByTrueWithSpaceSeparator(); |
| 191 | void testCheckForArgEnableByTrueWithEqualSeparator(); |
| 192 | void testCheckForArgEnableMissingOption(); |
| 193 | |
| 194 | void testCheckForArgDisableByFalseWithSpaceSeparator(); |
| 195 | void testCheckForArgDisableByFalseWithEqualSeparator(); |
| 196 | void testCheckForArgDisableMissingOption(); |
| 197 | |
| 198 | void testIsBoolOptionEnable(); |
| 199 | void testIsBoolOptionEnableWithoutValue(); |
| 200 | void testIsBoolOptionEnableWithIncorrectValue(); |
| 201 | void testIsBoolOptionEnableByTrueWithSpaceSeparator(); |
| 202 | void testIsBoolOptionEnableBy1WithSpaceSeparator(); |
| 203 | void testIsBoolOptionEnableByYesWithSpaceSeparator(); |
| 204 | void testIsBoolOptionEnableWithoutValueWithEqualSeparator(); |
| 205 | void testIsBoolOptionEnableWithIncorrectValueWithEqualSeparator(); |
| 206 | void testIsBoolOptionEnableByTrueWithEqualSeparator(); |
| 207 | void testIsBoolOptionEnableBy1WithEqualSeparator(); |
| 208 | void testIsBoolOptionEnableByYesWithEqualSeparator(); |
| 209 | void testIsBoolOptionEnableMissingOption(); |
| 210 | |
| 211 | void testIsBoolOptionDisable(); |
| 212 | void testIsBoolOptionDisableByFalseWithSpaceSeparator(); |
| 213 | void testIsBoolOptionDisableBy0WithSpaceSeparator(); |
| 214 | void testIsBoolOptionDisableByNoWithSpaceSeparator(); |
| 215 | void testIsBoolOptionDisableByFalseWithEqualSeparator(); |
| 216 | void testIsBoolOptionDisableBy0WithEqualSeparator(); |
| 217 | void testIsBoolOptionDisableByNoWithEqualSeparator(); |
| 218 | void testIsBoolOptionDisableMissingOption(); |
| 219 | }; |