Author: billblough
Date: Mon Feb 5 05:11:12 2018
New Revision: 1823121
URL: http://svn.apache.org/viewvc?rev=1823121&view=rev
Log:
Switch guththila tests to use gtest
Added:
axis/axis2/c/core/trunk/guththila/gtest/
axis/axis2/c/core/trunk/guththila/gtest/Makefile.am (with props)
axis/axis2/c/core/trunk/guththila/tests/test_attribute.cc
axis/axis2/c/core/trunk/guththila/tests/test_guththila.cc
Removed:
axis/axis2/c/core/trunk/guththila/tests/s
axis/axis2/c/core/trunk/guththila/tests/test.c
axis/axis2/c/core/trunk/guththila/tests/test.h
axis/axis2/c/core/trunk/guththila/tests/test_attribute.c
Modified:
axis/axis2/c/core/trunk/guththila/Makefile.am
axis/axis2/c/core/trunk/guththila/configure.ac
Modified: axis/axis2/c/core/trunk/guththila/Makefile.am
URL:
http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/guththila/Makefile.am?rev=1823121&r1=1823120&r2=1823121&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/guththila/Makefile.am (original)
+++ axis/axis2/c/core/trunk/guththila/Makefile.am Mon Feb 5 05:11:12 2018
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
datadir=$(prefix)
-SUBDIRS = src
+SUBDIRS = src $(GTEST) $(TESTDIR)
includedir=$(prefix)/include/axis2-${PACKAGE_VERSION}/
include_HEADERS=$(top_builddir)/include/*.h
data_DATA= INSTALL README AUTHORS NEWS LICENSE COPYING
Modified: axis/axis2/c/core/trunk/guththila/configure.ac
URL:
http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/guththila/configure.ac?rev=1823121&r1=1823120&r2=1823121&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/guththila/configure.ac (original)
+++ axis/axis2/c/core/trunk/guththila/configure.ac Mon Feb 5 05:11:12 2018
@@ -28,6 +28,7 @@ m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPT
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
+AC_PROG_CXX
AC_PROG_LIBTOOL
AC_PROG_INSTALL
AC_PROG_LN_S
@@ -79,6 +80,7 @@ AC_ARG_ENABLE(coverage, [ --enable-cove
AC_MSG_RESULT(yes)
CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
CPPFLAGS="$CPPFLAGS -fprofile-arcs -ftest-coverage"
+ LDFLAGS="$LDFLAGS -lgcov --coverage"
;;
esac ],[
AC_MSG_RESULT(no)
@@ -86,6 +88,44 @@ AC_ARG_ENABLE(coverage, [ --enable-cove
CPPFLAGS="$CPPFLAGS"]
)
+AC_MSG_CHECKING(whether to use the Google test framework)
+AC_ARG_WITH(gtest,
+ [ --with-gtest[=PATH] Find the gtest source files in
'PATH'.],
+[ case "$withval" in
+ no)
+ AC_MSG_RESULT(no)
+ USE_GTEST=""
+ GTEST_DIR=""
+ GTEST=""
+ ;;
+ *)
+ AC_MSG_RESULT(yes)
+ GTEST_DIR="$withval"
+ GTEST="gtest"
+ CXXFLAGS="$CXXFLAGS -g -Wall -Wextra -pthread"
+ ;;
+ esac ],
+ AC_MSG_RESULT(no)
+)
+
+AC_MSG_CHECKING(whether to build tests)
+AC_ARG_ENABLE(tests, [ --enable-tests build tests. default=no],
+[ case "${enableval}" in
+ yes)
+ AC_MSG_RESULT(yes)
+ TESTDIR="tests"
+ ;;
+ *)
+ AC_MSG_RESULT(no)
+ TESTDIR=""
+
+ ;;
+ esac ],
+ AC_MSG_RESULT(no)
+ TESTDIR=""
+)
+
+
dnl Checks for header files.
@@ -106,9 +146,14 @@ VERSION_NO="7:0:7"
AC_SUBST(UTILINC)
AC_SUBST(VERSION_NO)
+AC_SUBST(GTEST_DIR)
+AC_SUBST(GTEST)
+AC_SUBST(TESTDIR)
AC_CONFIG_FILES([Makefile \
src/Makefile \
+ gtest/Makefile \
+ tests/Makefile \
])
-
+
AC_OUTPUT
Added: axis/axis2/c/core/trunk/guththila/gtest/Makefile.am
URL:
http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/guththila/gtest/Makefile.am?rev=1823121&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/guththila/gtest/Makefile.am (added)
+++ axis/axis2/c/core/trunk/guththila/gtest/Makefile.am Mon Feb 5 05:11:12 2018
@@ -0,0 +1,14 @@
+
+noinst_LIBRARIES = libgtest.a libgtest_main.a
+
+libgtest_a_SOURCES = $(GTEST_DIR)/src/gtest-all.cc
+libgtest_a_CPPFLAGS = -I$(GTEST_DIR)/include -I$(GTEST_DIR)
+libgtest_a_CXXFLAGS = -g -Wall -Wextra
+libgtest_a_LDFLAGS = -pthread
+
+libgtest_main_a_SOURCES = $(GTEST_DIR)/src/gtest_main.cc
+libgtest_main_CPPFLAGS = -I$(GTEST_DIR)/include -I$(GTEST_DIR)
+libgtest_main_a_CXXFLAGS = -g -Wall -Wextra
+libgtest_main_LDFLAGS = -pthread
+libgtest_main_a_LIBADD = libgtest.a
+
Propchange: axis/axis2/c/core/trunk/guththila/gtest/Makefile.am
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/c/core/trunk/guththila/tests/test_attribute.cc
URL:
http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/guththila/tests/test_attribute.cc?rev=1823121&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/guththila/tests/test_attribute.cc (added)
+++ axis/axis2/c/core/trunk/guththila/tests/test_attribute.cc Mon Feb 5
05:11:12 2018
@@ -0,0 +1,132 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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 <gtest/gtest.h>
+
+#include <guththila.h>
+
+
+#define BUF_SIZE 256
+
+class TestAttribute: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+ m_allocator = axutil_allocator_init(NULL);
+ ASSERT_NE(m_allocator, nullptr);
+ m_env = axutil_env_create(m_allocator);
+ ASSERT_NE(m_env, nullptr);
+
+ m_parser = (guththila_t*) calloc(1, sizeof(guththila_t));
+ ASSERT_NE(m_parser, nullptr);
+
+ memset(m_buffer, 0, BUF_SIZE);
+
+ }
+
+ void TearDown()
+ {
+
+ guththila_reader_free(m_reader, m_env);
+ m_reader = nullptr;
+ guththila_un_init(m_parser, m_env);
+ m_parser = nullptr;
+ axutil_env_free(m_env);
+
+ }
+
+ guththila_reader_t *m_reader;
+ axutil_allocator_t *m_allocator;
+ axutil_env_t *m_env;
+ guththila_t *m_parser;
+ char m_buffer[BUF_SIZE];
+
+};
+
+TEST_F(TestAttribute, test_attribute) {
+
+ int count = 0;
+ int c = 0;
+ guththila_attr_t *att;
+
+ m_reader = guththila_reader_create_for_file("resources/om/evaluate.xml",
m_env);
+ ASSERT_NE(m_reader, nullptr);
+ guththila_init(m_parser, m_reader, m_env);
+
+ guththila_reader_read(m_parser->reader, m_buffer, 0, BUF_SIZE, m_env);
+ c = guththila_next(m_parser, m_env);
+
+ while (!count)
+ {
+ /* FIXME: This is potentially an infinite loop */
+ c = guththila_next(m_parser, m_env);
+ count = guththila_get_attribute_count(m_parser, m_env);
+ if (count)
+ att = guththila_get_attribute(m_parser, m_env);
+ }
+
+ ASSERT_NE(count, 0);
+ ASSERT_STREQ(guththila_get_attribute_name(m_parser, att, m_env), "color");
+ ASSERT_STREQ(guththila_get_attribute_value(m_parser, att, m_env), "brown");
+
+}
+
+
+TEST_F(TestAttribute, test_attribute_prefix) {
+
+ int count = 0;
+ int c = 0;
+ guththila_attr_t *att;
+
+ m_reader =
guththila_reader_create_for_file("resources/soap/soapmessage.xml", m_env);
+ ASSERT_NE(m_reader, nullptr);
+ guththila_init(m_parser, m_reader, m_env);
+
+ guththila_reader_read(m_parser->reader, m_buffer, 0, BUF_SIZE, m_env);
+ c = guththila_next(m_parser, m_env);
+
+ while(!count)
+ {
+ /* FIXME: This is potentially an infinite loop */
+ c = guththila_next(m_parser, m_env);
+ count = guththila_get_attribute_count(m_parser, m_env);
+ if (count)
+ att = guththila_get_attribute(m_parser, m_env);
+ }
+
+ ASSERT_NE(count, 0);
+ ASSERT_STREQ(guththila_get_attribute_prefix(m_parser, att, m_env),
"soapenv");
+ ASSERT_STREQ(guththila_get_attribute_name(m_parser, att, m_env),
"mustUnderstand");
+ ASSERT_STREQ(guththila_get_attribute_value(m_parser, att, m_env), "0");
+
+ count = 0;
+ while(!count)
+ {
+ /* FIXME: This is potentially an infinite loop */
+ c = guththila_next(m_parser, m_env);
+ count = guththila_get_attribute_count(m_parser, m_env);
+ if (count)
+ att = guththila_get_attribute(m_parser, m_env);
+ }
+ ASSERT_NE(count, 0);
+ ASSERT_STREQ(guththila_get_attribute_prefix(m_parser, att, m_env),
"soapenv");
+ ASSERT_STREQ(guththila_get_attribute_name(m_parser, att, m_env),
"mustUnderstand");
+ ASSERT_STREQ(guththila_get_attribute_value(m_parser, att, m_env), "0");
+
+}
Added: axis/axis2/c/core/trunk/guththila/tests/test_guththila.cc
URL:
http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/guththila/tests/test_guththila.cc?rev=1823121&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/guththila/tests/test_guththila.cc (added)
+++ axis/axis2/c/core/trunk/guththila/tests/test_guththila.cc Mon Feb 5
05:11:12 2018
@@ -0,0 +1,221 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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 <gtest/gtest.h>
+
+#include <guththila.h>
+#include "guththila_defines.h"
+
+#define BUF_SIZE 256
+
+class TestGuththila: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+ m_allocator = axutil_allocator_init(NULL);
+ ASSERT_NE(m_allocator, nullptr);
+ m_env = axutil_env_create(m_allocator);
+ ASSERT_NE(m_env, nullptr);
+
+ m_parser = (guththila_t*) calloc(1, sizeof(guththila_t));
+ ASSERT_NE(m_parser, nullptr);
+
+ memset(m_buffer, 0, BUF_SIZE);
+
+ }
+
+ void TearDown()
+ {
+ guththila_reader_free(m_reader, m_env);
+ m_reader = nullptr;
+ guththila_un_init(m_parser, m_env);
+ m_parser = nullptr;
+ axutil_env_free(m_env);
+
+ }
+
+ axutil_allocator_t *m_allocator;
+ axutil_env_t *m_env;
+ guththila_reader_t *m_reader;
+ guththila_t *m_parser;
+ char m_buffer[BUF_SIZE];
+
+};
+
+
+TEST_F(TestGuththila, test_start_element) {
+
+ int c = 0;
+ char *p;
+
+ m_reader = guththila_reader_create_for_file("resources/om/axis.xml",
m_env);
+ ASSERT_NE(m_reader, nullptr);
+ guththila_init(m_parser, m_reader, m_env);
+
+ guththila_reader_read(m_parser->reader, m_buffer, 0, BUF_SIZE, m_env);
+ c = guththila_next(m_parser, m_env);
+
+ while((c != GUTHTHILA_START_ELEMENT))
+ c = guththila_next(m_parser, m_env);
+
+ p = guththila_get_name(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+ ASSERT_EQ(c, GUTHTHILA_START_ELEMENT);
+ ASSERT_STREQ(p, "root");
+ c = 0;
+
+ while((c != GUTHTHILA_START_ELEMENT))
+ c = guththila_next(m_parser, m_env);
+
+ p = guththila_get_name(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+ ASSERT_EQ(c, GUTHTHILA_START_ELEMENT);
+ ASSERT_STREQ(p, "a");
+
+ c = 0;
+ while((c != GUTHTHILA_START_ELEMENT))
+ c = guththila_next(m_parser, m_env);
+
+ p = guththila_get_name(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+ ASSERT_STREQ(p, "b");
+}
+
+TEST_F(TestGuththila, test_empty_element) {
+
+ int c = 0;
+ char *p;
+
+ m_reader = guththila_reader_create_for_file("resources/om/axis.xml",
m_env);
+ ASSERT_NE(m_reader, nullptr);
+ guththila_init(m_parser, m_reader, m_env);
+
+ guththila_reader_read(m_parser->reader, m_buffer, 0, BUF_SIZE, m_env);
+ c = guththila_next(m_parser, m_env);
+
+ while((c != GUTHTHILA_EMPTY_ELEMENT))
+ c = guththila_next(m_parser, m_env);
+
+ p = guththila_get_name(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+
+ ASSERT_EQ(c, GUTHTHILA_EMPTY_ELEMENT);
+ ASSERT_STREQ(p, "a.1");
+
+ c = 0;
+
+ while((c != GUTHTHILA_EMPTY_ELEMENT))
+ c = guththila_next(m_parser, m_env);
+
+ p = guththila_get_name(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+
+ ASSERT_EQ(c, GUTHTHILA_EMPTY_ELEMENT);
+ ASSERT_STREQ(p, "a.2");
+
+ c = 0;
+ while((c != GUTHTHILA_START_ELEMENT))
+ c = guththila_next(m_parser, m_env);
+
+ c = 0;
+ while((c != GUTHTHILA_EMPTY_ELEMENT))
+ c = guththila_next(m_parser, m_env);
+
+ p = guththila_get_name(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+
+ ASSERT_EQ(c, GUTHTHILA_EMPTY_ELEMENT);
+ ASSERT_STREQ(p, "b.1");
+
+}
+
+
+TEST_F(TestGuththila, test_end_element) {
+
+ int c = 0;
+ char *p;
+
+ m_reader = guththila_reader_create_for_file("resources/om/axis.xml",
m_env);
+ ASSERT_NE(m_reader, nullptr);
+ guththila_init(m_parser, m_reader, m_env);
+
+ guththila_reader_read(m_parser->reader, m_buffer, 0, BUF_SIZE, m_env);
+ c = guththila_next(m_parser, m_env);
+
+ while((c != GUTHTHILA_END_ELEMENT))
+ c = guththila_next(m_parser, m_env);
+
+ p = guththila_get_name(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+
+ ASSERT_EQ(c, GUTHTHILA_END_ELEMENT);
+ ASSERT_STREQ(p, "a");
+
+ c = 0;
+ while((c != GUTHTHILA_END_ELEMENT))
+ c = guththila_next(m_parser, m_env);
+
+ p = guththila_get_name(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+
+ ASSERT_EQ(c, GUTHTHILA_END_ELEMENT);
+ ASSERT_STREQ(p, "b");
+
+ c = 0;
+ while((c != GUTHTHILA_END_ELEMENT))
+ c = guththila_next(m_parser, m_env);
+
+ p = guththila_get_name(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+
+ ASSERT_EQ(c, GUTHTHILA_END_ELEMENT);
+ ASSERT_STREQ(p, "root");
+}
+
+TEST_F(TestGuththila, test_character) {
+
+ int c = 0;
+ int i = 0;
+ char *p;
+
+ m_reader = guththila_reader_create_for_file("resources/om/numbers.xml",
m_env);
+ ASSERT_NE(m_reader, nullptr);
+ guththila_init(m_parser, m_reader, m_env);
+
+ guththila_reader_read(m_parser->reader, m_buffer, 0, BUF_SIZE, m_env);
+ c = guththila_next(m_parser, m_env);
+ while(i < 3)
+ {
+ if(c == GUTHTHILA_START_ELEMENT)
+ i++;
+ c = guththila_next(m_parser, m_env);
+ }
+
+ if(c == GUTHTHILA_CHARACTER)
+ p = guththila_get_value(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+ ASSERT_STREQ(p, "3");
+
+ c = 0;
+ while(c != GUTHTHILA_CHARACTER)
+ c = guththila_next(m_parser, m_env);
+ p = guththila_get_value(m_parser, m_env);
+ ASSERT_NE(p, nullptr);
+ ASSERT_STREQ(p, "24");
+}