Add build tests 50/265050/3
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 7 Oct 2021 07:43:06 +0000 (16:43 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 8 Oct 2021 00:54:41 +0000 (09:54 +0900)
When building this package, the tidl-build-tests is also built together.
Before building the codes, the tidl-build-tests generates the codes using tidlc.
The tidl files exist in the tests/buil_tests/tidl directory.
The unit_tests is moved to the tests/unit_tests.

Change-Id: I2816d93468582cdbf1aae3c067667104e3be3d52
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
45 files changed:
CMakeLists.txt
packaging/tidl.spec
tests/CMakeLists.txt [new file with mode: 0644]
tests/build_tests/CMakeLists.txt [new file with mode: 0644]
tests/build_tests/main.cc [new file with mode: 0644]
tests/build_tests/prebuild.sh [new file with mode: 0755]
tests/build_tests/tidl/Buffer.tidl [new file with mode: 0644]
tests/build_tests/tidl/DataPort.tidl [new file with mode: 0644]
tests/build_tests/tidl/Ex.tidl [new file with mode: 0644]
tests/build_tests/tidl/Foo.tidl [new file with mode: 0644]
tests/build_tests/tidl/Message.tidl [new file with mode: 0644]
tests/unit_tests/CMakeLists.txt [new file with mode: 0644]
tests/unit_tests/attribute_unittest.cc [new file with mode: 0644]
tests/unit_tests/block_unittest.cc [new file with mode: 0644]
tests/unit_tests/cs_gen/cs_proxy_gen_unittest.cc [new file with mode: 0644]
tests/unit_tests/cs_gen/cs_stub_gen_unittest.cc [new file with mode: 0644]
tests/unit_tests/declaration_unittest.cc [new file with mode: 0644]
tests/unit_tests/document_unittest.cc [new file with mode: 0644]
tests/unit_tests/element_unittest.cc [new file with mode: 0644]
tests/unit_tests/generator_unittest.cc [new file with mode: 0644]
tests/unit_tests/interface_unittest.cc [new file with mode: 0644]
tests/unit_tests/main.cc [new file with mode: 0644]
tests/unit_tests/parser_unittest.cc [new file with mode: 0644]
tests/unit_tests/structure_unittest.cc [new file with mode: 0644]
tests/unit_tests/test.tidl [new file with mode: 0644]
tests/unit_tests/test_error.tidl [new file with mode: 0644]
tests/unit_tests/type_unittest.cc [new file with mode: 0644]
tests/unit_tests/unit_tests.sh [new file with mode: 0755]
unit_tests/CMakeLists.txt [deleted file]
unit_tests/attribute_unittest.cc [deleted file]
unit_tests/block_unittest.cc [deleted file]
unit_tests/cs_gen/cs_proxy_gen_unittest.cc [deleted file]
unit_tests/cs_gen/cs_stub_gen_unittest.cc [deleted file]
unit_tests/declaration_unittest.cc [deleted file]
unit_tests/document_unittest.cc [deleted file]
unit_tests/element_unittest.cc [deleted file]
unit_tests/generator_unittest.cc [deleted file]
unit_tests/interface_unittest.cc [deleted file]
unit_tests/main.cc [deleted file]
unit_tests/parser_unittest.cc [deleted file]
unit_tests/structure_unittest.cc [deleted file]
unit_tests/test.tidl [deleted file]
unit_tests/test_error.tidl [deleted file]
unit_tests/type_unittest.cc [deleted file]
unit_tests/unit_tests.sh [deleted file]

index fd0ec2d02ef81a225bcdb36e0e633af3b051e842..d698f6ee1beab8d7c7e6ca54cbab9265e1af63b4 100644 (file)
@@ -8,13 +8,11 @@ FIND_PACKAGE(FLEX REQUIRED)
 
 IF(NOT DEFINED MINIMUM_BUILD)
 ENABLE_TESTING()
-SET(TIDL_UNIT_TESTS tidl-unit-tests)
+SET(TARGET_TIDL_BUILD_TESTS "tidl-build-tests")
+SET(TIDL_UNIT_TESTS "tidl-unit-tests")
 ADD_TEST(NAME ${TIDL_UNIT_TESTS} COMMAND ${TIDL_UNIT_TESTS} test.tidl test_error.tidl
-               WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/unit_tests)
+               WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/unit_tests)
 ENDIF(NOT DEFINED MINIMUM_BUILD)
 
 ADD_SUBDIRECTORY(idlc)
-IF(NOT DEFINED MINIMUM_BUILD)
-ADD_SUBDIRECTORY(unit_tests)
-ADD_DEPENDENCIES(${TIDL_UNIT_TESTS} ${PROJECT_NAME})
-ENDIF(NOT DEFINED MINIMUM_BUILD)
+ADD_SUBDIRECTORY(tests)
index 1c0399da43e857be0ab99e7549d47a3c03974aef..52dfc3c5065b06c0155fe8205916bca7c22c52b4 100644 (file)
@@ -16,6 +16,9 @@ BuildRequires:  flex
 BuildRequires:  bison
 BuildRequires:  gtest-devel
 BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(rpc-port)
+BuildRequires:  pkgconfig(bundle)
 %if 0%{?gcov:1}
 BuildRequires:  lcov
 %endif
@@ -50,7 +53,7 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %__make %{?_smp_mflags}
 
 %check
