tests CHANGE initial test for YANG parser
diff --git a/src/parser_yang.c b/src/parser_yang.c
index a80a62c..7f88bc6 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -203,8 +203,11 @@
 static LY_ERR
 skip_comment(struct ly_ctx *ctx, const char **data, int comment)
 {
-    /* comment: 0 - comment ended, 1 - in line comment, 2 - in block comment, 3 - in block comment with last read character '*' */
-
+    /* internal statuses: 0 - comment ended,
+     *                    1 - in line comment,
+     *                    2 - in block comment,
+     *                    3 - in block comment with last read character '*'
+     */
     while (**data && comment) {
         switch (comment) {
         case 1:
diff --git a/tests/src/CMakeLists.txt b/tests/src/CMakeLists.txt
index 77eead2..bce0d9a 100644
--- a/tests/src/CMakeLists.txt
+++ b/tests/src/CMakeLists.txt
@@ -3,12 +3,14 @@
     src_common
     src_context
     src_hash_table
-    src_xml)
+    src_xml
+    src_parser_yang)
 set(local_tests_wraps
     " "
     "-Wl,--wrap=realloc"
     "-Wl,--wrap=ly_set_add"
     " "
+    " "
     " ")
 set(tests ${tests} ${local_tests} PARENT_SCOPE)
 set(tests_wraps ${tests_wraps} ${local_tests_wraps} PARENT_SCOPE)
diff --git a/tests/src/test_parser_yang.c b/tests/src/test_parser_yang.c
new file mode 100644
index 0000000..0a14116
--- /dev/null
+++ b/tests/src/test_parser_yang.c
@@ -0,0 +1,101 @@
+/*
+ * @file test_parser_yang.c
+ * @author: Radek Krejci <rkrejci@cesnet.cz>
+ * @brief unit tests for functions from parser_yang.c
+ *
+ * Copyright (c) 2018 CESNET, z.s.p.o.
+ *
+ * This source code is licensed under BSD 3-Clause License (the "License").
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://opensource.org/licenses/BSD-3-Clause
+ */
+
+#define _BSD_SOURCE
+#define _DEFAULT_SOURCE
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include "libyang.h"
+#include "../../src/parser_yang.c"
+
+#define BUFSIZE 1024
+char logbuf[BUFSIZE] = {0};
+
+/* set to 0 to printing error messages to stderr instead of checking them in code */
+#define ENABLE_LOGGER_CHECKING 1
+
+static void
+logger(LY_LOG_LEVEL level, const char *msg, const char *path)
+{
+    (void) level; /* unused */
+
+    if (path) {
+        snprintf(logbuf, BUFSIZE - 1, "%s %s", msg, path);
+    } else {
+        strncpy(logbuf, msg, BUFSIZE - 1);
+    }
+}
+
+static int
+logger_setup(void **state)
+{
+    (void) state; /* unused */
+#if ENABLE_LOGGER_CHECKING
+    ly_set_log_clb(logger, 1);
+#endif
+    return 0;
+}
+
+void
+logbuf_clean(void)
+{
+    logbuf[0] = '\0';
+}
+
+#if ENABLE_LOGGER_CHECKING
+#   define logbuf_assert(str) assert_string_equal(logbuf, str)
+#else
+#   define logbuf_assert(str)
+#endif
+
+
+static void
+test_comments(void **state)
+{
+    (void) state; /* unused */
+
+    const char *str, *p;
+
+    str = " this is a text of / one * line */ comment\nx";
+    assert_int_equal(LY_SUCCESS, skip_comment(NULL, &str, 1));
+    assert_string_equal("x", str);
+
+    str = " this is a \n * text // of / block * comment */x";
+    assert_int_equal(LY_SUCCESS, skip_comment(NULL, &str, 2));
+    assert_string_equal("x", str);
+
+    str = p = " this is one line comment on last line";
+    assert_int_equal(LY_SUCCESS, skip_comment(NULL, &str, 1));
+    assert_true(str[0] == '\0');
+
+    str = p = " this is a not terminated comment x";
+    assert_int_equal(LY_EVALID, skip_comment(NULL, &str, 2));
+    logbuf_assert("Unexpected end-of-file, non-terminated comment.");
+    assert_true(str[0] == '\0');
+}
+
+int main(void)
+{
+    const struct CMUnitTest tests[] = {
+        cmocka_unit_test_setup(test_comments, logger_setup),
+    };
+
+    return cmocka_run_group_tests(tests, NULL, NULL);
+}