예제 #1
0
파일: version.hpp 프로젝트: niXman/yas
bool version_test(std::ostream &log, const char *archive_type, const char *test_name) {
	typename archive_traits::oarchive oa;
	archive_traits::ocreate(oa, archive_type);
	typename archive_traits::iarchive ia;
	archive_traits::icreate(ia, oa, archive_type);

	if ( oa->type() != ia->type() ) {
		YAS_TEST_REPORT(log, archive_type, test_name);
		return false;
	}

	if ( oa->version() != ia->version() ) {
		YAS_TEST_REPORT(log, archive_type, test_name);
		return false;
	}

	if ( oa->type() == yas::json ) {
        if ( oa->header_size() != archive_traits::oarchive_type::header_size() ||
             archive_traits::oarchive_type::header_size() != 0)
        {
			YAS_TEST_REPORT(log, archive_type, test_name);
            return false;
        }
    } else {
        if ( oa->header_size() != archive_traits::oarchive_type::header_size() ||
             archive_traits::oarchive_type::header_size() != 7)
        {
			YAS_TEST_REPORT(log, archive_type, test_name);
            return false;
        }
    }

	return true;
}
예제 #2
0
파일: version.hpp 프로젝트: starius/yas
bool version_test(const char* archive_type, const char* io_type) {
	typename archive_traits::oarchive oa;
	archive_traits::ocreate(oa, archive_type, io_type);
	typename archive_traits::iarchive ia;
	archive_traits::icreate(ia, oa, archive_type, io_type);

	if ( oa->type() != ia->type() ) {
		std::cout << "VERSION test failed! archive type is not equal! [1]" << std::endl;
		return false;
	}
	if ( oa->bits() != ia->bits() ) {
		std::cout << "VERSION test failed! archive bits is not equal! [2]" << std::endl;
		return false;
	}
	if ( oa->version() != ia->version() ) {
		std::cout << "VERSION test failed! archive versions is not equal! [3]" << std::endl;
		return false;
	}

	if ( yas::is_binary_archive<typename archive_traits::oarchive_type>::value ) {
		if ( oa->header_size() != archive_traits::oarchive_type::_header_size ||
			  archive_traits::oarchive_type::_header_size != sizeof(yas::uint32_t)
		) {
			std::cout << "VERSION test failed! bad archive header size! [4]" << std::endl;
			return false;
		}
	} else if ( yas::is_text_archive<typename archive_traits::oarchive_type>::value ) {
		if ( oa->header_size() != archive_traits::oarchive_type::_header_size ||
			  archive_traits::oarchive_type::_header_size != 5 /** see information.hpp */
		) {
			std::cout << "VERSION test failed! bad archive header size! [5]" << std::endl;
			return false;
		}
	} else if ( yas::is_json_archive<typename archive_traits::oarchive_type>::value ) {
		if ( oa->header_size() != archive_traits::oarchive_type::_header_size ||
			  archive_traits::oarchive_type::_header_size != 16 /** see information.hpp */
		) {
			std::cout << "VERSION test failed! bad archive header size! [6]" << std::endl;
			return false;
		}
	} else {
		std::cout << "VERSION test failed! bad archive type! [7]" << std::endl;
		return false;
	}
//   std::cout
//   << "binary_mem_oarchive: type = " << oa.archive_type() << std::endl
//   << "binary_mem_oarchive: bits = " << oa.bits() << std::endl
//   << "binary_mem_oarchive: vers = " << oa.version() << std::endl << std::endl;
//   std::cout
//   << "binary_mem_iarchive: type = " << ia.archive_type() << std::endl
//   << "binary_mem_iarchive: bits = " << ia.bits() << std::endl
//   << "binary_mem_iarchive: vers = " << ia.version() << std::endl << std::endl;

	return true;
}