Exemple #1
0
void
testfn_t::run()
{
    if (before_)
        before_->run();
    if (role_ == RTEST)
    {
        if (testrunner_t::current_->verbose_)
            fprintf(stderr, "Test %s:%s\n", suite(), name_);
        function_();
    }
    else
    {
        int (*fixture)(void) = (int(*)(void))function_;
        if (testrunner_t::current_->verbose_)
            fprintf(stderr, "Fixture %s:%s\n", suite(), name_);
        if (fixture())
        {
            fprintf(stderr, "%s:%s: fixture failed\n", suite(), name_);
            exit(1);
        }
    }
    if (after_)
        after_->run();
}
Exemple #2
0
int main (int argc, char ** argv)
{
  size_t nfail;
  nfail = 0;
  
  fprintf (stderr, "\nlet's try max heap first...\n\n");
  if (0 != suite (maxheap_create)) {
    ++nfail;
  }
  
  fprintf (stderr, "\nand how about min heap?\n\n");
  if (0 != suite (minheap_create)) {
    ++nfail;
  }
  
  if (nfail == 1) {
    fprintf (stderr, "\nOOPS there was a failure\n");
    return 1;
  }
  else if (nfail != 0) {
    fprintf (stderr, "\nOOPS there were %zu failures\n", nfail);
    return 1;
  }
  
  fprintf (stderr, "\nall tests passed\n");
  return 0;
}
void combinatorics_test() {
    suite("SubsetBacktrackSearch");
    mytest(subset_backtrack_search);

    suite("PermutationBacktrackSearch");
    mytest(permutation_backtrack_search);
//
    //suite("Generate symbols");
    //mytest(generate_symbols);
}
Exemple #4
0
void MergeTests(const char* name)
{
    UnitTestSuite suite(name);

    AddTestCase<TEST_ID(N), 
        MergingAll, Reader, Writer, NestedStructView, NestedStruct>(suite, "Merging nested struct");

    AddTestCase<TEST_ID(N), 
        MergingInitialized, Reader, Writer, NestedStructBondedView, NestedStruct>(suite, "Merging bonded nested struct");

    AddTestCase<TEST_ID(N), 
        MergingAll, Reader, Writer, NestedWithBaseView, NestedWithBase>(suite, "Merging struct with base");

    AddTestCase<TEST_ID(N), 
        MergingAll, Reader, Writer, SimpleListsStructView, SimpleListsStruct>(suite, "Merging simple containers");

    AddTestCase<TEST_ID(N), 
        MergingAll, Reader, Writer, NestedListsStructBondedViewView, NestedListsStructBondedView>(suite, "Merging bonded containers");

    AddTestCase<TEST_ID(N), 
        MergingContainers, Reader, Writer, NestedListsStruct, NestedListsView>(suite, "Merging struct lists");

    AddTestCase<TEST_ID(N), 
        MergingContainers, Reader, Writer, NestedMaps, NestedMapsView>(suite, "Merging struct maps");
}
Exemple #5
0
void test_pool(Test_Platform& platform)
{
	Test_Suite suite("pool", platform);

	Test_Node_Pool test;
	suite.run("node pool", test);
}
Exemple #6
0
/** The main function. */
int main()
{
	litest::TestSuite suite("LiTest demonstration");
	
	LT_ADD_TEST(suite, "Tests that pass",
	{
		std::vector<int> vec;
		
		// Assert that an expression evaluates to true:
		LT_CHECK(vec.empty());
		
		// Add a message to test output:
		LT_MESSAGE("Adding an element to the vector");
		
		vec.push_back(42);
		vec.push_back(56);
		
		// Assert equality of two expressions:
		LT_EQUAL(vec.size(), 2);
		
		// Assert that an expression throws:
		LT_THROWS(throw "Bad code");
		
		// Assert that an expression throws a certain type:
		LT_EXCEPT(vec.at(5), std::out_of_range);
		
		// Print the value of an expression
		LT_PRINT_EXPR(vec);
	});
Exemple #7
0
void MayOmitFieldsTests(const char* name)
{
    UnitTestSuite suite(name);

    AddTestCase<TEST_ID(N), 
        DontOmit, Reader, Writer, BondStructOptional<uint64_t>, BondStructRequired<uint64_t> >(suite, "Don't omit optional fields");
};
Exemple #8
0
void test_scoped(Test_Platform& platform)
{
	Test_Suite suite("scoped", platform);

	Test_Scoped test_scoped;
	suite.run("scoped", test_scoped);
}
    //
    // Some compilers get confused by these functions if they're inline
    //
    bool RealTestDescription::setUp()
    {
        if ( !suite() )
            return false;

        bool ok = true;

        for ( GlobalFixture *gf = GlobalFixture::firstGlobalFixture();
	      gf != 0; gf = gf->nextGlobalFixture() )
	{
            _TS_TRY_WITH_SIGNAL_PROTECTION
            {
                _TS_TRY
                {
                  ok = gf->setUp();
                }
                _TS_LAST_CATCH( {
		    tracker().failedTest( file(), line(),
		        "Exception thrown from GlobalFixture::setUp()" );
		    ok = false;
		} );
            }
            _TS_CATCH_SIGNAL({
                tracker().failedTest( file(), line(),
		    __cxxtest_sigmsg.c_str() );
                ok = false;
            });
Exemple #10
0
void	flags(char *str, DIR *directory, char *ahmed)
{
	if (!verif(str))
		return ;
	if (ft_strchr(str, 'a') && ft_strchr(str, 'l') && ft_strchr(str, 't') && ft_strchr(str, 'r'))
		fn_list(directory, ahmed, 0);
	else if (ft_strchr(str, '1') && ft_strchr(str, 'a') && ft_strchr(str, 'r') && ft_strchr(str, 't'))
		lister(directory, ahmed, 1);
	else if (ft_strchr(str, 'l') && ft_strchr(str, 'r') && ft_strchr(str, 't'))
		fn_list(directory, ahmed, 2);
	else if (ft_strchr(str, 'a') && ft_strchr(str, 'l') && ft_strchr(str, 't'))
		fn_list(directory, ahmed, 3);
	else if (ft_strchr(str, 'a') && ft_strchr(str, 'l') && ft_strchr(str, 'r'))
		fn_list(directory, ahmed, 4);
	else if (ft_strchr(str, '1') && ft_strchr(str, 'r') && ft_strchr(str, 't'))
		lister(directory, ahmed, 5);
	else if (ft_strchr(str, '1') && ft_strchr(str, 'a') && ft_strchr(str, 'r'))
		lister(directory, ahmed, 6);
	else if (ft_strchr(str, '1') && ft_strchr(str, 't') && ft_strchr(str, 'a'))
		lister(directory, ahmed, 7);
	else if (ft_strchr(str, 'r') && ft_strchr(str, 't'))
		lister(directory, ahmed, 8);
	else if (ft_strchr(str, 'l') && ft_strchr(str, 't'))
		fn_list(directory, ahmed, 9);
	suite(str, directory, ahmed);
}
int main()
{
  Suite * s = suite();
  SRunner * sr = srunner_create(s);
  srunner_run_all(sr, CK_NORMAL);
  int number_failed = srunner_ntests_failed(sr);
  srunner_free(sr);
  return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
Exemple #12
0
int main() {

    //Run unit tests
    CppUnit::TextUi::TestRunner runner;
    runner.addTest( suite() );   // Add the top suite to the test runner

    // Run the test.
    runner.run("");
}
Exemple #13
0
 void rMatrix_test() {
     suite("RMatrix");
     mytest(push_row);
     mytest(swap_rows);
     mytest(comparison);
     mytest(comparison_with_error);
     mytest(create_clone);
     mytest(copy_to);
     mytest(get_row);
 }
Exemple #14
0
void 
HelperMacrosTest::testException()
{
  std::auto_ptr<CPPUNIT_NS::TestSuite> suite( ExceptionTestFixture::suite() );
  m_testListener->setExpectedStartTestCall( 1 );
  m_testListener->setExpectNoFailure();
  
  suite->run( m_result );
  m_testListener->verify();
}
Exemple #15
0
void 
HelperMacrosTest::testAddTest()
{
  std::auto_ptr<CPPUNIT_NS::TestSuite> suite( AddTestTestFixture::suite() );
  m_testListener->setExpectedStartTestCall( 7 );
  m_testListener->setExpectedAddFailureCall( 0 );

  suite->run( m_result );
  m_testListener->verify();
}
Exemple #16
0
void SkipTests(const char* name)
{
    UnitTestSuite suite(name);

    AddTestCase<TEST_ID(N), 
        SkipMismatchedTypeTests, Reader, Writer, BasicTypes>(suite, "Basic types");

    AddTestCase<TEST_ID(N), 
        SkipMismatchedTypeTests, Reader, Writer, SkipTypes<double>::type>(suite, "Complex types");
}
Exemple #17
0
int main(void) {
    int numberFailed;
    Suite* s = suite();
    SRunner *sr = srunner_create(s);
    // Don't fork so we can actually use gdb
    srunner_set_fork_status(sr, CK_NOFORK);
    srunner_run_all(sr, CK_NORMAL);
    numberFailed = srunner_ntests_failed(sr);
    srunner_free(sr);
    return (numberFailed == 0) ? 0 : 1;
}
Exemple #18
0
void BondedTests(const char* name)
{
    UnitTestSuite suite(name);

    AddTestCase<TEST_ID(N), BondedConstructors, Reader, Writer>(suite, "bonded constructors");
    AddTestCase<TEST_ID(N), BondedCasts, Reader, Writer, unittest::NestedStruct>(suite, "bonded casts");
    
    TEST_SIMPLE_PROTOCOL(
        // Uses Simple protocol for random initialization of struct with bonded<T>
        AddTestCase<TEST_ID(N), BondedSerialize, Reader, Writer>(suite, "bonded serialization");
    );
Exemple #19
0
void 
HelperMacrosTest::testSubclassing()
{
  std::auto_ptr<CPPUNIT_NS::TestSuite> suite( SubclassedTestCase::suite() );
  CPPUNIT_ASSERT_EQUAL( 2, suite->countTestCases() );
  m_testListener->setExpectedStartTestCall( 2 );
  m_testListener->setExpectedAddFailureCall( 1 );

  suite->run( m_result );
  m_testListener->verify();
}
Exemple #20
0
void MarshalTests(const char* name)
{
    UnitTestSuite suite(name);

    AddTestCase<TEST_ID(N), 
        Marshaling, Writer, NestedWithBase>(suite, "Marshaling struct");

    TEST_SIMPLE_PROTOCOL(
        AddTestCase<TEST_ID(N), 
            Transcoding, Writer, NestedWithBase>(suite, "Transcoding marshaled data");
    );
void SKKProxyDictionary::recv(SKKCandidateSuite& result) {
    std::string response;

    if(std::getline(session_, response).eof() ||
       response.size() < 2 || response[0] != '1') {
        return;
    }

    SKKCandidateSuite suite(jconv::utf8_from_eucj(response.substr(1)));

    result.Add(suite);
}
Exemple #22
0
int
main(void)
{
  int failed;
  Suite *s = suite();
  SRunner *sr = srunner_create(s);
  srunner_run_all(sr, CK_NORMAL);
  failed = srunner_ntests_failed(sr);
  srunner_free(sr);

  return ((failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
} // main()
Exemple #23
0
void ExceptionTests(const char* name)
{
    UnitTestSuite suite(name);

    AddTestCase<TEST_ID(N), 
        OomException, Reader, Writer>(suite, "Out of memory");

    AddTestCase<TEST_ID(N), 
        MissingFieldException, Reader, Writer>(suite, "Eof after missing field");

    AddTestCase<TEST_ID(N), 
        TransformException, Reader, Writer, NestedListsStruct>(suite, "Exceptions in transform");
}
Exemple #24
0
void test_division_inverse() {
    suite("division has nonequal inverse");
    ALL1(
            switch ( a ) {
                case 0:
                case 1:
                    break;

                default:
                    test(gf_div(1,a) != a);
            }
        )
}
Exemple #25
0
void ExtensibilityTests(const char* name)
{
    UnitTestSuite suite(name);

    AddTestCase<TEST_ID(N), 
        SimpleListContainerTest, Reader, Writer>(suite, "C array based container");

    AddTestCase<TEST_ID(N), 
        StringTest, Reader, Writer>(suite, "uint8_t[], uint16_t[] string");

    AddTestCase<TEST_ID(N), 
        MultiIndexTest, Reader, Writer>(suite, "boost::multi_index_container");
}
Exemple #26
0
int main(int argc, char **argv) {
    srandom(time(NULL));
    test_initialize(argc, argv);
    gf_initialize();

    suite("reed solomon error correction");

    for (int n = 2; n <= 8; n++)
        for (int m = 1; m <= 8; m++)
            rs_test_run(n, m);

    test_exit();
}
Exemple #27
0
int main(void)
{
	int number_failed;
	SRunner* sr = srunner_create(suite());

	//srunner_set_fork_status(sr, CK_NOFORK);

	srunner_run_all(sr, CK_VERBOSE);
	//srunner_run_all(sr, CK_NORMAL);
	number_failed = srunner_ntests_failed(sr);
	srunner_free(sr);

	return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
Exemple #28
0
int
main(void)
{
  int failed = 0;

  SRunner *srunner = srunner_create(suite());

  srunner_run_all(srunner, CK_NORMAL);
  failed = srunner_ntests_failed(srunner);

  srunner_free(srunner);

  return failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
    bool RealTestDescription::setUp()
    {
        if ( !suite() )
            return false;

        for ( GlobalFixture *gf = GlobalFixture::firstGlobalFixture(); gf != 0; gf = gf->nextGlobalFixture() ) {
            bool ok;
            _TS_TRY { ok = gf->setUp(); }
            _TS_LAST_CATCH( { ok = false; } );

            if ( !ok ) {
                doFailTest( file(), line(), "Error in GlobalFixture::setUp()" );
                return false;
            }
        }
Exemple #30
0
void GenericProtocolTest(const char* name)
{
    UnitTestSuite suite(name);

    AddTestCase<TEST_ID(N), 
        IntegerEncoding, Reader, Writer>(suite, "Integer encoding");
    
    AddTestCase<TEST_ID(N), 
        StringEncoding, Reader, Writer>(suite, "String encoding");
    
    AddTestCase<COND_TEST_ID(N, !bond::uses_static_parser<Reader>::value), 
        FieldBeginEncoding, Reader, Writer>(suite, "FieldBegin encoding");
    
    AddTestCase<COND_TEST_ID(N, (std::is_same<Writer, bond::CompactBinaryWriter<bond::OutputBuffer> >::value)), 
        StructLengthEncoding, Reader, Writer>(suite, "StructLength encoding");
}