Пример #1
0
static void test_variables( libvlc_instance_t *p_vlc )
{
    libvlc_int_t *p_libvlc = p_vlc->p_libvlc_int;
    srand( time( NULL ) );

    log( "Testing for integers\n" );
    test_integer( p_libvlc );

    log( "Testing for booleans\n" );
    test_booleans( p_libvlc );

    log( "Testing for floats\n" );
    test_floats( p_libvlc );

    log( "Testing for strings\n" );
    test_strings( p_libvlc );

    log( "Testing for addresses\n" );
    test_address( p_libvlc );

    log( "Testing the callbacks\n" );
    test_callbacks( p_libvlc );

    log( "Testing the limits\n" );
    test_limits( p_libvlc );

    log( "Testing choices\n" );
    test_choices( p_libvlc );

    log( "Testing var_Change()\n" );
    test_change( p_libvlc );

    log( "Testing type at creation\n" );
    test_creation_and_type( p_libvlc );
}
Пример #2
0
int Test::all() {

	clock_t begin = clock();
	exeTime = 0;

	test_general();
	test_types();
	test_booleans();
	test_numbers();
	test_strings();
	test_arrays();
	test_intervals();
	test_map();
	test_set();
	test_objects();
	test_functions();
	test_classes();
	test_loops();
	test_operators();
	test_references();
	test_exceptions();
	test_operations();
	test_system();
	test_json();
	test_files();
	test_doc();
	test_utils();

	double elapsed_secs = double(clock() - begin) / CLOCKS_PER_SEC;
	int errors = (total - success_count);
	int leaks = (obj_created - obj_deleted);
	int mpz_leaks = (mpz_obj_created - mpz_obj_deleted);

	std::ostringstream line1, line2, line3, line4;
	line1 << "Total : " << total << ", success : " << success_count << ", errors : " << errors;
	line2 << "Total time : " << elapsed_secs * 1000 << " ms";
	line3 << "Objects destroyed : " << obj_deleted << " / " << obj_created << " (" << leaks << " leaked)";
	line4 << "MPZ objects destroyed : " << mpz_obj_deleted << " / " << mpz_obj_created << " (" << mpz_leaks << " leaked)";
	unsigned w = std::max(line1.str().size(), std::max(line2.str().size(), std::max(line3.str().size(), line4.str().size())));

	auto pad = [](std::string s, int l) {
		l -= s.size();
		while (l-- > 0) s += " ";
		return s;
	};
	std::cout << "┌";
	for (unsigned i = 0; i < w + 2; ++i) std::cout << "─";
	std::cout << "┐" << std::endl;
	std::cout << "│ " << pad(line1.str(), w) << " │" << std::endl;
	std::cout << "│ " << pad(line2.str(), w) << " │" << std::endl;
	std::cout << "│ " << pad(line3.str(), w) << " │" << std::endl;
	std::cout << "│ " << pad(line4.str(), w) << " │" << std::endl;
	std::cout << "├";
	for (unsigned i = 0; i < w + 2; ++i) std::cout << "─";
	std::cout << "┤";
	std::cout << std::endl;

	int result = abs(errors) + abs(leaks) + abs(mpz_leaks);
	if (result == 0) {
		std::cout << "│ " << pad("GOOD! ✔", w + 2) << " │" << std::endl;
	} else {
		std::cout << "│ " << pad("BAD! : " + std::to_string(result) + " error(s) ✘", w + 2) << " │" << std::endl;
	}
	std::cout << "└";
	for (unsigned i = 0; i < w + 2; ++i) std::cout << "─";
	std::cout << "┘" << std::endl;

	for (const auto& error : failed_tests) {
		std::cout << " " << error << std::endl;
	}
	if (failed_tests.size()) {
		std::cout << std::endl;
	}
	return result;
}