-ctest --output-on-failure %{?_smp_mflags}
+ctest -V %{?_smp_mflags}
 %if 0%{?gcov:1}
 lcov -c --ignore-errors graph --no-external -q -d . -o gcov.info
 genhtml gcov.info
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..84baa03
--- /dev/null
@@ -0,0 +1,7 @@
+IF(NOT DEFINED MINIMUM_BUILD)
+ADD_SUBDIRECTORY(unit_tests)
+ADD_DEPENDENCIES(${TIDL_UNIT_TESTS} ${PROJECT_NAME})
+
+ADD_SUBDIRECTORY(build_tests)
+ADD_DEPENDENCIES(${TARGET_TIDL_BUILD_TESTS} ${PROJECT_NAME})
+ENDIF(NOT DEFINED MINIMUM_BUILD)
diff --git a/tests/build_tests/CMakeLists.txt b/tests/build_tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e086a0f
--- /dev/null
@@ -0,0 +1,49 @@
+SET(TOOL_TIDLC "${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/tidlc")
+SET(TARGET_PREBUILD_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/prebuild.sh")
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PKGS REQUIRED dlog glib-2.0 rpc-port bundle)
+
+FOREACH(flag ${PKGS_CFLAGS})
+  SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIE -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFALGS} -fPIE -Werror")
+SET(CMAKE_EXE_LINKER_FLAGS "-pie -Wl,--as-needed")
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TIDL_BUILD_TESTS_SRCS)
+
+SET(TIDL_GEN_SRCS
+  BufferProxy.cc
+  BufferProxyC.c
+  BufferStub.cc
+  BufferStubC.c
+  DataPortProxy.cc
+  DataPortProxyC.c
+  DataPortStub.cc
+  DataPortStubC.c
+  ExProxy.cc
+  ExProxyC.c
+  ExStub.cc
+  ExStubC.c
+  MessageProxy.cc
+  MessageProxyC.c
+  MessageStub.cc
+  MessageStubC.c
+)
+
+ADD_CUSTOM_COMMAND(OUTPUT ${TIDL_GEN_SRCS} PRE_BUILD
+  COMMAND ${TARGET_PREBUILD_SCRIPT} ${TOOL_TIDLC} ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS ${TOOL_TIDLC}
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+ADD_EXECUTABLE(${TARGET_TIDL_BUILD_TESTS}
+  ${TIDL_BUILD_TESTS_SRCS}
+  ${TIDL_GEN_SRCS}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_TIDL_BUILD_TESTS} ${PKGS_LDFLAGS} "-lpthread")
+
+INSTALL(TARGETS ${TARGET_TIDL_BUILD_TESTS} DESTINATION bin)
diff --git a/tests/build_tests/main.cc b/tests/build_tests/main.cc
new file mode 100644 (file)
index 0000000..f24580c
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2021 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 <iostream>
+
+int main(int argc, char** argv) {
+  std::cout << "TIDL Build Test" << std::endl;
+  return 0;
+}
diff --git a/tests/build_tests/prebuild.sh b/tests/build_tests/prebuild.sh
new file mode 100755 (executable)
index 0000000..16a0d63
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+SCRIPT_FILE=$(readlink -f $0)
+SCRIPT_DIR=$(dirname $SCRIPT_FILE)
+TIDLC=$1
+TARGET_DIR=$2
+
+FILES[0]="Message"
+FILES[1]="Buffer"
+FILES[2]="Ex"
+FILES[3]="DataPort"
+FILES[4]="Foo"
+
+GenerateTIDL() {
+  for index in ${!FILES[*]}; do
+    echo "Generate ${FILES[index]}"
+
+    INPUT="${FILES[index]}.tidl"
+    OUTPUT="${FILES[index]}Stub"
+    ${TIDLC} -s -l C++ -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+
+    OUTPUT="${FILES[index]}Proxy"
+    ${TIDLC} -p -l C++ -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+
+    OUTPUT="${FILES[index]}StubC"
+    ${TIDLC} -s -n -l C -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+
+    OUTPUT="${FILES[index]}ProxyC"
+    ${TIDLC} -p -n -l C -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+  done
+}
+
+GenerateTIDL
+
+echo "Done"
diff --git a/tests/build_tests/tidl/Buffer.tidl b/tests/build_tests/tidl/Buffer.tidl
new file mode 100644 (file)
index 0000000..c1525ba
--- /dev/null
@@ -0,0 +1,6 @@
+interface IRemoteBuffer {
+  void BufEvent(array<char> buf) delegate;
+
+  int GetFirst(string id, BufEvent ev, int max_size);
+  int GetNext(string id);
+}
diff --git a/tests/build_tests/tidl/DataPort.tidl b/tests/build_tests/tidl/DataPort.tidl
new file mode 100644 (file)
index 0000000..643d66d
--- /dev/null
@@ -0,0 +1,21 @@
+struct CursorContext {
+  int Handle;
+}
+
+struct Pair {
+  string Key;
+  string Value;
+}
+
+interface DataPort {
+  CursorContext Query(string uri, list<string> projection, string selection, list<string> selectionArgs, string sortOrder);
+  int Insert(string uri, list<Pair> values);
+  int Update(string uri, list<Pair> values, string selection, list<string> selectionArgs);
+  int Delete(string uri, string selection, list<string> selectionArgs);
+
+  bool CursorIsLast(CursorContext cxt);
+  bool CursorMoveToFirst(CursorContext cxt);
+  bool CursorMoveToNext(CursorContext cxt);
+  string CursorGetString(CursorContext cxt, int column);
+  void CursorDispose(CursorContext cxt) async;
+}
diff --git a/tests/build_tests/tidl/Ex.tidl b/tests/build_tests/tidl/Ex.tidl
new file mode 100644 (file)
index 0000000..8a33828
--- /dev/null
@@ -0,0 +1,57 @@
+struct StructTest {
+  int Int;
+  short Short;
+  char Char;
+  bundle Bd;
+  bool Fg;
+  string Str;
+  float Float;
+  double Double;
+  long Long;
+}
+
+struct Student {
+  string name;
+  int num;
+  bundle data;
+  array<char> extra;
+}
+
+struct Class {
+  string name;
+  list<Student> students;
+}
+
+[privilege = "http://tizen.org/privilege/appmanager.launch", privilege = "http://tizen.org/privilege/mediastorage",
+trusted = "true"]
+interface School {
+  void ClassAddedCB(int ret) delegate;
+  int T1(out bool b);
+  int T2(out char c);
+  int T3(out int l);
+  int T4(ref bool b);
+  int T5(ref char c);
+  int T6(ref int l);
+  int T7(out string str);
+  int T8(ref string str);
+  int Test1(out StructTest st);
+  int Test2(StructTest st);
+  int Test3(ref StructTest st);
+  int Test4(out list<StructTest> st);
+  int Test5(list<StructTest> st);
+  int Test6(ref list<StructTest> st);
+
+  /// <summary>
+  /// Add class
+  /// </summary>
+  int AddClass(in Class cls);
+
+  /// <summary>
+  /// Add class async
+  /// </summary>
+  void AddClassAsync(Class cls, ClassAddedCB cb) async;
+
+  int GetStudent(in string c_name, in string s_name, out Student student);
+  int SetAllIds(list<list<int>> nums);
+  int SetExtra(string s_name, array<char> extra);
+}
diff --git a/tests/build_tests/tidl/Foo.tidl b/tests/build_tests/tidl/Foo.tidl
new file mode 100644 (file)
index 0000000..03ac041
--- /dev/null
@@ -0,0 +1,9 @@
+struct Foo {
+  int Age;
+  string Name;
+}
+
+interface Runnable {
+  int Run(Foo foo);
+  list<string> GetNames();
+}
diff --git a/tests/build_tests/tidl/Message.tidl b/tests/build_tests/tidl/Message.tidl
new file mode 100644 (file)
index 0000000..28f45ad
--- /dev/null
@@ -0,0 +1,7 @@
+interface Message {
+  void NotifyCB(string sender, string msg) delegate;
+
+  int Register(string name, NotifyCB cb);
+  void Unregister() async;
+  int Send(string msg);
+}
diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9390822
--- /dev/null
@@ -0,0 +1,53 @@
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wno-unused-function -Wno-sign-compare")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++11")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+
+FIND_PACKAGE(GTest REQUIRED)
+INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
+LINK_DIRECTORIES(${GTEST_LIBRARY_DIRS})
+
+SET(TIDLC_SOURCES
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/document.cc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/declaration.cc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/interface.cc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/type.cc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/parameter.cc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/element.cc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/structure.cc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/block.cc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/gen/generator.cc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/parser.cc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/attribute.cc
+       )
+
+ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"")
+
+AUX_SOURCE_DIRECTORY(. UNIT_TESTS_SOURCES)
+AUX_SOURCE_DIRECTORY(cs_gen CS_GEN_UNIT_TESTS_SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/gen CS_GEN_SOURCES)
+
+FLEX_TARGET(TIDLC ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/tidlc.ll
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/tidlc_l.cpp)
+BISON_TARGET(TIDLC ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/tidlc.yy
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/tidlc_y.cpp)
+
+ADD_EXECUTABLE(${TIDL_UNIT_TESTS}
+       ${BISON_TIDLC_OUTPUTS}
+       ${FLEX_TIDLC_OUTPUTS}
+       ${TIDLC_SOURCES}
+       ${CS_GEN_SOURCES}
+       ${UNIT_TESTS_SOURCES}
+       ${CS_GEN_UNIT_TESTS_SOURCES}
+       )
+TARGET_LINK_LIBRARIES(${TIDL_UNIT_TESTS} ${GTEST_LIBRARIES} pthread)
+
+INSTALL(TARGETS ${TIDL_UNIT_TESTS} DESTINATION bin)
+INSTALL(FILES test.tidl DESTINATION /opt/usr/share/tidl-unit-tests)
+INSTALL(FILES test_error.tidl DESTINATION /opt/usr/share/tidl-unit-tests)
diff --git a/tests/unit_tests/attribute_unittest.cc b/tests/unit_tests/attribute_unittest.cc
new file mode 100644 (file)
index 0000000..e001f4c
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/attribute.h"
+
+class AttributeTest : public testing::Test {
+ public:
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+};
+
+TEST_F(AttributeTest, Attribute_Constructor) {
+  tidl::Attribute* attr = new tidl::Attribute("key", "value", __LINE__);
+  EXPECT_NE(attr, nullptr);
+  delete attr;
+}
+
+TEST_F(AttributeTest, Attribute_GetKey) {
+  tidl::Attribute* attr = new tidl::Attribute("key", "value", __LINE__);
+  EXPECT_NE(attr, nullptr);
+  EXPECT_EQ(attr->GetKey(), "key");
+  delete attr;
+}
+
+TEST_F(AttributeTest, Attribute_GetValue) {
+  tidl::Attribute* attr = new tidl::Attribute("key", "value", __LINE__);
+  EXPECT_NE(attr, nullptr);
+  EXPECT_EQ(attr->GetValue(), "value");
+  delete attr;
+}
+
+TEST_F(AttributeTest, Attribute_GetLine) {
+  unsigned line = __LINE__;
+  tidl::Attribute* attr = new tidl::Attribute("key", "value", line);
+  EXPECT_NE(attr, nullptr);
+  EXPECT_EQ(attr->GetLine(), line);
+  delete attr;
+}
+
+class AttributesTest : public testing::Test {
+ public:
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+};
+
+TEST_F(AttributesTest, Attributes_Constructor) {
+  tidl::Attributes* attrs = new tidl::Attributes();
+  EXPECT_NE(attrs, nullptr);
+  delete attrs;
+}
+
+TEST_F(AttributesTest, Attributes_Add) {
+  tidl::Attributes* attrs = new tidl::Attributes();
+  EXPECT_NE(attrs, nullptr);
+  attrs->Add(new tidl::Attribute("key", "value", __LINE__));
+
+  bool flag = false;
+  for (auto& attr : attrs->GetAttrs()) {
+    if (attr->GetKey() == "key" &&
+        attr->GetValue() == "value")
+      flag = true;
+  }
+  EXPECT_EQ(flag, true);
+  delete attrs;
+}
+
+TEST_F(AttributesTest, Attributes_GetAttrs) {
+  tidl::Attributes* attrs = new tidl::Attributes();
+  EXPECT_NE(attrs, nullptr);
+  attrs->Add(new tidl::Attribute("key1", "value1", __LINE__));
+  attrs->Add(new tidl::Attribute("key2", "value2", __LINE__));
+
+  int count = 0;
+  for (auto& attr : attrs->GetAttrs()) {
+    if (attr->GetKey() == "key1" &&
+        attr->GetValue() == "value1")
+      count++;
+    if (attr->GetKey() == "key2" &&
+        attr->GetValue() == "value2")
+      count++;
+  }
+  EXPECT_EQ(count, 2);
+  delete attrs;
+}
+
+TEST_F(AttributesTest, Attributes_Exist) {
+  tidl::Attributes* attrs = new tidl::Attributes();
+  EXPECT_NE(attrs, nullptr);
+  attrs->Add(new tidl::Attribute("key", "value", __LINE__));
+  tidl::Attribute* attr = new tidl::Attribute("key", "value", __LINE__);
+  EXPECT_NE(attr, nullptr);
+  EXPECT_EQ(attrs->Exist(attr), true);
+  delete attr;
+  delete attrs;
+}
diff --git a/tests/unit_tests/block_unittest.cc b/tests/unit_tests/block_unittest.cc
new file mode 100644 (file)
index 0000000..0659344
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/block.h"
+
+class BlockTest : public testing::Test {
+ public:
+  tidl::Block* testBlock;
+
+  virtual void SetUp() {
+    testBlock = new tidl::Block("TestBlock", tidl::Block::TYPE_INTERFACE,
+        "", 28);
+  }
+  virtual void TearDown() {
+    delete testBlock;
+  }
+};
+
+TEST_F(BlockTest, Block_Constructor) {
+  tidl::Block* block = new tidl::Block("StructureBlock",
+      tidl::Block::TYPE_STRUCTURE, "", __LINE__);
+  EXPECT_NE(block, nullptr);
+  delete block;
+}
+
+TEST_F(BlockTest, Block_GetID) {
+  EXPECT_EQ(testBlock->GetID(), "TestBlock");
+}
+
+TEST_F(BlockTest, Block_GetType) {
+  EXPECT_EQ(testBlock->GetType(), tidl::Block::TYPE_INTERFACE);
+}
+
+TEST_F(BlockTest, Block_GetLine) {
+  EXPECT_EQ(testBlock->GetLine(), 28);
+}
+
+TEST_F(BlockTest, Block_GetComments) {
+  std::string comments = "Test Block";
+  tidl::Block* block = new tidl::Block("StructureBlock",
+      tidl::Block::TYPE_STRUCTURE, comments, __LINE__);
+  EXPECT_NE(block, nullptr);
+  EXPECT_EQ(block->GetComments(), comments);
+  delete block;
+}
diff --git a/tests/unit_tests/cs_gen/cs_proxy_gen_unittest.cc b/tests/unit_tests/cs_gen/cs_proxy_gen_unittest.cc
new file mode 100644 (file)
index 0000000..fd247cf
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/parser.h"
+#include "idlc/gen/cs_proxy_gen.h"
+
+class CsProxyGenTest : public testing::Test {
+ public:
+  tidl::Parser* ps = nullptr;
+
+  virtual void SetUp() {
+    ps = new tidl::Parser();
+  }
+
+  virtual void TearDown() {
+    delete ps;
+  }
+
+  bool FindStringFromFile(std::string filename, std::string str) {
+    std::ifstream cb_file(filename);
+    std::string line;
+
+    while (std::getline(cb_file, line)) {
+      if (line.find(str) == 0) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+};
+
+TEST_F(CsProxyGenTest, CsProxyGen_Constructor) {
+  bool ret = ps->ParseFromFile("test.tidl");
+  ASSERT_TRUE(ret);
+  tidl::CsProxyGen gen(ps->GetDoc());
+}
+
+TEST_F(CsProxyGenTest, CsProxyGen_Run) {
+  bool ret = ps->ParseFromFile("test.tidl");
+  ASSERT_TRUE(ret);
+  tidl::CsProxyGen gen(ps->GetDoc());
+  gen.Run("test.cs");
+
+  ASSERT_TRUE(FindStringFromFile("test.cs", "namespace RPCPort"));
+  ASSERT_TRUE(FindStringFromFile("test.cs",
+      "    public sealed class Student"));
+  ASSERT_TRUE(FindStringFromFile("test.cs",
+      "        public string name { get; set; }"));
+  ASSERT_TRUE(FindStringFromFile("test.cs", "    public sealed class Class"));
+  ASSERT_TRUE(FindStringFromFile("test.cs",
+      "        public LinkedList<Student> students { get; set; }"));
+}
diff --git a/tests/unit_tests/cs_gen/cs_stub_gen_unittest.cc b/tests/unit_tests/cs_gen/cs_stub_gen_unittest.cc
new file mode 100644 (file)
index 0000000..512c6de
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/parser.h"
+#include "idlc/gen/cs_stub_gen.h"
+
+class CsStubGenTest : public testing::Test {
+ public:
+  tidl::Parser* ps = nullptr;
+
+  virtual void SetUp() {
+    ps = new tidl::Parser();
+  }
+
+  virtual void TearDown() {
+    delete ps;
+  }
+
+  bool FindStringFromFile(std::string filename, std::string str) {
+    std::ifstream cb_file(filename);
+    std::string line;
+
+    while (std::getline(cb_file, line)) {
+      if (line.find(str) == 0) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+};
+
+TEST_F(CsStubGenTest, CsStubGen_Constructor) {
+  bool ret = ps->ParseFromFile("test.tidl");
+  ASSERT_TRUE(ret);
+  tidl::CsStubGen gen(ps->GetDoc());
+}
+
+TEST_F(CsStubGenTest, CsStubGen_Run) {
+  bool ret = ps->ParseFromFile("test.tidl");
+  ASSERT_TRUE(ret);
+  tidl::CsStubGen gen(ps->GetDoc());
+  gen.Run("test_stub.cs");
+
+  ASSERT_TRUE(FindStringFromFile("test_stub.cs", "namespace RPCPort"));
+  ASSERT_TRUE(FindStringFromFile("test_stub.cs",
+      "    public sealed class Student"));
+  ASSERT_TRUE(FindStringFromFile("test_stub.cs",
+      "        public string name { get; set; }"));
+  ASSERT_TRUE(FindStringFromFile("test_stub.cs",
+      "    public sealed class Class"));
+  ASSERT_TRUE(FindStringFromFile("test_stub.cs",
+      "        public LinkedList<Student> students { get; set; }"));
+}
diff --git a/tests/unit_tests/declaration_unittest.cc b/tests/unit_tests/declaration_unittest.cc
new file mode 100644 (file)
index 0000000..776341d
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/declaration.h"
+#include "idlc/ast/type.h"
+#include "idlc/ast/parameter.h"
+
+class DeclarationTest : public testing::Test {
+ public:
+  tidl::Parameters* params;
+
+  virtual void SetUp() {
+    params = new tidl::Parameters();
+    EXPECT_NE(params, nullptr);
+    params->Add(new tidl::Parameter("test1",
+          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+    params->Add(new tidl::Parameter("test2",
+          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+  }
+  virtual void TearDown() {}
+};
+
+TEST_F(DeclarationTest, Declaration_Constructor) {
+  tidl::Declaration* decl = new tidl::Declaration("test",
+      new tidl::BaseType("int", ""), params, "", __LINE__);
+  EXPECT_NE(decl, nullptr);
+  delete decl;
+}
+
+TEST_F(DeclarationTest, Declaration_GetID) {
+  tidl::Declaration* decl = new tidl::Declaration("test",
+      new tidl::BaseType("int", ""), params, "", __LINE__);
+  EXPECT_NE(decl, nullptr);
+  EXPECT_EQ(decl->GetID(), "test");
+  delete decl;
+}
+
+TEST_F(DeclarationTest, Declaration_GetType) {
+  tidl::Declaration* decl = new tidl::Declaration("test",
+      new tidl::BaseType("int", ""), params, "", __LINE__);
+  EXPECT_NE(decl, nullptr);
+  EXPECT_EQ(decl->GetType().ToString(), "int");
+  delete decl;
+}
+
+TEST_F(DeclarationTest, Declaration_GetParameters) {
+  tidl::Declaration* decl = new tidl::Declaration("test",
+      new tidl::BaseType("int", ""), params, "", __LINE__);
+  EXPECT_NE(decl, nullptr);
+
+  int count = 0;
+  for (auto& param : decl->GetParameters().GetParams()) {
+    if (param->GetID() == "test1" &&
+        param->GetParameterType().GetBaseType().ToString() == "int")
+      count++;
+    if (param->GetID() == "test2" &&
+        param->GetParameterType().GetBaseType().ToString() == "int")
+      count++;
+  }
+  EXPECT_EQ(count, 2);
+
+  delete decl;
+}
+
+TEST_F(DeclarationTest, Declaration_GetMethodType) {
+  tidl::Declaration* decl = new tidl::Declaration("test",
+      new tidl::BaseType("int", ""), params, "", __LINE__,
+      tidl::Declaration::MethodType::DELEGATE);
+  EXPECT_NE(decl, nullptr);
+  EXPECT_EQ(decl->GetMethodType(), tidl::Declaration::MethodType::DELEGATE);
+  delete decl;
+}
+
+TEST_F(DeclarationTest, Declaration_GetComments) {
+  std::string comments = "Test Declaration";
+  tidl::Declaration* decl = new tidl::Declaration("test",
+      new tidl::BaseType("int", ""), params, comments, __LINE__);
+  EXPECT_NE(decl, nullptr);
+  EXPECT_EQ(decl->GetComments(), comments);
+  delete decl;
+}
+
+TEST_F(DeclarationTest, Declaration_GetLine) {
+  unsigned line = __LINE__;
+  tidl::Declaration* decl = new tidl::Declaration("test",
+      new tidl::BaseType("int", ""), params, "", line);
+  EXPECT_NE(decl, nullptr);
+  EXPECT_EQ(decl->GetLine(), line);
+  delete decl;
+}
+
+class DeclarationsTest : public testing::Test {
+ public:
+  tidl::Declaration* decl;
+
+  virtual void SetUp() {}
+  virtual void TestDown() {}
+  void PrepareDeclaration() {
+    tidl::Parameters* params = new tidl::Parameters();
+    EXPECT_NE(params, nullptr);
+    params->Add(new tidl::Parameter("test1",
+          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+    params->Add(new tidl::Parameter("test2",
+          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+    decl = new tidl::Declaration("test",
+        new tidl::BaseType("int", ""), params, "", __LINE__);
+    EXPECT_NE(decl, nullptr);
+  }
+};
+
+TEST_F(DeclarationsTest, Declarations_Constructor) {
+  tidl::Declarations* decls = new tidl::Declarations();
+  EXPECT_NE(decls, nullptr);
+  delete decls;
+}
+
+TEST_F(DeclarationsTest, Declarations_Add) {
+  tidl::Declarations* decls = new tidl::Declarations();
+  EXPECT_NE(decls, nullptr);
+  PrepareDeclaration();
+  decls->Add(decl);
+
+  bool flag = false;
+  for (auto& d : decls->GetDecls()) {
+    if (d->GetID() == "test")
+      flag = true;
+  }
+  EXPECT_EQ(flag, true);
+  delete decls;
+}
+
+TEST_F(DeclarationsTest, Declarations_GetDecls) {
+  tidl::Declarations* decls = new tidl::Declarations();
+  EXPECT_NE(decls, nullptr);
+  PrepareDeclaration();
+  decls->Add(decl);
+
+  bool flag = false;
+  for (auto& d : decls->GetDecls()) {
+    if (d->GetID() == "test")
+      flag = true;
+  }
+  EXPECT_EQ(flag, true);
+  delete decls;
+}
+
+TEST_F(DeclarationsTest, Declarations_Exist) {
+  tidl::Declarations* decls = new tidl::Declarations();
+  EXPECT_NE(decls, nullptr);
+  PrepareDeclaration();
+  decls->Add(decl);
+  tidl::Parameters* testParams = new tidl::Parameters();
+  EXPECT_NE(testParams, nullptr);
+  testParams->Add(new tidl::Parameter("test1",
+        new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+  tidl::Declaration* testDecl = new tidl::Declaration("test",
+        new tidl::BaseType("int", ""), testParams, "", __LINE__);
+  EXPECT_NE(testDecl, nullptr);
+  EXPECT_EQ(decls->Exist(testDecl), true);
+  delete testDecl;
+  delete decls;
+}
diff --git a/tests/unit_tests/document_unittest.cc b/tests/unit_tests/document_unittest.cc
new file mode 100644 (file)
index 0000000..31e6c1b
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/document.h"
+#include "idlc/ast/block.h"
+
+class DocumentTest : public testing::Test {
+ public:
+  tidl::Block* block;
+  tidl::Document* document;
+
+  virtual void SetUp() {
+    document = new tidl::Document();
+    block = new tidl::Block("TestBlock", tidl::Block::TYPE_INTERFACE,
+        "", __LINE__);
+  }
+  virtual void TearDown() {
+  }
+};
+
+TEST_F(DocumentTest, Document_Constructor) {
+  tidl::Document *doc = new tidl::Document();
+  EXPECT_NE(doc, nullptr);
+  delete doc;
+}
+
+TEST_F(DocumentTest, Document_AddBlock) {
+  document->AddBlock(block);
+  bool flag = false;
+  for (auto& blk : document->GetBlocks()) {
+    if (blk->GetID() == "TestBlock")
+      flag = true;
+  }
+  EXPECT_NE(flag, false);
+}
+
+TEST_F(DocumentTest, Document_GetBlocks) {
+  document->AddBlock(block);
+  bool flag = false;
+  for (auto& blk : document->GetBlocks()) {
+    if (blk->GetType() == tidl::Block::TYPE_INTERFACE)
+      flag = true;
+  }
+  EXPECT_NE(flag, false);
+}
+
+TEST_F(DocumentTest, Document_ExistBlock) {
+  document->AddBlock(block);
+  tidl::Block* testBlock = new tidl::Block("TestBlock",
+      tidl::Block::TYPE_INTERFACE, "", __LINE__);
+  EXPECT_NE(testBlock, nullptr);
+  EXPECT_EQ(document->ExistBlock(testBlock), true);
+  delete testBlock;
+}
diff --git a/tests/unit_tests/element_unittest.cc b/tests/unit_tests/element_unittest.cc
new file mode 100644 (file)
index 0000000..8ef351c
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/element.h"
+
+class ElementTest : public testing::Test {
+ public:
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+};
+
+TEST_F(ElementTest, Element_Contstructor) {
+  tidl::Element* elm = new tidl::Element("test",
+      new tidl::BaseType("int", ""), "", __LINE__);
+  EXPECT_NE(elm, nullptr);
+  delete elm;
+}
+
+TEST_F(ElementTest, Element_GetID) {
+  tidl::Element* elm = new tidl::Element("test",
+      new tidl::BaseType("int", ""), "", __LINE__);
+  EXPECT_NE(elm, nullptr);
+  EXPECT_EQ(elm->GetID(), "test");
+  delete elm;
+}
+
+TEST_F(ElementTest, Element_GetType) {
+  tidl::Element* elm = new tidl::Element("test",
+      new tidl::BaseType("int", ""), "", __LINE__);
+  EXPECT_NE(elm, nullptr);
+  EXPECT_EQ(elm->GetType().ToString(), "int");
+  delete elm;
+}
+
+TEST_F(ElementTest, Element_GetLine) {
+  unsigned line = __LINE__;
+  tidl::Element* elm = new tidl::Element("test",
+      new tidl::BaseType("int", ""), "", line);
+  EXPECT_NE(elm, nullptr);
+  EXPECT_EQ(elm->GetLine(), line);
+  delete elm;
+}
+
+TEST_F(ElementTest, Element_GetComments) {
+  std::string comments = "Test comments";
+  tidl::Element* elm = new tidl::Element("test",
+      new tidl::BaseType("int", ""), comments, __LINE__);
+  EXPECT_NE(elm, nullptr);
+  EXPECT_EQ(elm->GetComments(), comments);
+  delete elm;
+}
+
+class ElementsTest : public testing::Test {
+ public:
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+};
+
+TEST_F(ElementsTest, Elements_Constructor) {
+  tidl::Elements* elms = new tidl::Elements();
+  EXPECT_NE(elms, nullptr);
+  delete elms;
+}
+
+TEST_F(ElementsTest, Elements_Add) {
+  tidl::Element* elm = new tidl::Element("test",
+      new tidl::BaseType("int", ""), "", __LINE__);
+  EXPECT_NE(elm, nullptr);
+  tidl::Elements* elms = new tidl::Elements();
+  EXPECT_NE(elms, nullptr);
+  elms->Add(elm);
+
+  bool flag = false;
+  for (auto& elm : elms->GetElms()) {
+    if (elm->GetID() == "test" &&
+        elm->GetType().ToString() == "int")
+      flag = true;
+  }
+  EXPECT_EQ(flag, true);
+  delete elms;
+}
+
+TEST_F(ElementsTest, Elements_Getelms) {
+  tidl::Elements* elms = new tidl::Elements();
+  EXPECT_NE(elms, nullptr);
+  elms->Add(new tidl::Element("test1", new tidl::BaseType("int", ""),
+      "", __LINE__));
+  elms->Add(new tidl::Element("test2", new tidl::BaseType("char *", ""),
+      "", __LINE__));
+
+  int count = 0;
+  for (auto& elm : elms->GetElms()) {
+    if (elm->GetID() == "test1" &&
+        elm->GetType().ToString() == "int")
+      count++;
+    if (elm->GetID() == "test2" &&
+        elm->GetType().ToString() == "char *")
+      count++;
+  }
+  EXPECT_EQ(count, 2);
+  delete elms;
+}
+
+TEST_F(ElementsTest, Elements_Exist) {
+  tidl::Element* elm = new tidl::Element("test",
+      new tidl::BaseType("int", ""), "", __LINE__);
+  EXPECT_NE(elm, nullptr);
+  tidl::Elements* elms = new tidl::Elements();
+  EXPECT_NE(elms, nullptr);
+  elms->Add(elm);
+  tidl::Element* elm2 = new tidl::Element("test",
+      new tidl::BaseType("int", ""), "", __LINE__);
+  EXPECT_NE(elm, nullptr);
+  EXPECT_EQ(elms->Exist(elm2), true);
+  delete elm2;
+  delete elms;
+}
diff --git a/tests/unit_tests/generator_unittest.cc b/tests/unit_tests/generator_unittest.cc
new file mode 100644 (file)
index 0000000..7573025
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+#include <memory>
+
+#include "idlc/gen/generator.h"
+#include "idlc/ast/interface.h"
+#include "idlc/ast/structure.h"
+#include "idlc/ast/attribute.h"
+
+class SampleGenerator : public tidl::Generator {
+ public:
+  explicit SampleGenerator(std::shared_ptr<tidl::Document> doc)
+      : tidl::Generator(doc), count_(0) {}
+  ~SampleGenerator() {}
+
+  void OnInitGen(std::ofstream& stream) override {
+    count_++;
+  }
+  void OnFiniGen(std::ofstream& stream) override {
+    count_++;
+  }
+
+  int GetCount() {
+    return count_;
+  }
+
+ private:
+  int count_;
+};
+
+class GeneratorTest : public testing::Test {
+ public:
+  SampleGenerator* gen;
+
+  virtual void SetUp() {
+    gen = new SampleGenerator(
+        std::shared_ptr<tidl::Document>(new tidl::Document()));
+  }
+  virtual void TearDown() {
+    delete gen;
+  }
+};
+
+TEST_F(GeneratorTest, Generator_Constructor) {
+  EXPECT_NE(gen, nullptr);
+}
+
+TEST_F(GeneratorTest, Generator_Run) {
+  EXPECT_NE(gen, nullptr);
+  gen->Run("test.out");
+  EXPECT_EQ(gen->GetCount(), 2);
+}
diff --git a/tests/unit_tests/interface_unittest.cc b/tests/unit_tests/interface_unittest.cc
new file mode 100644 (file)
index 0000000..780aca5
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/interface.h"
+
+class InterfaceTest : public testing::Test {
+ public:
+  tidl::Declarations* decls;
+
+  virtual void SetUp() {
+    tidl::Parameters* params = new tidl::Parameters();
+    EXPECT_NE(params, nullptr);
+    params->Add(new tidl::Parameter("test1",
+          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+    params->Add(new tidl::Parameter("test2",
+          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+    tidl::Declaration* decl = new tidl::Declaration("test",
+        new tidl::BaseType("int", ""), params, "", __LINE__);
+    EXPECT_NE(decl, nullptr);
+    decls = new tidl::Declarations();
+    EXPECT_NE(decls, nullptr);
+    decls->Add(decl);
+  }
+  virtual void TearDown() {}
+};
+
+TEST_F(InterfaceTest, Interface_Constructor) {
+  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
+      "", new tidl::Attributes(), __LINE__);
+  EXPECT_NE(interface, nullptr);
+  delete interface;
+}
+
+TEST_F(InterfaceTest, Interface_GetDeclrations) {
+  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
+      "", new tidl::Attributes(), __LINE__);
+  EXPECT_NE(interface, nullptr);
+
+  bool flag = false;
+  for (auto& d : interface->GetDeclarations().GetDecls()) {
+    if (d->GetID() == "test")
+      flag = true;
+  }
+  EXPECT_EQ(flag, true);
+  delete interface;
+}
+
+TEST_F(InterfaceTest, Interface_GetID) {
+  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
+      "", new tidl::Attributes(), __LINE__);
+  EXPECT_NE(interface, nullptr);
+  EXPECT_EQ(interface->GetID(), "TestInterface");
+  delete interface;
+}
+
+TEST_F(InterfaceTest, Interface_GetType) {
+  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
+      "", new tidl::Attributes(), __LINE__);
+  EXPECT_NE(interface, nullptr);
+  EXPECT_EQ(interface->GetType(), tidl::Interface::TYPE_INTERFACE);
+  delete interface;
+}
+
+TEST_F(InterfaceTest, Interface_GetLine) {
+  unsigned line = __LINE__;
+  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
+      "", new tidl::Attributes(), line);
+  EXPECT_NE(interface, nullptr);
+  EXPECT_EQ(interface->GetLine(), line);
+  delete interface;
+}
+
+TEST_F(InterfaceTest, Interface_GetComments) {
+  std::string comments = "Test Interface";
+  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
+      comments, new tidl::Attributes(), __LINE__);
+  EXPECT_NE(interface, nullptr);
+  EXPECT_EQ(interface->GetComments(), comments);
+  delete interface;
+}
+
diff --git a/tests/unit_tests/main.cc b/tests/unit_tests/main.cc
new file mode 100644 (file)
index 0000000..a2e3a75
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+int gargc;
+char** gargv;
+
+int main(int argc, char** argv) {
+  gargc = argc;
+  gargv = argv;
+
+  testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
diff --git a/tests/unit_tests/parser_unittest.cc b/tests/unit_tests/parser_unittest.cc
new file mode 100644 (file)
index 0000000..748e33a
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/parser.h"
+
+extern int gargc;
+extern char** gargv;
+
+class ParserTest : public testing::Test {
+ public:
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+};
+
+TEST_F(ParserTest, Parser_Constructor) {
+  tidl::Parser* ps = new tidl::Parser();
+  EXPECT_NE(ps, nullptr);
+  delete ps;
+}
+
+TEST_F(ParserTest, Parser_Scanner) {
+  tidl::Parser* ps = new tidl::Parser();
+  EXPECT_NE(ps, nullptr);
+  EXPECT_NE(ps->Scanner(), nullptr);
+  delete ps;
+}
+
+TEST_F(ParserTest, Parser_SetDoc) {
+  tidl::Parser* ps = new tidl::Parser();
+  EXPECT_NE(ps, nullptr);
+  ps->SetDoc(new tidl::Document());
+  EXPECT_NE(ps->GetDoc(), nullptr);
+  delete ps;
+}
+
+TEST_F(ParserTest, Parser_GetDoc) {
+  tidl::Parser* ps = new tidl::Parser();
+  EXPECT_NE(ps, nullptr);
+  ps->SetDoc(new tidl::Document());
+  EXPECT_NE(ps->GetDoc(), nullptr);
+  delete ps;
+}
+
+TEST_F(ParserTest, Parser_Parse) {
+  tidl::Parser* ps = new tidl::Parser();
+  EXPECT_NE(ps, nullptr);
+  std::string input = "interface ParserTest { int test(in int a); }";
+  EXPECT_EQ(ps->Parse(input), true);
+  delete ps;
+}
+
+TEST_F(ParserTest, Parser_ParseFromFile) {
+  tidl::Parser* ps = new tidl::Parser();
+  EXPECT_NE(ps, nullptr);
+
+  std::string file = "test.tidl";
+  if (gargc > 1)
+    file = gargv[1];
+  EXPECT_EQ(ps->ParseFromFile(file), true);
+  delete ps;
+}
+
+TEST_F(ParserTest, Parser_ParseFromFile_N) {
+  tidl::Parser* ps = new tidl::Parser();
+  EXPECT_NE(ps, nullptr);
+
+  std::string file = "test_error.tidl";
+  if (gargc > 2)
+    file = gargv[2];
+  EXPECT_EQ(ps->ParseFromFile(file), false);
+  delete ps;
+}
diff --git a/tests/unit_tests/structure_unittest.cc b/tests/unit_tests/structure_unittest.cc
new file mode 100644 (file)
index 0000000..4e68e98
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/structure.h"
+
+class StructureTest : public testing::Test {
+ public:
+  tidl::Elements* elms;
+
+  virtual void SetUp() {
+    elms = new tidl::Elements();
+    EXPECT_NE(elms, nullptr);
+    elms->Add(new tidl::Element("test1", new tidl::BaseType("int", ""),
+        "", __LINE__));
+    elms->Add(new tidl::Element("test2", new tidl::BaseType("char *", ""),
+        "", __LINE__));
+  }
+  virtual void TearDown() {}
+};
+
+TEST_F(StructureTest, Structure_Constructor) {
+  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
+      "", __LINE__);
+  EXPECT_NE(structure, nullptr);
+  delete structure;
+}
+
+TEST_F(StructureTest, Structure_GetElements) {
+  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
+      "", __LINE__);
+  EXPECT_NE(structure, nullptr);
+
+  int count = 0;
+  for (auto& elm : elms->GetElms()) {
+    if (elm->GetID() == "test1" &&
+        elm->GetType().ToString() == "int")
+      count++;
+    if (elm->GetID() == "test2" &&
+        elm->GetType().ToString() == "char *")
+      count++;
+  }
+  EXPECT_EQ(count, 2);
+  delete structure;
+}
+
+TEST_F(StructureTest, Structure_GetID) {
+  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
+      "", __LINE__);
+  EXPECT_NE(structure, nullptr);
+  EXPECT_EQ(structure->GetID(), "TestStructure");
+  delete structure;
+}
+
+TEST_F(StructureTest, Structure_GetType) {
+  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
+      "", __LINE__);
+  EXPECT_NE(structure, nullptr);
+  EXPECT_EQ(structure->GetType(), tidl::Structure::TYPE_STRUCTURE);
+  delete structure;
+}
+
+TEST_F(StructureTest, Structure_GetLine) {
+  unsigned line = __LINE__;
+  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
+      "", line);
+  EXPECT_NE(structure, nullptr);
+  EXPECT_EQ(structure->GetLine(), line);
+  delete structure;
+}
+
+TEST_F(StructureTest, Structure_GetComments) {
+  std::string comments = "Test Structure";
+  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
+      comments, __LINE__);
+  EXPECT_NE(structure, nullptr);
+  EXPECT_EQ(structure->GetComments(), comments);
+  delete structure;
+}
diff --git a/tests/unit_tests/test.tidl b/tests/unit_tests/test.tidl
new file mode 100644 (file)
index 0000000..2624814
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017 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.
+ */
+
+struct Student {
+       string name;
+       int num;
+       bundle data;
+       array<char> tag;
+}
+
+// Annotation Test!!
+// Structure Class
+struct Class {
+       /* string name attr */
+       string name;
+       list<Student> students;
+}
+
+/* Interface School! */
+[privilege = "http://tizen.org/privilege/appmanager.launch", privilege = "http://tizen.org/privilege/appmanager.kill"]
+interface School {
+       /* Method section */
+       /* Method AddClass */
+       int AddClass(in Class cls);
+       /* Method GetStudent */
+       int GetStudent(in string c_name, in string s_name, out Student student);
+       string GetName(out string name);
+       int SetName(in string name);
+}
diff --git a/tests/unit_tests/test_error.tidl b/tests/unit_tests/test_error.tidl
new file mode 100644 (file)
index 0000000..ca6475d
--- /dev/null
@@ -0,0 +1,53 @@
+struct Student {
+       string name;
+       int num;
+       bundle data;
+}
+
+struct Class {
+       string name;
+       list<Student> students;
+}
+
+interface School {
+       int AddClass(in Class cls);
+       int GetStudent(in string c_name, in string s_name, out Student student);
+}
+
+interface School {
+       int RemoveStudent(in string name);
+}
+
+struct {
+       string k;
+}
+
+interface {
+       int test(int a);
+}
+
+struct ErrorAttrMissingName1 {
+       string;
+}
+
+interface ErrorAttrMissingName2 {
+       int (int a);
+}
+
+interface ErrorMethod {
+       void RemoveClass(in class cls);
+}
+
+interface ErrorMethodDupMethod {
+       int GetStudent(in string c_name, out Student student);
+       int GetStudent(in string c_name, out Student student);
+}
+
+struct ErrorMethodDupAttr {
+       string name;
+       string name;
+}
+
+interface ErrorMethodInvalidType {
+       int AddStudent(in string name) async;
+}
diff --git a/tests/unit_tests/type_unittest.cc b/tests/unit_tests/type_unittest.cc
new file mode 100644 (file)
index 0000000..677e096
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2017 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 <gtest/gtest.h>
+
+#include <iostream>
+
+#include "idlc/ast/type.h"
+
+class TokenTest : public testing::Test {
+ public:
+  tidl::Token* testToken;
+
+  virtual void SetUp() {
+    testToken = new tidl::Token("TestToken", "Test Token");
+  }
+  virtual void TearDown() {
+    delete testToken;
+  }
+};
+
+TEST_F(TokenTest, Token_Constructor) {
+  tidl::Token* token = new tidl::Token("TestToken", "");
+  EXPECT_NE(token, nullptr);
+  delete token;
+}
+
+TEST_F(TokenTest, Token_ToString) {
+  EXPECT_EQ(testToken->ToString(), "TestToken");
+}
+
+TEST_F(TokenTest, Token_GetComments) {
+  EXPECT_EQ(testToken->GetComments(), "Test Token");
+}
+
+class BaseTypeTest : public testing::Test {
+ public:
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+};
+
+TEST_F(BaseTypeTest, BaseType_Constructor) {
+  tidl::BaseType* baseType = new tidl::BaseType("BaseType", "");
+  EXPECT_NE(baseType, nullptr);
+  delete baseType;
+}
+
+TEST_F(BaseTypeTest, BaseType_SetMetaType) {
+  tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
+  customType->SetMetaType(new tidl::BaseType("int", ""));
+  EXPECT_NE(customType->GetMetaType(), nullptr);
+  EXPECT_EQ(customType->GetMetaType()->ToString(), "int");
+  delete customType;
+}
+
+TEST_F(BaseTypeTest, BaseType_GetMetaType) {
+  tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
+  customType->SetMetaType(new tidl::BaseType("string", ""));
+  EXPECT_NE(customType->GetMetaType(), nullptr);
+  EXPECT_EQ(customType->GetMetaType()->ToString(), "string");
+  delete customType;
+}
+
+TEST_F(BaseTypeTest, BaseType_GetFullName) {
+  tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
+  customType->SetMetaType(new tidl::BaseType("string", ""));
+  EXPECT_EQ(customType->GetFullName(), "CustomType<string>");
+  delete customType;
+}
+
+TEST_F(BaseTypeTest, BaseType_IsUserDefinedType) {
+  tidl::BaseType* testType = new tidl::BaseType("TestType", "", true);
+  EXPECT_EQ(testType->IsUserDefinedType(), true);
+  delete testType;
+}
+
+TEST_F(BaseTypeTest, BaseType_GetComments) {
+  std::string comments = "Test BaseType";
+  tidl::BaseType* testType = new tidl::BaseType("TestType", comments, true);
+  EXPECT_NE(testType, nullptr);
+  EXPECT_EQ(testType->GetComments(), comments);
+  delete testType;
+}
+
+class ParameterTypeTest : public testing::Test {
+ public:
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+};
+
+TEST_F(ParameterTypeTest, ParameterType_Constructor) {
+  tidl::ParameterType *parameterType = new tidl::ParameterType(
+      new tidl::BaseType("int", ""));
+  EXPECT_NE(parameterType, nullptr);
+  delete parameterType;
+}
+
+TEST_F(ParameterTypeTest, ParameterType_Constructor_With_Direction) {
+  tidl::ParameterType *parameterType = new tidl::ParameterType(
+      new tidl::BaseType("int", ""), "in");
+  EXPECT_NE(parameterType, nullptr);
+  delete parameterType;
+}
+
+TEST_F(ParameterTypeTest, ParameterType_GetDirection) {
+  tidl::ParameterType *parameterType = new tidl::ParameterType(
+      new tidl::BaseType("int", ""), "out");
+  EXPECT_NE(parameterType, nullptr);
+  EXPECT_EQ(parameterType->GetDirection(), tidl::ParameterType::Direction::OUT);
+  delete parameterType;
+}
+
+TEST_F(ParameterTypeTest, ParameterType_GetBaseType) {
+  tidl::ParameterType *parameterType = new tidl::ParameterType(
+      new tidl::BaseType("string", ""), "ref");
+  EXPECT_NE(parameterType, nullptr);
+  EXPECT_EQ(parameterType->GetBaseType().ToString(),
+      "string");
+  delete parameterType;
+}
diff --git a/tests/unit_tests/unit_tests.sh b/tests/unit_tests/unit_tests.sh
new file mode 100755 (executable)
index 0000000..36fce76
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+#--------------------------------------------------------#
+# Tizen Interface Definition Langauge Compiler Unit Test #
+#--------------------------------------------------------#
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+SCRIPT_FILE=$(readlink -f $0)
+SCRIPT_DIR=$(dirname $SCRIPT_FILE)
+BUILD_DIR=build
+
+usage() {
+       echo "Usage: $0 [command]"
+       echo "Commands:"
+       echo "    build              Build the unit tests"
+       echo "    clean              Clean all artifacts"
+       echo "    run                Run the unit tests"
+       echo "    full               Build & Run the unit tests"
+}
+
+cmd_build() {
+       echo "[TIDL Unit Test] Build Unit Tests"
+       mkdir -p $SCRIPT_DIR/$BUILD_DIR
+       cd $SCRIPT_DIR/$BUILD_DIR
+       cmake ..
+       make clean
+       make
+}
+
+cmd_clean() {
+       echo "[TIDL Unit Test] Clean all artifacts"
+       rm -rf $SCRIPT_DIR/$BUILD_DIR
+}
+
+cmd_run() {
+       echo "[TIDL Unit Test] Run Unit Tests"
+       cd $SCRIPT_DIR/$BUILD_DIR
+       $SCRIPT_DIR/$BUILD_DIR/tidl-unit-tests $SCRIPT_DIR/test.tidl $SCRIPT_DIR/test_error.tidl
+       cd $SCRIPT_DIR
+}
+
+cmd_full() {
+       cmd_build
+       cmd_run
+       cmd_clean
+}
+
+cmd=$1; shift;
+case "$cmd" in
+       build|--build|-b) cmd_build $@ ;;
+       clean|--clean|-c) cmd_clean $@ ;;
+       run|--run|-r) cmd_run $@ ;;
+       full |--full |-f)  cmd_full $@ ;;
+       *)     usage ;;
+
+esac
diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt
deleted file mode 100644 (file)
index 96849aa..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wno-unused-function -Wno-sign-compare")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++11")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
-
-FIND_PACKAGE(GTest REQUIRED)
-INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
-LINK_DIRECTORIES(${GTEST_LIBRARY_DIRS})
-
-SET(TIDLC_SOURCES
-       ${CMAKE_SOURCE_DIR}/idlc/ast/document.cc
-       ${CMAKE_SOURCE_DIR}/idlc/ast/declaration.cc
-       ${CMAKE_SOURCE_DIR}/idlc/ast/interface.cc
-       ${CMAKE_SOURCE_DIR}/idlc/ast/type.cc
-       ${CMAKE_SOURCE_DIR}/idlc/ast/parameter.cc
-       ${CMAKE_SOURCE_DIR}/idlc/ast/element.cc
-       ${CMAKE_SOURCE_DIR}/idlc/ast/structure.cc
-       ${CMAKE_SOURCE_DIR}/idlc/ast/block.cc
-       ${CMAKE_SOURCE_DIR}/idlc/gen/generator.cc
-       ${CMAKE_SOURCE_DIR}/idlc/ast/parser.cc
-       ${CMAKE_SOURCE_DIR}/idlc/ast/attribute.cc
-       )
-
-ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"")
-
-AUX_SOURCE_DIRECTORY(. UNIT_TESTS_SOURCES)
-AUX_SOURCE_DIRECTORY(cs_gen CS_GEN_UNIT_TESTS_SOURCES)
-AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/idlc/gen CS_GEN_SOURCES)
-
-FLEX_TARGET(TIDLC ${CMAKE_SOURCE_DIR}/idlc/ast/tidlc.ll ${CMAKE_SOURCE_DIR}/idlc/ast/tidlc_l.cpp)
-BISON_TARGET(TIDLC ${CMAKE_SOURCE_DIR}/idlc/ast/tidlc.yy ${CMAKE_SOURCE_DIR}/idlc/ast/tidlc_y.cpp)
-
-ADD_EXECUTABLE(${TIDL_UNIT_TESTS}
-       ${BISON_TIDLC_OUTPUTS}
-       ${FLEX_TIDLC_OUTPUTS}
-       ${TIDLC_SOURCES}
-       ${CS_GEN_SOURCES}
-       ${UNIT_TESTS_SOURCES}
-       ${CS_GEN_UNIT_TESTS_SOURCES}
-       )
-TARGET_LINK_LIBRARIES(${TIDL_UNIT_TESTS} ${GTEST_LIBRARIES} pthread)
-
-INSTALL(TARGETS ${TIDL_UNIT_TESTS} DESTINATION bin)
-INSTALL(FILES test.tidl DESTINATION /opt/usr/share/tidl-unit-tests)
-INSTALL(FILES test_error.tidl DESTINATION /opt/usr/share/tidl-unit-tests)
diff --git a/unit_tests/attribute_unittest.cc b/unit_tests/attribute_unittest.cc
deleted file mode 100644 (file)
index e001f4c..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/attribute.h"
-
-class AttributeTest : public testing::Test {
- public:
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-};
-
-TEST_F(AttributeTest, Attribute_Constructor) {
-  tidl::Attribute* attr = new tidl::Attribute("key", "value", __LINE__);
-  EXPECT_NE(attr, nullptr);
-  delete attr;
-}
-
-TEST_F(AttributeTest, Attribute_GetKey) {
-  tidl::Attribute* attr = new tidl::Attribute("key", "value", __LINE__);
-  EXPECT_NE(attr, nullptr);
-  EXPECT_EQ(attr->GetKey(), "key");
-  delete attr;
-}
-
-TEST_F(AttributeTest, Attribute_GetValue) {
-  tidl::Attribute* attr = new tidl::Attribute("key", "value", __LINE__);
-  EXPECT_NE(attr, nullptr);
-  EXPECT_EQ(attr->GetValue(), "value");
-  delete attr;
-}
-
-TEST_F(AttributeTest, Attribute_GetLine) {
-  unsigned line = __LINE__;
-  tidl::Attribute* attr = new tidl::Attribute("key", "value", line);
-  EXPECT_NE(attr, nullptr);
-  EXPECT_EQ(attr->GetLine(), line);
-  delete attr;
-}
-
-class AttributesTest : public testing::Test {
- public:
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-};
-
-TEST_F(AttributesTest, Attributes_Constructor) {
-  tidl::Attributes* attrs = new tidl::Attributes();
-  EXPECT_NE(attrs, nullptr);
-  delete attrs;
-}
-
-TEST_F(AttributesTest, Attributes_Add) {
-  tidl::Attributes* attrs = new tidl::Attributes();
-  EXPECT_NE(attrs, nullptr);
-  attrs->Add(new tidl::Attribute("key", "value", __LINE__));
-
-  bool flag = false;
-  for (auto& attr : attrs->GetAttrs()) {
-    if (attr->GetKey() == "key" &&
-        attr->GetValue() == "value")
-      flag = true;
-  }
-  EXPECT_EQ(flag, true);
-  delete attrs;
-}
-
-TEST_F(AttributesTest, Attributes_GetAttrs) {
-  tidl::Attributes* attrs = new tidl::Attributes();
-  EXPECT_NE(attrs, nullptr);
-  attrs->Add(new tidl::Attribute("key1", "value1", __LINE__));
-  attrs->Add(new tidl::Attribute("key2", "value2", __LINE__));
-
-  int count = 0;
-  for (auto& attr : attrs->GetAttrs()) {
-    if (attr->GetKey() == "key1" &&
-        attr->GetValue() == "value1")
-      count++;
-    if (attr->GetKey() == "key2" &&
-        attr->GetValue() == "value2")
-      count++;
-  }
-  EXPECT_EQ(count, 2);
-  delete attrs;
-}
-
-TEST_F(AttributesTest, Attributes_Exist) {
-  tidl::Attributes* attrs = new tidl::Attributes();
-  EXPECT_NE(attrs, nullptr);
-  attrs->Add(new tidl::Attribute("key", "value", __LINE__));
-  tidl::Attribute* attr = new tidl::Attribute("key", "value", __LINE__);
-  EXPECT_NE(attr, nullptr);
-  EXPECT_EQ(attrs->Exist(attr), true);
-  delete attr;
-  delete attrs;
-}
diff --git a/unit_tests/block_unittest.cc b/unit_tests/block_unittest.cc
deleted file mode 100644 (file)
index 0659344..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/block.h"
-
-class BlockTest : public testing::Test {
- public:
-  tidl::Block* testBlock;
-
-  virtual void SetUp() {
-    testBlock = new tidl::Block("TestBlock", tidl::Block::TYPE_INTERFACE,
-        "", 28);
-  }
-  virtual void TearDown() {
-    delete testBlock;
-  }
-};
-
-TEST_F(BlockTest, Block_Constructor) {
-  tidl::Block* block = new tidl::Block("StructureBlock",
-      tidl::Block::TYPE_STRUCTURE, "", __LINE__);
-  EXPECT_NE(block, nullptr);
-  delete block;
-}
-
-TEST_F(BlockTest, Block_GetID) {
-  EXPECT_EQ(testBlock->GetID(), "TestBlock");
-}
-
-TEST_F(BlockTest, Block_GetType) {
-  EXPECT_EQ(testBlock->GetType(), tidl::Block::TYPE_INTERFACE);
-}
-
-TEST_F(BlockTest, Block_GetLine) {
-  EXPECT_EQ(testBlock->GetLine(), 28);
-}
-
-TEST_F(BlockTest, Block_GetComments) {
-  std::string comments = "Test Block";
-  tidl::Block* block = new tidl::Block("StructureBlock",
-      tidl::Block::TYPE_STRUCTURE, comments, __LINE__);
-  EXPECT_NE(block, nullptr);
-  EXPECT_EQ(block->GetComments(), comments);
-  delete block;
-}
diff --git a/unit_tests/cs_gen/cs_proxy_gen_unittest.cc b/unit_tests/cs_gen/cs_proxy_gen_unittest.cc
deleted file mode 100644 (file)
index fd247cf..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/parser.h"
-#include "idlc/gen/cs_proxy_gen.h"
-
-class CsProxyGenTest : public testing::Test {
- public:
-  tidl::Parser* ps = nullptr;
-
-  virtual void SetUp() {
-    ps = new tidl::Parser();
-  }
-
-  virtual void TearDown() {
-    delete ps;
-  }
-
-  bool FindStringFromFile(std::string filename, std::string str) {
-    std::ifstream cb_file(filename);
-    std::string line;
-
-    while (std::getline(cb_file, line)) {
-      if (line.find(str) == 0) {
-        return true;
-      }
-    }
-
-    return false;
-  }
-};
-
-TEST_F(CsProxyGenTest, CsProxyGen_Constructor) {
-  bool ret = ps->ParseFromFile("test.tidl");
-  ASSERT_TRUE(ret);
-  tidl::CsProxyGen gen(ps->GetDoc());
-}
-
-TEST_F(CsProxyGenTest, CsProxyGen_Run) {
-  bool ret = ps->ParseFromFile("test.tidl");
-  ASSERT_TRUE(ret);
-  tidl::CsProxyGen gen(ps->GetDoc());
-  gen.Run("test.cs");
-
-  ASSERT_TRUE(FindStringFromFile("test.cs", "namespace RPCPort"));
-  ASSERT_TRUE(FindStringFromFile("test.cs",
-      "    public sealed class Student"));
-  ASSERT_TRUE(FindStringFromFile("test.cs",
-      "        public string name { get; set; }"));
-  ASSERT_TRUE(FindStringFromFile("test.cs", "    public sealed class Class"));
-  ASSERT_TRUE(FindStringFromFile("test.cs",
-      "        public LinkedList<Student> students { get; set; }"));
-}
diff --git a/unit_tests/cs_gen/cs_stub_gen_unittest.cc b/unit_tests/cs_gen/cs_stub_gen_unittest.cc
deleted file mode 100644 (file)
index 512c6de..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/parser.h"
-#include "idlc/gen/cs_stub_gen.h"
-
-class CsStubGenTest : public testing::Test {
- public:
-  tidl::Parser* ps = nullptr;
-
-  virtual void SetUp() {
-    ps = new tidl::Parser();
-  }
-
-  virtual void TearDown() {
-    delete ps;
-  }
-
-  bool FindStringFromFile(std::string filename, std::string str) {
-    std::ifstream cb_file(filename);
-    std::string line;
-
-    while (std::getline(cb_file, line)) {
-      if (line.find(str) == 0) {
-        return true;
-      }
-    }
-
-    return false;
-  }
-};
-
-TEST_F(CsStubGenTest, CsStubGen_Constructor) {
-  bool ret = ps->ParseFromFile("test.tidl");
-  ASSERT_TRUE(ret);
-  tidl::CsStubGen gen(ps->GetDoc());
-}
-
-TEST_F(CsStubGenTest, CsStubGen_Run) {
-  bool ret = ps->ParseFromFile("test.tidl");
-  ASSERT_TRUE(ret);
-  tidl::CsStubGen gen(ps->GetDoc());
-  gen.Run("test_stub.cs");
-
-  ASSERT_TRUE(FindStringFromFile("test_stub.cs", "namespace RPCPort"));
-  ASSERT_TRUE(FindStringFromFile("test_stub.cs",
-      "    public sealed class Student"));
-  ASSERT_TRUE(FindStringFromFile("test_stub.cs",
-      "        public string name { get; set; }"));
-  ASSERT_TRUE(FindStringFromFile("test_stub.cs",
-      "    public sealed class Class"));
-  ASSERT_TRUE(FindStringFromFile("test_stub.cs",
-      "        public LinkedList<Student> students { get; set; }"));
-}
diff --git a/unit_tests/declaration_unittest.cc b/unit_tests/declaration_unittest.cc
deleted file mode 100644 (file)
index 776341d..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/declaration.h"
-#include "idlc/ast/type.h"
-#include "idlc/ast/parameter.h"
-
-class DeclarationTest : public testing::Test {
- public:
-  tidl::Parameters* params;
-
-  virtual void SetUp() {
-    params = new tidl::Parameters();
-    EXPECT_NE(params, nullptr);
-    params->Add(new tidl::Parameter("test1",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-    params->Add(new tidl::Parameter("test2",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-  }
-  virtual void TearDown() {}
-};
-
-TEST_F(DeclarationTest, Declaration_Constructor) {
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", __LINE__);
-  EXPECT_NE(decl, nullptr);
-  delete decl;
-}
-
-TEST_F(DeclarationTest, Declaration_GetID) {
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", __LINE__);
-  EXPECT_NE(decl, nullptr);
-  EXPECT_EQ(decl->GetID(), "test");
-  delete decl;
-}
-
-TEST_F(DeclarationTest, Declaration_GetType) {
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", __LINE__);
-  EXPECT_NE(decl, nullptr);
-  EXPECT_EQ(decl->GetType().ToString(), "int");
-  delete decl;
-}
-
-TEST_F(DeclarationTest, Declaration_GetParameters) {
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", __LINE__);
-  EXPECT_NE(decl, nullptr);
-
-  int count = 0;
-  for (auto& param : decl->GetParameters().GetParams()) {
-    if (param->GetID() == "test1" &&
-        param->GetParameterType().GetBaseType().ToString() == "int")
-      count++;
-    if (param->GetID() == "test2" &&
-        param->GetParameterType().GetBaseType().ToString() == "int")
-      count++;
-  }
-  EXPECT_EQ(count, 2);
-
-  delete decl;
-}
-
-TEST_F(DeclarationTest, Declaration_GetMethodType) {
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", __LINE__,
-      tidl::Declaration::MethodType::DELEGATE);
-  EXPECT_NE(decl, nullptr);
-  EXPECT_EQ(decl->GetMethodType(), tidl::Declaration::MethodType::DELEGATE);
-  delete decl;
-}
-
-TEST_F(DeclarationTest, Declaration_GetComments) {
-  std::string comments = "Test Declaration";
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, comments, __LINE__);
-  EXPECT_NE(decl, nullptr);
-  EXPECT_EQ(decl->GetComments(), comments);
-  delete decl;
-}
-
-TEST_F(DeclarationTest, Declaration_GetLine) {
-  unsigned line = __LINE__;
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", line);
-  EXPECT_NE(decl, nullptr);
-  EXPECT_EQ(decl->GetLine(), line);
-  delete decl;
-}
-
-class DeclarationsTest : public testing::Test {
- public:
-  tidl::Declaration* decl;
-
-  virtual void SetUp() {}
-  virtual void TestDown() {}
-  void PrepareDeclaration() {
-    tidl::Parameters* params = new tidl::Parameters();
-    EXPECT_NE(params, nullptr);
-    params->Add(new tidl::Parameter("test1",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-    params->Add(new tidl::Parameter("test2",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-    decl = new tidl::Declaration("test",
-        new tidl::BaseType("int", ""), params, "", __LINE__);
-    EXPECT_NE(decl, nullptr);
-  }
-};
-
-TEST_F(DeclarationsTest, Declarations_Constructor) {
-  tidl::Declarations* decls = new tidl::Declarations();
-  EXPECT_NE(decls, nullptr);
-  delete decls;
-}
-
-TEST_F(DeclarationsTest, Declarations_Add) {
-  tidl::Declarations* decls = new tidl::Declarations();
-  EXPECT_NE(decls, nullptr);
-  PrepareDeclaration();
-  decls->Add(decl);
-
-  bool flag = false;
-  for (auto& d : decls->GetDecls()) {
-    if (d->GetID() == "test")
-      flag = true;
-  }
-  EXPECT_EQ(flag, true);
-  delete decls;
-}
-
-TEST_F(DeclarationsTest, Declarations_GetDecls) {
-  tidl::Declarations* decls = new tidl::Declarations();
-  EXPECT_NE(decls, nullptr);
-  PrepareDeclaration();
-  decls->Add(decl);
-
-  bool flag = false;
-  for (auto& d : decls->GetDecls()) {
-    if (d->GetID() == "test")
-      flag = true;
-  }
-  EXPECT_EQ(flag, true);
-  delete decls;
-}
-
-TEST_F(DeclarationsTest, Declarations_Exist) {
-  tidl::Declarations* decls = new tidl::Declarations();
-  EXPECT_NE(decls, nullptr);
-  PrepareDeclaration();
-  decls->Add(decl);
-  tidl::Parameters* testParams = new tidl::Parameters();
-  EXPECT_NE(testParams, nullptr);
-  testParams->Add(new tidl::Parameter("test1",
-        new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-  tidl::Declaration* testDecl = new tidl::Declaration("test",
-        new tidl::BaseType("int", ""), testParams, "", __LINE__);
-  EXPECT_NE(testDecl, nullptr);
-  EXPECT_EQ(decls->Exist(testDecl), true);
-  delete testDecl;
-  delete decls;
-}
diff --git a/unit_tests/document_unittest.cc b/unit_tests/document_unittest.cc
deleted file mode 100644 (file)
index 31e6c1b..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/document.h"
-#include "idlc/ast/block.h"
-
-class DocumentTest : public testing::Test {
- public:
-  tidl::Block* block;
-  tidl::Document* document;
-
-  virtual void SetUp() {
-    document = new tidl::Document();
-    block = new tidl::Block("TestBlock", tidl::Block::TYPE_INTERFACE,
-        "", __LINE__);
-  }
-  virtual void TearDown() {
-  }
-};
-
-TEST_F(DocumentTest, Document_Constructor) {
-  tidl::Document *doc = new tidl::Document();
-  EXPECT_NE(doc, nullptr);
-  delete doc;
-}
-
-TEST_F(DocumentTest, Document_AddBlock) {
-  document->AddBlock(block);
-  bool flag = false;
-  for (auto& blk : document->GetBlocks()) {
-    if (blk->GetID() == "TestBlock")
-      flag = true;
-  }
-  EXPECT_NE(flag, false);
-}
-
-TEST_F(DocumentTest, Document_GetBlocks) {
-  document->AddBlock(block);
-  bool flag = false;
-  for (auto& blk : document->GetBlocks()) {
-    if (blk->GetType() == tidl::Block::TYPE_INTERFACE)
-      flag = true;
-  }
-  EXPECT_NE(flag, false);
-}
-
-TEST_F(DocumentTest, Document_ExistBlock) {
-  document->AddBlock(block);
-  tidl::Block* testBlock = new tidl::Block("TestBlock",
-      tidl::Block::TYPE_INTERFACE, "", __LINE__);
-  EXPECT_NE(testBlock, nullptr);
-  EXPECT_EQ(document->ExistBlock(testBlock), true);
-  delete testBlock;
-}
diff --git a/unit_tests/element_unittest.cc b/unit_tests/element_unittest.cc
deleted file mode 100644 (file)
index 8ef351c..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/element.h"
-
-class ElementTest : public testing::Test {
- public:
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-};
-
-TEST_F(ElementTest, Element_Contstructor) {
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  delete elm;
-}
-
-TEST_F(ElementTest, Element_GetID) {
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  EXPECT_EQ(elm->GetID(), "test");
-  delete elm;
-}
-
-TEST_F(ElementTest, Element_GetType) {
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  EXPECT_EQ(elm->GetType().ToString(), "int");
-  delete elm;
-}
-
-TEST_F(ElementTest, Element_GetLine) {
-  unsigned line = __LINE__;
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", line);
-  EXPECT_NE(elm, nullptr);
-  EXPECT_EQ(elm->GetLine(), line);
-  delete elm;
-}
-
-TEST_F(ElementTest, Element_GetComments) {
-  std::string comments = "Test comments";
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), comments, __LINE__);
-  EXPECT_NE(elm, nullptr);
-  EXPECT_EQ(elm->GetComments(), comments);
-  delete elm;
-}
-
-class ElementsTest : public testing::Test {
- public:
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-};
-
-TEST_F(ElementsTest, Elements_Constructor) {
-  tidl::Elements* elms = new tidl::Elements();
-  EXPECT_NE(elms, nullptr);
-  delete elms;
-}
-
-TEST_F(ElementsTest, Elements_Add) {
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  tidl::Elements* elms = new tidl::Elements();
-  EXPECT_NE(elms, nullptr);
-  elms->Add(elm);
-
-  bool flag = false;
-  for (auto& elm : elms->GetElms()) {
-    if (elm->GetID() == "test" &&
-        elm->GetType().ToString() == "int")
-      flag = true;
-  }
-  EXPECT_EQ(flag, true);
-  delete elms;
-}
-
-TEST_F(ElementsTest, Elements_Getelms) {
-  tidl::Elements* elms = new tidl::Elements();
-  EXPECT_NE(elms, nullptr);
-  elms->Add(new tidl::Element("test1", new tidl::BaseType("int", ""),
-      "", __LINE__));
-  elms->Add(new tidl::Element("test2", new tidl::BaseType("char *", ""),
-      "", __LINE__));
-
-  int count = 0;
-  for (auto& elm : elms->GetElms()) {
-    if (elm->GetID() == "test1" &&
-        elm->GetType().ToString() == "int")
-      count++;
-    if (elm->GetID() == "test2" &&
-        elm->GetType().ToString() == "char *")
-      count++;
-  }
-  EXPECT_EQ(count, 2);
-  delete elms;
-}
-
-TEST_F(ElementsTest, Elements_Exist) {
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  tidl::Elements* elms = new tidl::Elements();
-  EXPECT_NE(elms, nullptr);
-  elms->Add(elm);
-  tidl::Element* elm2 = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  EXPECT_EQ(elms->Exist(elm2), true);
-  delete elm2;
-  delete elms;
-}
diff --git a/unit_tests/generator_unittest.cc b/unit_tests/generator_unittest.cc
deleted file mode 100644 (file)
index 7573025..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-#include <memory>
-
-#include "idlc/gen/generator.h"
-#include "idlc/ast/interface.h"
-#include "idlc/ast/structure.h"
-#include "idlc/ast/attribute.h"
-
-class SampleGenerator : public tidl::Generator {
- public:
-  explicit SampleGenerator(std::shared_ptr<tidl::Document> doc)
-      : tidl::Generator(doc), count_(0) {}
-  ~SampleGenerator() {}
-
-  void OnInitGen(std::ofstream& stream) override {
-    count_++;
-  }
-  void OnFiniGen(std::ofstream& stream) override {
-    count_++;
-  }
-
-  int GetCount() {
-    return count_;
-  }
-
- private:
-  int count_;
-};
-
-class GeneratorTest : public testing::Test {
- public:
-  SampleGenerator* gen;
-
-  virtual void SetUp() {
-    gen = new SampleGenerator(
-        std::shared_ptr<tidl::Document>(new tidl::Document()));
-  }
-  virtual void TearDown() {
-    delete gen;
-  }
-};
-
-TEST_F(GeneratorTest, Generator_Constructor) {
-  EXPECT_NE(gen, nullptr);
-}
-
-TEST_F(GeneratorTest, Generator_Run) {
-  EXPECT_NE(gen, nullptr);
-  gen->Run("test.out");
-  EXPECT_EQ(gen->GetCount(), 2);
-}
diff --git a/unit_tests/interface_unittest.cc b/unit_tests/interface_unittest.cc
deleted file mode 100644 (file)
index 780aca5..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/interface.h"
-
-class InterfaceTest : public testing::Test {
- public:
-  tidl::Declarations* decls;
-
-  virtual void SetUp() {
-    tidl::Parameters* params = new tidl::Parameters();
-    EXPECT_NE(params, nullptr);
-    params->Add(new tidl::Parameter("test1",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-    params->Add(new tidl::Parameter("test2",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-    tidl::Declaration* decl = new tidl::Declaration("test",
-        new tidl::BaseType("int", ""), params, "", __LINE__);
-    EXPECT_NE(decl, nullptr);
-    decls = new tidl::Declarations();
-    EXPECT_NE(decls, nullptr);
-    decls->Add(decl);
-  }
-  virtual void TearDown() {}
-};
-
-TEST_F(InterfaceTest, Interface_Constructor) {
-  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
-      "", new tidl::Attributes(), __LINE__);
-  EXPECT_NE(interface, nullptr);
-  delete interface;
-}
-
-TEST_F(InterfaceTest, Interface_GetDeclrations) {
-  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
-      "", new tidl::Attributes(), __LINE__);
-  EXPECT_NE(interface, nullptr);
-
-  bool flag = false;
-  for (auto& d : interface->GetDeclarations().GetDecls()) {
-    if (d->GetID() == "test")
-      flag = true;
-  }
-  EXPECT_EQ(flag, true);
-  delete interface;
-}
-
-TEST_F(InterfaceTest, Interface_GetID) {
-  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
-      "", new tidl::Attributes(), __LINE__);
-  EXPECT_NE(interface, nullptr);
-  EXPECT_EQ(interface->GetID(), "TestInterface");
-  delete interface;
-}
-
-TEST_F(InterfaceTest, Interface_GetType) {
-  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
-      "", new tidl::Attributes(), __LINE__);
-  EXPECT_NE(interface, nullptr);
-  EXPECT_EQ(interface->GetType(), tidl::Interface::TYPE_INTERFACE);
-  delete interface;
-}
-
-TEST_F(InterfaceTest, Interface_GetLine) {
-  unsigned line = __LINE__;
-  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
-      "", new tidl::Attributes(), line);
-  EXPECT_NE(interface, nullptr);
-  EXPECT_EQ(interface->GetLine(), line);
-  delete interface;
-}
-
-TEST_F(InterfaceTest, Interface_GetComments) {
-  std::string comments = "Test Interface";
-  tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
-      comments, new tidl::Attributes(), __LINE__);
-  EXPECT_NE(interface, nullptr);
-  EXPECT_EQ(interface->GetComments(), comments);
-  delete interface;
-}
-
diff --git a/unit_tests/main.cc b/unit_tests/main.cc
deleted file mode 100644 (file)
index a2e3a75..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-int gargc;
-char** gargv;
-
-int main(int argc, char** argv) {
-  gargc = argc;
-  gargv = argv;
-
-  testing::InitGoogleTest(&argc, argv);
-  return RUN_ALL_TESTS();
-}
diff --git a/unit_tests/parser_unittest.cc b/unit_tests/parser_unittest.cc
deleted file mode 100644 (file)
index 748e33a..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/parser.h"
-
-extern int gargc;
-extern char** gargv;
-
-class ParserTest : public testing::Test {
- public:
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-};
-
-TEST_F(ParserTest, Parser_Constructor) {
-  tidl::Parser* ps = new tidl::Parser();
-  EXPECT_NE(ps, nullptr);
-  delete ps;
-}
-
-TEST_F(ParserTest, Parser_Scanner) {
-  tidl::Parser* ps = new tidl::Parser();
-  EXPECT_NE(ps, nullptr);
-  EXPECT_NE(ps->Scanner(), nullptr);
-  delete ps;
-}
-
-TEST_F(ParserTest, Parser_SetDoc) {
-  tidl::Parser* ps = new tidl::Parser();
-  EXPECT_NE(ps, nullptr);
-  ps->SetDoc(new tidl::Document());
-  EXPECT_NE(ps->GetDoc(), nullptr);
-  delete ps;
-}
-
-TEST_F(ParserTest, Parser_GetDoc) {
-  tidl::Parser* ps = new tidl::Parser();
-  EXPECT_NE(ps, nullptr);
-  ps->SetDoc(new tidl::Document());
-  EXPECT_NE(ps->GetDoc(), nullptr);
-  delete ps;
-}
-
-TEST_F(ParserTest, Parser_Parse) {
-  tidl::Parser* ps = new tidl::Parser();
-  EXPECT_NE(ps, nullptr);
-  std::string input = "interface ParserTest { int test(in int a); }";
-  EXPECT_EQ(ps->Parse(input), true);
-  delete ps;
-}
-
-TEST_F(ParserTest, Parser_ParseFromFile) {
-  tidl::Parser* ps = new tidl::Parser();
-  EXPECT_NE(ps, nullptr);
-
-  std::string file = "test.tidl";
-  if (gargc > 1)
-    file = gargv[1];
-  EXPECT_EQ(ps->ParseFromFile(file), true);
-  delete ps;
-}
-
-TEST_F(ParserTest, Parser_ParseFromFile_N) {
-  tidl::Parser* ps = new tidl::Parser();
-  EXPECT_NE(ps, nullptr);
-
-  std::string file = "test_error.tidl";
-  if (gargc > 2)
-    file = gargv[2];
-  EXPECT_EQ(ps->ParseFromFile(file), false);
-  delete ps;
-}
diff --git a/unit_tests/structure_unittest.cc b/unit_tests/structure_unittest.cc
deleted file mode 100644 (file)
index 4e68e98..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/structure.h"
-
-class StructureTest : public testing::Test {
- public:
-  tidl::Elements* elms;
-
-  virtual void SetUp() {
-    elms = new tidl::Elements();
-    EXPECT_NE(elms, nullptr);
-    elms->Add(new tidl::Element("test1", new tidl::BaseType("int", ""),
-        "", __LINE__));
-    elms->Add(new tidl::Element("test2", new tidl::BaseType("char *", ""),
-        "", __LINE__));
-  }
-  virtual void TearDown() {}
-};
-
-TEST_F(StructureTest, Structure_Constructor) {
-  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
-      "", __LINE__);
-  EXPECT_NE(structure, nullptr);
-  delete structure;
-}
-
-TEST_F(StructureTest, Structure_GetElements) {
-  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
-      "", __LINE__);
-  EXPECT_NE(structure, nullptr);
-
-  int count = 0;
-  for (auto& elm : elms->GetElms()) {
-    if (elm->GetID() == "test1" &&
-        elm->GetType().ToString() == "int")
-      count++;
-    if (elm->GetID() == "test2" &&
-        elm->GetType().ToString() == "char *")
-      count++;
-  }
-  EXPECT_EQ(count, 2);
-  delete structure;
-}
-
-TEST_F(StructureTest, Structure_GetID) {
-  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
-      "", __LINE__);
-  EXPECT_NE(structure, nullptr);
-  EXPECT_EQ(structure->GetID(), "TestStructure");
-  delete structure;
-}
-
-TEST_F(StructureTest, Structure_GetType) {
-  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
-      "", __LINE__);
-  EXPECT_NE(structure, nullptr);
-  EXPECT_EQ(structure->GetType(), tidl::Structure::TYPE_STRUCTURE);
-  delete structure;
-}
-
-TEST_F(StructureTest, Structure_GetLine) {
-  unsigned line = __LINE__;
-  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
-      "", line);
-  EXPECT_NE(structure, nullptr);
-  EXPECT_EQ(structure->GetLine(), line);
-  delete structure;
-}
-
-TEST_F(StructureTest, Structure_GetComments) {
-  std::string comments = "Test Structure";
-  tidl::Structure* structure = new tidl::Structure("TestStructure", elms,
-      comments, __LINE__);
-  EXPECT_NE(structure, nullptr);
-  EXPECT_EQ(structure->GetComments(), comments);
-  delete structure;
-}
diff --git a/unit_tests/test.tidl b/unit_tests/test.tidl
deleted file mode 100644 (file)
index 2624814..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2017 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.
- */
-
-struct Student {
-       string name;
-       int num;
-       bundle data;
-       array<char> tag;
-}
-
-// Annotation Test!!
-// Structure Class
-struct Class {
-       /* string name attr */
-       string name;
-       list<Student> students;
-}
-
-/* Interface School! */
-[privilege = "http://tizen.org/privilege/appmanager.launch", privilege = "http://tizen.org/privilege/appmanager.kill"]
-interface School {
-       /* Method section */
-       /* Method AddClass */
-       int AddClass(in Class cls);
-       /* Method GetStudent */
-       int GetStudent(in string c_name, in string s_name, out Student student);
-       string GetName(out string name);
-       int SetName(in string name);
-}
diff --git a/unit_tests/test_error.tidl b/unit_tests/test_error.tidl
deleted file mode 100644 (file)
index ca6475d..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-struct Student {
-       string name;
-       int num;
-       bundle data;
-}
-
-struct Class {
-       string name;
-       list<Student> students;
-}
-
-interface School {
-       int AddClass(in Class cls);
-       int GetStudent(in string c_name, in string s_name, out Student student);
-}
-
-interface School {
-       int RemoveStudent(in string name);
-}
-
-struct {
-       string k;
-}
-
-interface {
-       int test(int a);
-}
-
-struct ErrorAttrMissingName1 {
-       string;
-}
-
-interface ErrorAttrMissingName2 {
-       int (int a);
-}
-
-interface ErrorMethod {
-       void RemoveClass(in class cls);
-}
-
-interface ErrorMethodDupMethod {
-       int GetStudent(in string c_name, out Student student);
-       int GetStudent(in string c_name, out Student student);
-}
-
-struct ErrorMethodDupAttr {
-       string name;
-       string name;
-}
-
-interface ErrorMethodInvalidType {
-       int AddStudent(in string name) async;
-}
diff --git a/unit_tests/type_unittest.cc b/unit_tests/type_unittest.cc
deleted file mode 100644 (file)
index 677e096..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 2017 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 <gtest/gtest.h>
-
-#include <iostream>
-
-#include "idlc/ast/type.h"
-
-class TokenTest : public testing::Test {
- public:
-  tidl::Token* testToken;
-
-  virtual void SetUp() {
-    testToken = new tidl::Token("TestToken", "Test Token");
-  }
-  virtual void TearDown() {
-    delete testToken;
-  }
-};
-
-TEST_F(TokenTest, Token_Constructor) {
-  tidl::Token* token = new tidl::Token("TestToken", "");
-  EXPECT_NE(token, nullptr);
-  delete token;
-}
-
-TEST_F(TokenTest, Token_ToString) {
-  EXPECT_EQ(testToken->ToString(), "TestToken");
-}
-
-TEST_F(TokenTest, Token_GetComments) {
-  EXPECT_EQ(testToken->GetComments(), "Test Token");
-}
-
-class BaseTypeTest : public testing::Test {
- public:
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-};
-
-TEST_F(BaseTypeTest, BaseType_Constructor) {
-  tidl::BaseType* baseType = new tidl::BaseType("BaseType", "");
-  EXPECT_NE(baseType, nullptr);
-  delete baseType;
-}
-
-TEST_F(BaseTypeTest, BaseType_SetMetaType) {
-  tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
-  customType->SetMetaType(new tidl::BaseType("int", ""));
-  EXPECT_NE(customType->GetMetaType(), nullptr);
-  EXPECT_EQ(customType->GetMetaType()->ToString(), "int");
-  delete customType;
-}
-
-TEST_F(BaseTypeTest, BaseType_GetMetaType) {
-  tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
-  customType->SetMetaType(new tidl::BaseType("string", ""));
-  EXPECT_NE(customType->GetMetaType(), nullptr);
-  EXPECT_EQ(customType->GetMetaType()->ToString(), "string");
-  delete customType;
-}
-
-TEST_F(BaseTypeTest, BaseType_GetFullName) {
-  tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
-  customType->SetMetaType(new tidl::BaseType("string", ""));
-  EXPECT_EQ(customType->GetFullName(), "CustomType<string>");
-  delete customType;
-}
-
-TEST_F(BaseTypeTest, BaseType_IsUserDefinedType) {
-  tidl::BaseType* testType = new tidl::BaseType("TestType", "", true);
-  EXPECT_EQ(testType->IsUserDefinedType(), true);
-  delete testType;
-}
-
-TEST_F(BaseTypeTest, BaseType_GetComments) {
-  std::string comments = "Test BaseType";
-  tidl::BaseType* testType = new tidl::BaseType("TestType", comments, true);
-  EXPECT_NE(testType, nullptr);
-  EXPECT_EQ(testType->GetComments(), comments);
-  delete testType;
-}
-
-class ParameterTypeTest : public testing::Test {
- public:
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-};
-
-TEST_F(ParameterTypeTest, ParameterType_Constructor) {
-  tidl::ParameterType *parameterType = new tidl::ParameterType(
-      new tidl::BaseType("int", ""));
-  EXPECT_NE(parameterType, nullptr);
-  delete parameterType;
-}
-
-TEST_F(ParameterTypeTest, ParameterType_Constructor_With_Direction) {
-  tidl::ParameterType *parameterType = new tidl::ParameterType(
-      new tidl::BaseType("int", ""), "in");
-  EXPECT_NE(parameterType, nullptr);
-  delete parameterType;
-}
-
-TEST_F(ParameterTypeTest, ParameterType_GetDirection) {
-  tidl::ParameterType *parameterType = new tidl::ParameterType(
-      new tidl::BaseType("int", ""), "out");
-  EXPECT_NE(parameterType, nullptr);
-  EXPECT_EQ(parameterType->GetDirection(), tidl::ParameterType::Direction::OUT);
-  delete parameterType;
-}
-
-TEST_F(ParameterTypeTest, ParameterType_GetBaseType) {
-  tidl::ParameterType *parameterType = new tidl::ParameterType(
-      new tidl::BaseType("string", ""), "ref");
-  EXPECT_NE(parameterType, nullptr);
-  EXPECT_EQ(parameterType->GetBaseType().ToString(),
-      "string");
-  delete parameterType;
-}
diff --git a/unit_tests/unit_tests.sh b/unit_tests/unit_tests.sh
deleted file mode 100755 (executable)
index 36fce76..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-
-#--------------------------------------------------------#
-# Tizen Interface Definition Langauge Compiler Unit Test #
-#--------------------------------------------------------#
-
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
-
-SCRIPT_FILE=$(readlink -f $0)
-SCRIPT_DIR=$(dirname $SCRIPT_FILE)
-BUILD_DIR=build
-
-usage() {
-       echo "Usage: $0 [command]"
-       echo "Commands:"
-       echo "    build              Build the unit tests"
-       echo "    clean              Clean all artifacts"
-       echo "    run                Run the unit tests"
-       echo "    full               Build & Run the unit tests"
-}
-
-cmd_build() {
-       echo "[TIDL Unit Test] Build Unit Tests"
-       mkdir -p $SCRIPT_DIR/$BUILD_DIR
-       cd $SCRIPT_DIR/$BUILD_DIR
-       cmake ..
-       make clean
-       make
-}
-
-cmd_clean() {
-       echo "[TIDL Unit Test] Clean all artifacts"
-       rm -rf $SCRIPT_DIR/$BUILD_DIR
-}
-
-cmd_run() {
-       echo "[TIDL Unit Test] Run Unit Tests"
-       cd $SCRIPT_DIR/$BUILD_DIR
-       $SCRIPT_DIR/$BUILD_DIR/tidl-unit-tests $SCRIPT_DIR/test.tidl $SCRIPT_DIR/test_error.tidl
-       cd $SCRIPT_DIR
-}
-
-cmd_full() {
-       cmd_build
-       cmd_run
-       cmd_clean
-}
-
-cmd=$1; shift;
-case "$cmd" in
-       build|--build|-b) cmd_build $@ ;;
-       clean|--clean|-c) cmd_clean $@ ;;
-       run|--run|-r) cmd_run $@ ;;
-       full |--full |-f)  cmd_full $@ ;;
-       *)     usage ;;
-
-esac