Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
Archivo: endian.hpp Proyecto: pmed/yas
bool endian_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 ( ia->is_big_endian() != oa->is_big_endian() || oa->is_big_endian() != YAS_BIG_ENDIAN() ) {
		std::cout << "ENDIAN test failed! endianness is not equal! [1]" << std::endl;
		return false;
	}

	if ( ia->is_little_endian() != oa->is_little_endian() || oa->is_little_endian() != YAS_LITTLE_ENDIAN() ) {
		std::cout << "ENDIAN test failed! endianness is not equal! [2]" << std::endl;
		return false;
	}

	return true;
}