bsl_test_archive.h 1.3 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
/***************************************************************************
 * 
 * Copyright (c) 2008 Baidu.com, Inc. All Rights Reserved
 * $Id: bsl_test_archive.h,v 1.2 2008/12/15 09:57:00 xiaowei Exp $ 
 * 
 **************************************************************************/
 
 
 
/**
 * @file bsl_test_archive.h
 * @author xiaowei(com@baidu.com)
 * @date 2008/11/12 16:37:59
 * @version $Revision: 1.2 $ 
 * @brief 
 *  
 **/


#ifndef  __BSL_TEST_ARCHIVE_H_
#define  __BSL_TEST_ARCHIVE_H_


#include <cxxtest/TestSuite.h>
#include <bsl/archive/bsl_serialization.h>
#include <bsl/archive/bsl_filestream.h>
#include <bsl/archive/bsl_binarchive.h>

#define __XASSERT(flag, fmt, arg...)  \
{\
	bool ___bsl_flag = flag; \
	if (!(___bsl_flag)) { \
		fprintf(stdout, "\n[error][%s:%d][%s]"fmt"\n", __FILE__, __LINE__, #flag, ##arg); \
		return false; \
	}\
}

#define __XASSERT2(flag) __XASSERT(flag, "")

bool test_archive(void)
{
	bsl::filestream fs;
	fs.open ("test_archive.dat", "w");
	bsl::binarchive ar(fs);
	fs.start_trans();
	const char *ptr = "hello world";
	ar.push(ptr, strlen(ptr));
	fs.drop_trans(true);
	fs.close();
	return true;
}

class bsl_test_archive : public CxxTest::TestSuite
{
public:
	void test_archive_ (void) {
		TSM_ASSERT(0, test_archive());
	}
};
















#endif  //__BSL_TEST_ARCHIVE_H_

/* vim: set ts=4 sw=4 sts=4 tw=100 noet: */