<commit_before>/*****************************************************************************************
 *                                                                                       *
 * OpenSpace                                                                             *
 *                                                                                       *
 * Copyright (c) 2014-2016                                                               *
 *                                                                                       *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this  *
 * software and associated documentation files (the "Software"), to deal in the Software *
 * without restriction, including without limitation the rights to use, copy, modify,    *
 * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to    *
 * permit persons to whom the Software is furnished to do so, subject to the following   *
 * conditions:                                                                           *
 *                                                                                       *
 * The above copyright notice and this permission notice shall be included in all copies *
 * or substantial portions of the Software.                                              *
 *                                                                                       *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,   *
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A         *
 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT    *
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF  *
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE  *
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                                         *
 ****************************************************************************************/

#include "gtest/gtest.h"

#include <openspace/util/documentation.h>

#include <ghoul/misc/dictionary.h>

#include <string>

class DocumentationTest : public testing::Test {};

TEST_F(DocumentationTest, Constructor) {
    using namespace openspace::documentation;

    Documentation doc;

    // Basic Verifiers
    doc.emplace_back("BoolVerifier", new BoolVerifier);
    doc.emplace_back("DoubleVerifier", new DoubleVerifier);
    doc.emplace_back("IntVerifier", new IntVerifier);
    doc.emplace_back("StringVerifier", new StringVerifier);
    doc.emplace_back("TableVerifier", new TableVerifier);

    // Operator Verifiers
    doc.emplace_back("LessDouble", new DoubleLessVerifier(0.0));
    doc.emplace_back("LessInt", new IntLessVerifier(0));

    doc.emplace_back("LessEqualDouble", new DoubleLessEqualVerifier(0.0));
    doc.emplace_back("LessEqualInt", new IntLessEqualVerifier(0));

    doc.emplace_back("GreaterDouble", new DoubleGreaterVerifier(0.0));
    doc.emplace_back("GreaterInt", new IntGreaterVerifier(0));

    doc.emplace_back("GreaterEqualDouble", new DoubleGreaterEqualVerifier(0.0));
    doc.emplace_back("GreaterEqualInt", new IntGreaterEqualVerifier(0));

    doc.emplace_back("EqualBool", new BoolEqualVerifier(false));
    doc.emplace_back("EqualDouble", new DoubleEqualVerifier(0.0));
    doc.emplace_back("EqualInt", new IntEqualVerifier(0));
    doc.emplace_back("EqualString", new StringEqualVerifier(""));

    doc.emplace_back("UnequalBool", new BoolUnequalVerifier(false));
    doc.emplace_back("UnequalDouble", new DoubleUnequalVerifier(0.0));
    doc.emplace_back("UnequalInt", new IntUnequalVerifier(0));
    doc.emplace_back("UnequalString", new StringUnequalVerifier(""));

    // List Verifiers
    doc.emplace_back("InListBool", new BoolInListVerifier({ true, false }));
    doc.emplace_back("InListDouble", new DoubleInListVerifier({ 0.0, 1.0}));
    doc.emplace_back("InListInt", new IntInListVerifier({ 0, 1 }));
    doc.emplace_back("InListString", new StringInListVerifier({ "", "a" }));

    doc.emplace_back("NotInListBool", new BoolNotInListVerifier({ true, false }));
    doc.emplace_back("NotInListDouble", new DoubleNotInListVerifier({ 0.0, 1.0 }));
    doc.emplace_back("NotInListInt", new IntNotInListVerifier({ 0, 1 }));
    doc.emplace_back("NotInListString", new StringNotInListVerifier({ "", "a" }));

    // Range Verifiers
    doc.emplace_back("InListDouble", new DoubleInRangeVerifier({ 0.0, 1.0 }));
    doc.emplace_back("InListInt", new IntInRangeVerifier({ 0, 1 }));

    doc.emplace_back("NotInListDouble", new DoubleNotInRangeVerifier({ 0.0, 1.0 }));
    doc.emplace_back("NotInListInt", new IntNotInRangeVerifier({ 0, 1 }));

    // Misc Verifiers
    doc.emplace_back("AnnotationBool", new BoolAnnotationVerifier("Bool"));
    doc.emplace_back("AnnotationDouble", new DoubleAnnotationVerifier("Double"));
    doc.emplace_back("AnnotationInt", new IntAnnotationVerifier("Int"));
    doc.emplace_back("AnnotationString", new StringAnnotationVerifier("String"));
    doc.emplace_back("AnnotationTable", new TableAnnotationVerifier("Table"));
}

