mirror of
https://github.com/ceph/ceph
synced 2025-02-24 03:27:10 +00:00
unit: Add test/base64.cc
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
This commit is contained in:
parent
983e62c81d
commit
e7153f383f
@ -315,15 +315,26 @@ endif
|
||||
# target to build but not run the unit tests
|
||||
unittests:: $(check_PROGRAMS)
|
||||
|
||||
unittest_encoding_SOURCES = test/encoding.cc
|
||||
unittest_encoding_LDADD = libceph.la libcrush.la -lpthread -lm -lcrypto \
|
||||
$(top_builddir)/src/gtest/lib/libgtest.la \
|
||||
$(top_builddir)/src/gtest/lib/libgtest_main.la
|
||||
unittest_encoding_CPPFLAGS = \
|
||||
UNITTEST_CFLAGS = \
|
||||
-I$(top_srcdir)/src/gtest/include \
|
||||
-I$(top_builddir)/src/gtest/include
|
||||
UNITTEST_LDADD = \
|
||||
$(top_builddir)/src/gtest/lib/libgtest.la \
|
||||
$(top_builddir)/src/gtest/lib/libgtest_main.la
|
||||
|
||||
unittest_encoding_SOURCES = test/encoding.cc
|
||||
unittest_encoding_LDADD = libceph.la libcrush.la -lpthread -lm -lcrypto \
|
||||
${UNITTEST_LDADD}
|
||||
unittest_encoding_CPPFLAGS = ${AM_CFLAGS} ${UNITTEST_CFLAGS}
|
||||
check_PROGRAMS += unittest_encoding
|
||||
|
||||
unittest_base64_SOURCES = test/base64.cc
|
||||
unittest_base64_LDFLAGS = -pthread
|
||||
unittest_base64_LDADD = libceph.la libcrush.la -lpthread -lm -lcrypto \
|
||||
${UNITTEST_LDADD}
|
||||
unittest_base64_CPPFLAGS = ${AM_CFLAGS} ${UNITTEST_CFLAGS}
|
||||
check_PROGRAMS += unittest_base64
|
||||
|
||||
# shell scripts
|
||||
editpaths = sed \
|
||||
-e 's|@bindir[@]|$(bindir)|g' \
|
||||
|
35
src/test/base64.cc
Normal file
35
src/test/base64.cc
Normal file
@ -0,0 +1,35 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
||||
// vim: ts=8 sw=2 smarttab
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2011 Dreamhost
|
||||
*
|
||||
* This is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software
|
||||
* Foundation. See file COPYING.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/armor.h"
|
||||
#include "config.h"
|
||||
#include "include/buffer.h"
|
||||
#include "include/encoding.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(CorrectBase64Encoding, StringSimple) {
|
||||
static const int OUT_LEN = 4096;
|
||||
const char * const original = "abracadabra";
|
||||
const char * const correctly_encoded = "YWJyYWNhZGFicmE=";
|
||||
char out[OUT_LEN];
|
||||
memset(out, 0, sizeof(out));
|
||||
int alen = ceph_armor(out, out + OUT_LEN, original, original + strlen(original));
|
||||
ASSERT_STREQ(correctly_encoded, out);
|
||||
|
||||
char out2[OUT_LEN];
|
||||
memset(out2, 0, sizeof(out2));
|
||||
ceph_unarmor(out2, out2 + OUT_LEN, out, out + alen);
|
||||
ASSERT_STREQ(original, out2);
|
||||
}
|
Loading…
Reference in New Issue
Block a user