test_constraint.cpp 2.4 KB
Newer Older
W
wangguibao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
#include <stdlib.h>
#include <Configure.h>
#include <gtest/gtest.h>
	
	
int main(int argc, char **argv)
{
 	testing::InitGoogleTest(&argc, argv);
	return RUN_ALL_TESTS();
}
/**
 * @brief 
**/
class test_load_ex2_suite : public ::testing::Test{
    protected:
        test_load_ex2_suite(){};
        virtual ~test_load_ex2_suite(){};
        virtual void SetUp() {
            //Called befor every TEST_F(test_load_ex_suite, *)
        };
        virtual void TearDown() {
            //Called after every TEST_F(test_load_ex_suite, *)
        };
};


/**
 * @brief check null param 
 * @begin_version
 **/
TEST_F(test_load_ex2_suite, case_nullParam)
{
	//TODO
	comcfg::Configure conf[3];
	int ret = conf[0].load_ex2("conf/", "ill_cons.conf", NULL);
	ASSERT_EQ(0, ret);
	ret = conf[1].load_ex2("conf/", "ill_cons.conf", "");
	ASSERT_EQ(0, ret);
	ret = conf[2].load_ex2("conf/", "ill_cons.conf");
	ASSERT_EQ(0, ret);
}

/**
 * @brief check regular range file 
 * @begin_version
 **/
TEST_F(test_load_ex2_suite, case_reg_conf)
{
	//TODO
	comcfg::Configure conf;
	int ret = conf.load_ex2("conf/", "reg_cons.conf", "cons.range");
	ASSERT_EQ(0, ret);
}
  
/**
 * @brief check illegal range file 
 * @begin_version
 **/
TEST_F(test_load_ex2_suite, case_ill_conf)
{
	//TODO
	comcfg::Configure conf;
	int ret = conf.load_ex2("conf/", "ill_cons.conf", "cons.range");
	ASSERT_NE(0, ret);
}
  
/**
 * @brief check load()+checkConstraint()
 * @begin_version
 **/
TEST_F(test_load_ex2_suite, case_load_check_conf)
{
	//TODO
	comcfg::Configure conf;
	int ret = conf.load("conf/", "ill_cons.conf", "cons.range");
	ASSERT_EQ(0, ret);
	ret = conf.checkConstraint();
	ASSERT_NE(0, ret);
}
  
/**
 * @brief check load_ex()+checkConstraint()
 * @begin_version
 **/
TEST_F(test_load_ex2_suite, case_load_ex_check_conf)
{
	//TODO
	comcfg::Configure conf;
	int ret = conf.load_ex("conf/", "ill_cons.conf", "cons.range");
	ASSERT_EQ(0, ret);
	ret = conf.checkConstraint();
	ASSERT_NE(0, ret);
}
  
/**
 * @brief check reentrant check_once()
 * @begin_version
 **/
TEST_F(test_load_ex2_suite, case_reentrant_check_once)
{
	//TODO
	comcfg::Configure conf;
	int ret = conf.load("conf/", "reg_cons.conf"); 
	ASSERT_EQ(0, ret);
	for(int i=1; i<5; i++){
		ret = conf.check_once("conf/cons.range");
		ASSERT_EQ(0, ret);
		ret = conf.checkConstraint();
		ASSERT_EQ(0, ret);

		ret = conf.check_once("conf/bad_cons.range");
		ASSERT_EQ(0, ret);
		ret = conf.checkConstraint();
		ASSERT_NE(0, ret);
	}
}