diff options
| author | Tom Harley | 2019-01-27 15:37:06 +0000 |
|---|---|---|
| committer | Tom Harley | 2019-01-27 15:37:06 +0000 |
| commit | a996283af7c21baaff0e114d58c34db820902c6f (patch) | |
| tree | 2fe5b6f7a800d4a7b8a65ee345f8c98aa138e36b /src/test/unit_tests/deal_parser_test.cpp | |
| parent | Split code into 3 files (diff) | |
| download | metasol-a996283af7c21baaff0e114d58c34db820902c6f.tar.gz metasol-a996283af7c21baaff0e114d58c34db820902c6f.zip | |
Reorganise repo
All solvitaire content has been shoved into a subdirectory to tidy up the root of the project. This also means solvitaire is treated similarly to other dependencies of the project, and allows other dependencies to be added easily.
There’s also a lot of other work done here, such as usign a thread pool library to manage the running of the voters.
Diffstat (limited to 'src/test/unit_tests/deal_parser_test.cpp')
| -rw-r--r-- | src/test/unit_tests/deal_parser_test.cpp | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/src/test/unit_tests/deal_parser_test.cpp b/src/test/unit_tests/deal_parser_test.cpp deleted file mode 100644 index db2bd31..0000000 --- a/src/test/unit_tests/deal_parser_test.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// -// Created by thecharlesblake on 1/11/18. -// - -#include <gtest/gtest.h> - -#include "../../../lib/rapidjson/stringbuffer.h" -#include "../../../lib/rapidjson/document.h" - -#include "../../main/input-output/input/json-parsing/deal_parser.h" -#include "../../main/input-output/input/json-parsing/json_helper.h" - -using namespace std; -using namespace rapidjson; - -void run_deal_parser_test(bool, const char*); - -TEST(DealParser, SimpleTableauLetter) { - run_deal_parser_test(true, R"( -{ - "tableau piles": [ - ["AS"] - ] -} -)"); -} - -TEST(DealParser, SimpleTableauNumber) { - run_deal_parser_test(true, R"( -{ - "tableau piles": [ - ["1S"] - ] -} -)"); -} - -TEST(DealParser, IllegalTableauNumber) { - run_deal_parser_test(false, R"( -{ - "tableau piles": [ - ["14S"] - ] -} -)"); -} - -TEST(DealParser, IllegalTableauSuit) { - run_deal_parser_test(false, R"( -{ - "tableau piles": [ - ["14A"] - ] -} -)"); -} - -TEST(DealParser, SimpleTableauCase) { - run_deal_parser_test(true, R"( -{ - "tableau piles": [ - ["kc"] - ] -} -)"); -} - -TEST(DealParser, AdvancedTableau) { - run_deal_parser_test(true, R"( -{ - "tableau piles": [ - ["5S","13C","4C","3C","2S","2c"], - ["5D","qD","3S","1d","2D"], - ["5H","4S","JH","3h","2H"] - ] -} -)"); -} - -TEST(DealParser, Hole) { - run_deal_parser_test(true, R"( -{ - "tableau piles": [ - ["5S","13C","4C"] - ], - "hole": "qD" -} -)"); -} - -TEST(DealParser, Stock) { - run_deal_parser_test(true, R"( -{ - "tableau piles": [ - ["5S","13C","4C"] - ], - "stock": ["1S","JC","7H"] -} -)"); -} - -TEST(DealParser, Waste) { - run_deal_parser_test(true, R"( -{ - "tableau piles": [ - ["5S","13C","4C"] - ], - "waste": ["1S","JC","7H"] -} -)"); -} - -TEST(DealParser, IllegalPileType) { - run_deal_parser_test(false, R"( -{ - "tableau piles": [ - ["5S","13C","4C"] - ], - "other": ["1S","JC","7H"] -} -)"); -} - -void run_deal_parser_test(bool validity, const char* json) { - Document in_doc; - in_doc.Parse(json); - if (in_doc.HasParseError()) { - throw runtime_error("invalid json"); - } - - Document val_doc; - val_doc.Parse(deal_parser::deal_schema_json().c_str()); - SchemaDocument sd(val_doc); - SchemaValidator validator(sd); - bool acc = in_doc.Accept(validator); - if (acc) { - ASSERT_TRUE(validity == acc) << "JSON accepted when it should not have " - "been:\n" << json; - } else { - ASSERT_TRUE(validity == acc) << json_helper::schema_err_str(validator) - << "\n" << json; - } -} |
