From 9c61ac82c790b7f09eb6f77f757e6ad3eff5da3c Mon Sep 17 00:00:00 2001 From: WaLyong Cho Date: Wed, 21 Sep 2016 13:41:47 +0900 Subject: [PATCH] test: add test-truncate_nl --- src/Makefile.am | 9 ++++++++ src/test/test-truncate_nl.c | 41 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/test/test-truncate_nl.c diff --git a/src/Makefile.am b/src/Makefile.am index be42ed4..61fee7c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,6 +74,15 @@ libsystem_la_CFLAGS = \ libsystem_la_LIBADD = \ -lrt +# ------------------------------------------------------------------------------ +test_truncate_nl_SOURCES = \ + test/test-truncate_nl.c + +test_truncate_nl_LDADD = \ + libsystem.la + +tests += test-truncate_nl + # ------------------------------------------------------------------------------ pkgconfiglib_DATA += \ libsystem-sd/libsystem-sd.pc diff --git a/src/test/test-truncate_nl.c b/src/test/test-truncate_nl.c new file mode 100644 index 0000000..07d01e8 --- /dev/null +++ b/src/test/test-truncate_nl.c @@ -0,0 +1,41 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/* + * libsystem + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "libsystem/libsystem.h" + +#define TEST_STRING "hello libsystem" +#define TEST_STRING_NL TEST_STRING "\n\r" + +static void test_truncate_nl(void) { + char s[] = TEST_STRING_NL; + + assert(!streq(s, TEST_STRING)); + truncate_nl(s); + assert(streq(s, TEST_STRING)); +} + +int main(int argc, char *argv[]) { + test_truncate_nl(); + + return 0; +} -- 2.34.1