Sha256: 4371a33acfbad2c17541ccbae8c727355ab1c02a54112375f95dd68757fc07f0

Contents?: true

Size: 1.97 KB

Versions: 35

Compression:

Stored size: 1.97 KB

Contents

/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
 *     Copyright 2010-2012 Couchbase, Inc.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
#include "config.h"
#include <gtest/gtest.h>
#define LIBCOUCHBASE_INTERNAL 1
#include <libcouchbase/couchbase.h>

class Strerror : public ::testing::Test
{
};

TEST_F(Strerror, testNoCrash)
{
    for (int ii = -10; ii < 0xffff; ++ii) {
        EXPECT_NE((const char *)NULL,
                  lcb_strerror(NULL, (lcb_error_t)ii));
    }
}

TEST_F(Strerror, allCodesDocumented)
{
    const char *generic = lcb_strerror(NULL, (lcb_error_t)( LCB_MAX_ERROR -1));
    ASSERT_NE((const char *)NULL, generic);
    for (int ii = 0; ii < LCB_MAX_ERROR_VAL; ++ii) {
        EXPECT_STRNE(generic,
                     lcb_strerror(NULL, (lcb_error_t)ii));
    }

    for (int ii = LCB_MAX_ERROR_VAL; ii < LCB_MAX_ERROR; ++ii) {
        EXPECT_STREQ(generic,
                     lcb_strerror(NULL, (lcb_error_t)ii));
    }

}

TEST_F(Strerror, testErrTypes)
{
    for (int ii = 0; ii < LCB_MAX_ERROR_VAL; ii++) {
        lcb_error_t err = (lcb_error_t)ii;
        ASSERT_NE(-1, LCB_EIFDATA(err));
        ASSERT_NE(-1, LCB_EIFFATAL(err));
        ASSERT_NE(-1, LCB_EIFINPUT(err));
        ASSERT_NE(-1, LCB_EIFNET(err));
        ASSERT_NE(-1, LCB_EIFPLUGIN(err));
        ASSERT_NE(-1, LCB_EIFTMP(err));
    }

    ASSERT_EQ(-1, lcb_get_errtype(LCB_MAX_ERROR_VAL));
    ASSERT_EQ(-1, lcb_get_errtype((lcb_error_t)-1));
}

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
mt-libcouchbase-1.4.03 ext/libcouchbase/tests/basic/t_strerror.cc
mt-libcouchbase-1.4.02 ext/libcouchbase/tests/basic/t_strerror.cc
mt-libcouchbase-1.4.01 ext/libcouchbase/tests/basic/t_strerror.cc
mt-libcouchbase-1.4.0 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.3.2 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.3.0 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.2.8 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.2.7 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.2.6 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.2.5 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.2.4 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.2.3 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.2.2 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.2.1 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.2.0 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.1.1 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.1.0 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.0.4 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.0.3 ext/libcouchbase/tests/basic/t_strerror.cc
libcouchbase-1.0.2 ext/libcouchbase/tests/basic/t_strerror.cc