TEST_F(DocumentationTest, InitializerConstructor) {
    using namespace openspace::documentation;
    
    Documentation doc{
        // Basic Verifiers
        {"BoolVerifier", new BoolVerifier },
        {"DoubleVerifier", new DoubleVerifier},
        {"IntVerifier", new IntVerifier},
        {"StringVerifier", new StringVerifier},
        {"TableVerifier", new TableVerifier},

        // Operator Verifiers
        { "LessDouble", new DoubleLessVerifier(0.0)},
        { "LessInt", new IntLessVerifier(0)},

        {"LessEqualDouble", new DoubleLessEqualVerifier(0.0)},
        {"LessEqualInt", new IntLessEqualVerifier(0)},

        {"GreaterDouble", new DoubleGreaterVerifier(0.0)},
        {"GreaterInt", new IntGreaterVerifier(0)},

        {"GreaterEqualDouble", new DoubleGreaterEqualVerifier(0.0)},
        {"GreaterEqualInt", new IntGreaterEqualVerifier(0)},

        {"EqualBool", new BoolEqualVerifier(false)},
        {"EqualDouble", new DoubleEqualVerifier(0.0)},
        {"EqualInt", new IntEqualVerifier(0)},
        {"EqualString", new StringEqualVerifier("")},

        {"UnequalBool", new BoolUnequalVerifier(false)},
        {"UnequalDouble", new DoubleUnequalVerifier(0.0)},
        {"UnequalInt", new IntUnequalVerifier(0)},
        {"UnequalString", new StringUnequalVerifier("")},

        // List Verifiers
        {"InListBool", new BoolInListVerifier({ true, false })},
        {"InListDouble", new DoubleInListVerifier({ 0.0, 1.0 })},
        {"InListInt", new IntInListVerifier({ 0, 1 })},
        {"InListString", new StringInListVerifier({ "", "a" })},

        {"NotInListBool", new BoolNotInListVerifier({ true, false })},
        {"NotInListDouble", new DoubleNotInListVerifier({ 0.0, 1.0 })},
        {"NotInListInt", new IntNotInListVerifier({ 0, 1 })},
        {"NotInListString", new StringNotInListVerifier({ "", "a" })},

        // Range Verifiers
        {"InRangeDouble", new DoubleInRangeVerifier{{0.0, 1.0}},
        {"InRangeInt", new IntInRangeVerifier{{0, 1}},

        {"InRangeDouble", new DoubleNotInRangeVerifier{{ 0.0, 1.0 }},
        {"InRangeInt", new IntNotInRangeVerifier{{ 0, 1 }},<commit_msg>Fix compilation error in unit test<commit_after>/*****************************************************************************************
 *                                                                                       *
 * OpenSpace                                                                             *
 *                                                                                       *
 * Copyright (c) 2014-2016                                                               *
 *                                                                                       *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this  *
 * software and associated documentation files (the "Software"), to deal in the Software *
 * without restriction, including without limitation the rights to use, copy, modify,    *
 * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to    *
 * permit persons to whom the Software is furnished to do so, subject to the following   *
 * conditions:                                                                           *
 *                                                                                       *
 * The above copyright notice and this permission notice shall be included in all copies *
 * or substantial portions of the Software.                                              *
 *                                                                                       *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,   *
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A         *
 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT    *
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF  *
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE  *
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                                         *
 ****************************************************************************************/

#include "gtest/gtest.h"

#include <openspace/util/documentation.h>

#include <ghoul/misc/dictionary.h>

#include <string>

class DocumentationTest : public testing::Test {};

TEST_F(DocumentationTest, Constructor) {
    using namespace openspace::documentation;

    Documentation doc;

    // Basic Verifiers
    doc.emplace_back("BoolVerifier", new BoolVerifier);
    doc.emplace_back("DoubleVerifier", new DoubleVerifier);
    doc.emplace_back("IntVerifier", new IntVerifier);
    doc.emplace_back("StringVerifier", new StringVerifier);
    doc.emplace_back("TableVerifier", new TableVerifier);

    // Operator Verifiers
    doc.emplace_back("LessDouble", new DoubleLessVerifier(0.0));
    doc.emplace_back("LessInt", new IntLessVerifier(0));

    doc.emplace_back("LessEqualDouble", new DoubleLessEqualVerifier(0.0));
    doc.emplace_back("LessEqualInt", new IntLessEqualVerifier(0));

    doc.emplace_back("GreaterDouble", new DoubleGreaterVerifier(0.0));
    doc.emplace_back("GreaterInt", new IntGreaterVerifier(0));

    doc.emplace_back("GreaterEqualDouble", new DoubleGreaterEqualVerifier(0.0));
    doc.emplace_back("GreaterEqualInt", new IntGreaterEqualVerifier(0));

    doc.emplace_back("EqualBool", new BoolEqualVerifier(false));
    doc.emplace_back("EqualDouble", new DoubleEqualVerifier(0.0));
    doc.emplace_back("EqualInt", new IntEqualVerifier(0));
    doc.emplace_back("EqualString", new StringEqualVerifier(""));

    doc.emplace_back("UnequalBool", new BoolUnequalVerifier(false));
    doc.emplace_back("UnequalDouble", new DoubleUnequalVerifier(0.0));
    doc.emplace_back("UnequalInt", new IntUnequalVerifier(0));
    doc.emplace_back("UnequalString", new StringUnequalVerifier(""));

    // List Verifiers
    doc.emplace_back("InListBool", new BoolInListVerifier({ true, false }));
    doc.emplace_back("InListDouble", new DoubleInListVerifier({ 0.0, 1.0}));
    doc.emplace_back("InListInt", new IntInListVerifier({ 0, 1 }));
    doc.emplace_back("InListString", new StringInListVerifier({ "", "a" }));

    doc.emplace_back("NotInListBool", new BoolNotInListVerifier({ true, false }));
    doc.emplace_back("NotInListDouble", new DoubleNotInListVerifier({ 0.0, 1.0 }));
    doc.emplace_back("NotInListInt", new IntNotInListVerifier({ 0, 1 }));
    doc.emplace_back("NotInListString", new StringNotInListVerifier({ "", "a" }));

    // Range Verifiers
    doc.emplace_back("InListDouble", new DoubleInRangeVerifier({ 0.0, 1.0 }));
    doc.emplace_back("InListInt", new IntInRangeVerifier({ 0, 1 }));

    doc.emplace_back("NotInListDouble", new DoubleNotInRangeVerifier({ 0.0, 1.0 }));
    doc.emplace_back("NotInListInt", new IntNotInRangeVerifier({ 0, 1 }));

    // Misc Verifiers
    doc.emplace_back("AnnotationBool", new BoolAnnotationVerifier("Bool"));
    doc.emplace_back("AnnotationDouble", new DoubleAnnotationVerifier("Double"));
    doc.emplace_back("AnnotationInt", new IntAnnotationVerifier("Int"));
    doc.emplace_back("AnnotationString", new StringAnnotationVerifier("String"));
    doc.emplace_back("AnnotationTable", new TableAnnotationVerifier("Table"));
}

TEST_F(DocumentationTest, InitializerConstructor) {
    using namespace openspace::documentation;
    
    Documentation doc{
        // Basic Verifiers
        {"BoolVerifier", new BoolVerifier },
        {"DoubleVerifier", new DoubleVerifier},
        {"IntVerifier", new IntVerifier},
        {"StringVerifier", new StringVerifier},
        {"TableVerifier", new TableVerifier},

        // Operator Verifiers
        { "LessDouble", new DoubleLessVerifier(0.0)},
        { "LessInt", new IntLessVerifier(0)},

        {"LessEqualDouble", new DoubleLessEqualVerifier(0.0)},
        {"LessEqualInt", new IntLessEqualVerifier(0)},

        {"GreaterDouble", new DoubleGreaterVerifier(0.0)},
        {"GreaterInt", new IntGreaterVerifier(0)},

        {"GreaterEqualDouble", new DoubleGreaterEqualVerifier(0.0)},
        {"GreaterEqualInt", new IntGreaterEqualVerifier(0)},

        {"EqualBool", new BoolEqualVerifier(false)},
        {"EqualDouble", new DoubleEqualVerifier(0.0)},
        {"EqualInt", new IntEqualVerifier(0)},
        {"EqualString", new StringEqualVerifier("")},

        {"UnequalBool", new BoolUnequalVerifier(false)},
        {"UnequalDouble", new DoubleUnequalVerifier(0.0)},
        {"UnequalInt", new IntUnequalVerifier(0)},
        {"UnequalString", new StringUnequalVerifier("")},

        // List Verifiers
        {"InListBool", new BoolInListVerifier({ true, false })},
        {"InListDouble", new DoubleInListVerifier({ 0.0, 1.0 })},
        {"InListInt", new IntInListVerifier({ 0, 1 })},
        {"InListString", new StringInListVerifier({ "", "a" })},

        {"NotInListBool", new BoolNotInListVerifier({ true, false })},
        {"NotInListDouble", new DoubleNotInListVerifier({ 0.0, 1.0 })},
        {"NotInListInt", new IntNotInListVerifier({ 0, 1 })},
        {"NotInListString", new StringNotInListVerifier({ "", "a" })},

        // Range Verifiers
        {"InRangeDouble", new DoubleInRangeVerifier(0.0, 1.0)},
        {"InRangeInt", new IntInRangeVerifier(0, 1)},

        {"InRangeDouble", new DoubleNotInRangeVerifier(0.0, 1.0)},
        {"InRangeInt", new IntNotInRangeVerifier(0, 1)},
{'fraction_non_alphanumeric': 0.1401964104300711, 'fraction_numerical': 0.012461903149339655, 'mean_word_length': 2.801750772399588, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 62, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6860621', 'n_tokens_mistral': 4036, 'n_tokens_neox': 3887, 'n_words': 935}