test: add test-truncate_nl
authorWaLyong Cho <walyong.cho@samsung.com>
Wed, 21 Sep 2016 04:41:47 +0000 (13:41 +0900)
committerWaLyong Cho <walyong.cho@samsung.com>
Wed, 21 Sep 2016 04:41:47 +0000 (13:41 +0900)
src/Makefile.am
src/test/test-truncate_nl.c [new file with mode: 0644]

index be42ed4..61fee7c 100644 (file)
@@ -75,6 +75,15 @@ 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 (file)
index 0000000..07d01e8
--- /dev/null
@@ -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 <stdio.h>
+#include <assert.h>
+
+#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;
+}