2020-06-26 18:01:27 +00:00
|
|
|
// This file is a part of toml++ and is subject to the the terms of the MIT license.
|
2021-01-02 15:48:47 +00:00
|
|
|
// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
|
2020-06-26 18:01:27 +00:00
|
|
|
// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2020-01-04 14:21:38 +00:00
|
|
|
#include "tests.h"
|
|
|
|
|
2020-02-03 09:12:43 +00:00
|
|
|
TEST_CASE("parsing - booleans")
|
2020-01-04 14:21:38 +00:00
|
|
|
{
|
2020-04-06 12:57:49 +00:00
|
|
|
parsing_should_succeed(
|
|
|
|
FILE_LINE_ARGS,
|
2020-06-28 22:57:59 +00:00
|
|
|
R"(
|
2020-06-08 15:31:23 +00:00
|
|
|
bool1 = true
|
|
|
|
bool2 = false
|
2020-06-28 22:57:59 +00:00
|
|
|
)"sv,
|
2020-04-18 13:14:07 +00:00
|
|
|
[](table&& tbl)
|
2020-01-04 14:21:38 +00:00
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
CHECK(tbl["bool1"] == true);
|
|
|
|
CHECK(tbl["bool2"] == false);
|
2020-01-04 14:21:38 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// "Always lowercase."
|
2020-06-28 22:57:59 +00:00
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "bool = True"sv);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "bool = TRUE"sv);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "bool = tRUE"sv);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "bool = False"sv);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "bool = FALSE"sv);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "bool = fALSE"sv);
|
2020-01-04 14:21:38 +00:00
|
|
|
|
|
|
|
// value tests
|
2020-04-06 12:57:49 +00:00
|
|
|
parse_expected_value(FILE_LINE_ARGS, " true", true);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, "false", false);
|
2020-01-04 14:21:38 +00:00
|
|
|
}
|