Blame tests/dictionary/enchant_dict_get_error_tests.cpp

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

Packit Service bc2325
#include <UnitTest++.h>
Packit Service bc2325
#include <enchant.h>
Packit Service bc2325
#include "EnchantDictionaryTestFixture.h"
Packit Service bc2325

Packit Service bc2325
/**
Packit Service bc2325
 * enchant_dict_get_error
Packit Service bc2325
 * @dict: A non-null dictionary
Packit Service bc2325
 *
Packit Service bc2325
 * Returns a const char string or NULL describing the last exception.
Packit Service bc2325
 * WARNING: error is transient. It will likely be cleared as soon as 
Packit Service bc2325
 * the next dictionary operation is called
Packit Service bc2325
 *
Packit Service bc2325
 * Returns: an error message
Packit Service bc2325
 */
Packit Service bc2325

Packit Service bc2325
/////////////////////////////////////////////////////////////////////////////
Packit Service bc2325
// Test Normal Operation
Packit Service bc2325

Packit Service bc2325
TEST_FIXTURE(EnchantDictionaryTestFixture, 
Packit Service bc2325
             EnchantDictionaryGetError_HasPreviousError_Error)
Packit Service bc2325
{
Packit Service bc2325
    std::string errorMessage("something bad happened");
Packit Service bc2325
    SetErrorOnMockDictionary(errorMessage);
Packit Service bc2325

Packit Service bc2325
    CHECK_EQUAL(errorMessage.c_str(), enchant_dict_get_error(_dict));
Packit Service bc2325
}
Packit Service bc2325

Packit Service bc2325
TEST_FIXTURE(EnchantDictionaryTestFixture, 
Packit Service bc2325
             EnchantDictionaryGetErrorOnPwl_HasPreviousError_Error)
Packit Service bc2325
{
Packit Service bc2325
    std::string errorMessage("something bad happened");
Packit Service bc2325
    enchant_dict_set_error(_pwl, errorMessage.c_str());
Packit Service bc2325

Packit Service bc2325

Packit Service bc2325
    CHECK_EQUAL(errorMessage.c_str(), enchant_dict_get_error(_pwl));
Packit Service bc2325
}
Packit Service bc2325

Packit Service bc2325
TEST_FIXTURE(EnchantDictionaryTestFixture, 
Packit Service bc2325
             EnchantDictionaryGetError_NoPreviousError_Null)
Packit Service bc2325
{
Packit Service bc2325
    CHECK_EQUAL((void*)NULL, (void*)enchant_dict_get_error(_dict));
Packit Service bc2325
}
Packit Service bc2325

Packit Service bc2325
/////////////////////////////////////////////////////////////////////////////
Packit Service bc2325
// Test Error Conditions
Packit Service bc2325
TEST(EnchantDictionaryGetError_NullBroker_Null)
Packit Service bc2325
{
Packit Service bc2325
    CHECK_EQUAL((void*)NULL, (void*)enchant_dict_get_error(NULL));
Packit Service bc2325
}