Skip to content

Commit

Permalink
add platform, dialect, and dml statement
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Oct 1, 2015
1 parent 9710bd4 commit 7daabdd
Show file tree
Hide file tree
Showing 75 changed files with 2,470 additions and 406 deletions.
6 changes: 6 additions & 0 deletions symmetric-client-clib-test/Debug/src/util/subdir.mk
Expand Up @@ -4,14 +4,20 @@

# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../src/util/ListTest.c \
../src/util/MapTest.c \
../src/util/PropertiesTest.c \
../src/util/StringBuilderTest.c

OBJS += \
./src/util/ListTest.o \
./src/util/MapTest.o \
./src/util/PropertiesTest.o \
./src/util/StringBuilderTest.o

C_DEPS += \
./src/util/ListTest.d \
./src/util/MapTest.d \
./src/util/PropertiesTest.d \
./src/util/StringBuilderTest.d

Expand Down
Binary file modified symmetric-client-clib-test/Debug/symclient_test
Binary file not shown.
2 changes: 2 additions & 0 deletions symmetric-client-clib-test/inc/symclient_test.h
Expand Up @@ -25,11 +25,13 @@

#include <stdlib.h>
#include <stdarg.h>
#include <string.h>

#include "libsymclient.h"

int SymEngineTest_CUnit();
int SymPropertiesTest_CUnit();
int SymStringBuilderTest_CUnit();
int SymMapTest_CUnit();

#endif
2 changes: 1 addition & 1 deletion symmetric-client-clib-test/run/symclient_test.launch
Expand Up @@ -20,7 +20,7 @@
<listEntry value="4"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.environmentVariables">
<mapEntry key="LD_LIBRARY_PATH" value="/usr/local/lib:${workspace_loc}/symmetric-client-clib/Debug"/>
<mapEntry key="LD_LIBRARY_PATH" value="../symmetric-client-clib/Debug:/usr/local/lib"/>
</mapAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
Expand Down
5 changes: 4 additions & 1 deletion symmetric-client-clib-test/src/symclient_test.c
Expand Up @@ -25,7 +25,10 @@ int main() {
return CU_get_error();
}

if (SymEngineTest_CUnit() != CUE_SUCCESS ||
if (
SymEngineTest_CUnit() != CUE_SUCCESS ||
//SymMapTest_CUnit() != CUE_SUCCESS ||
//SymListTest_CUnit() != CUE_SUCCESS ||
//SymStringBuilderTest_CUnit() != CUE_SUCCESS ||
//SymPropertiesTest_CUnit() != CUE_SUCCESS) {
1==0) {
Expand Down
121 changes: 121 additions & 0 deletions symmetric-client-clib-test/src/util/ListTest.c
@@ -0,0 +1,121 @@
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* 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 "symclient_test.h"

typedef struct {
int i;
} myobj;

/*
void SymListTest_test1() {
SymList *list = SymList_new(NULL);
list->add(list, "hola");
list->add(list, "");
list->add(list, NULL);
list->add(list, "bonjour");
CU_ASSERT(strcmp(list->get(list, 0), "hola") == 0);
CU_ASSERT(strcmp(list->get(list, 1), "") == 0);
CU_ASSERT(list->get(list, 2) == NULL);
CU_ASSERT(strcmp(list->get(list, 3), "bonjour") == 0);
CU_ASSERT(list->size == 4);
char **array = (char **) list->to_array(list);
CU_ASSERT(strcmp(array[0], "hola") == 0);
CU_ASSERT(array[1] != NULL);
CU_ASSERT(strcmp(array[1], "") == 0);
CU_ASSERT(array[2] == NULL);
CU_ASSERT(strcmp(array[3], "bonjour") == 0);
CU_ASSERT(array[4] == NULL);
int i;
for (i = 0; array[i] != NULL; i++) {
printf("%d is %s\n", i, array[i]);
}
list->destroy(list);
}
void SymListTest_test2() {
myobj myobjs[3];
myobjs[0].i = 0;
myobjs[1].i = 1;
myobjs[2].i = 2;
SymList *list = SymList_new(NULL);
list->add(list, &myobjs[0]);
list->add(list, NULL);
list->add(list, &myobjs[2]);
CU_ASSERT(((myobj *) list->get(list, 0))->i == 0);
CU_ASSERT(((myobj *) list->get(list, 1)) == NULL);
CU_ASSERT(((myobj *) list->get(list, 2))->i == 2);
myobj **array = (myobj **) list->to_array(list);
CU_ASSERT(array[0]->i == 0);
CU_ASSERT(array[1] == NULL);
CU_ASSERT(array[2]->i == 2);
int i;
for (i = 0; array[i] != NULL; i++) {
printf("%d is %d\n", i, array[i]->i);
}
list->destroy(list);
}
void SymListTest_test3() {
SymList *list = SymList_new(NULL);
list->add(list, "one string");
list->add(list, "two thing");
list->add(list, "red ping");
list->add(list, "blue ring");
char **array = (char **) list->to_array_slice(list, 1, 2);
CU_ASSERT(strcmp(array[0], "two thing") == 0);
int i;
for (i = 0; array[i] != NULL; i++) {
printf("%d is %s\n", i, array[i]);
}
list->destroy(list);
}
*/

int SymListTest_CUnit() {
CU_pSuite suite = CU_add_suite("SymListTest", NULL, NULL);
if (suite == NULL) {
return CUE_NOSUITE;
}

/*
if (CU_add_test(suite, "SymListTest_test1", SymListTest_test1) == NULL ||
CU_add_test(suite, "SymListTest_test2", SymListTest_test2) == NULL ||
CU_add_test(suite, "SymListTest_test3", SymListTest_test3) == NULL) {
return CUE_NOTEST;
}
*/
return CUE_SUCCESS;
}
104 changes: 104 additions & 0 deletions symmetric-client-clib-test/src/util/MapTest.c
@@ -0,0 +1,104 @@
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* 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 "symclient_test.h"

static void SymMapTest_test_stringmap(int keySize, char **keys, char **values, int mapSize) {
SymMap *map = SymMap_new(NULL, mapSize);
int i;
for (i = 0; i < keySize; i++) {
map->put(map, keys[i], values[i], strlen(values[i]));
}

for (i = 0; i < keySize; i++) {
char *out = (char *) map->get(map, keys[i]);
CU_ASSERT(out != NULL);
if (out != NULL) {
CU_ASSERT(strcmp(out, values[i]) == 0);
}
}
map->destroy(map);
}

void SymMapTest_test1() {
char *keys[] = { "Hello", "Hi", "Welcome", "Greetings" };
char *values[] = { "Goodbye", "Hey", "Thank you", "Later" };

SymMapTest_test_stringmap(4, keys, values, 1);
SymMapTest_test_stringmap(4, keys, values, 4);
SymMapTest_test_stringmap(4, keys, values, 8);
}

void SymMapTest_test2() {
char *keys[] = { "1", "2", "Three" };
char *values[] = { "One", "", "3" };

SymMapTest_test_stringmap(3, keys, values, 0);
SymMapTest_test_stringmap(3, keys, values, 1);
SymMapTest_test_stringmap(3, keys, values, 2);
SymMapTest_test_stringmap(3, keys, values, 3);
}

void SymMapTest_test3() {
char *columnNames[] = { "id", "name", "description", "create_time" };
SymTable *table = SymTable_new_with_fullname(NULL, "mydb", "dbo", "table1");
table->columns = SymList_new(NULL);
int i;
for (i = 0; i < 4; i++) {
table->columns->add(table->columns, SymColumn_new(NULL, columnNames[i], 0));
}

SymMap *map = SymMap_new(NULL, 100);
map->put(map, table->name, table, sizeof(SymTable));
SymTable *out = map->get(map, table->name);

CU_ASSERT(out != NULL);
if (out) {
CU_ASSERT(out->columns != NULL);
if (out->columns) {
SymIterator *iter = out->columns->iterator(out->columns);
while (iter->has_next(iter)) {
SymColumn *column = (SymColumn *) iter->next(iter);
CU_ASSERT(column->name != NULL);
if (column->name) {
CU_ASSERT(strcmp(column->name, columnNames[iter->index]) == 0);
}
}
iter->destroy(iter);
}
}

table->destroy(table);
map->destroy(map);
}

int SymMapTest_CUnit() {
CU_pSuite suite = CU_add_suite("SymMapTest", NULL, NULL);
if (suite == NULL) {
return CUE_NOSUITE;
}

if (CU_add_test(suite, "SymMapTest_test1", SymMapTest_test1) == NULL ||
CU_add_test(suite, "SymMapTest_test2", SymMapTest_test2) == NULL ||
CU_add_test(suite, "SymMapTest_test3", SymMapTest_test3) == NULL) {
return CUE_NOTEST;
}
return CUE_SUCCESS;
}
6 changes: 3 additions & 3 deletions symmetric-client-clib-test/src/util/StringBuilderTest.c
Expand Up @@ -27,15 +27,15 @@ void SymStringBuilderTest_test1() {
sb->append(sb, ",bonjour");
sb->append(sb, ",guten tag");
sb->append(sb, ",ciao");
CU_ASSERT(strcmp(sb->to_string(sb), "hello,hola,salute,bonjour,guten tag,ciao") == 0);
CU_ASSERT(strcmp(sb->str, "hello,hola,salute,bonjour,guten tag,ciao") == 0);
sb->destroy(sb);
}

void SymStringBuilderTest_test2() {
SymStringBuilder *sb = SymStringBuilder_new_with_size(1);
sb->append(sb, "como ");
sb->append(sb, "t'allez-vous");
CU_ASSERT(strcmp(sb->to_string(sb), "como t'allez-vous") == 0);
CU_ASSERT(strcmp(sb->str, "como t'allez-vous") == 0);
sb->destroy(sb);
}

Expand All @@ -44,7 +44,7 @@ void SymStringBuilderTest_test3() {
sb->append(sb, "1");
sb->append(sb, "2");
sb->append(sb, "3");
CU_ASSERT(strcmp(sb->to_string(sb), "123") == 0);
CU_ASSERT(strcmp(sb->str, "123") == 0);
sb->destroy(sb);
}

Expand Down
4 changes: 4 additions & 0 deletions symmetric-client-clib/Debug/makefile
Expand Up @@ -16,6 +16,10 @@ RM := rm -rf
-include src/io/writer/subdir.mk
-include src/io/reader/subdir.mk
-include src/io/data/subdir.mk
-include src/db/sqlite/subdir.mk
-include src/db/sql/subdir.mk
-include src/db/platform/sqlite/subdir.mk
-include src/db/platform/subdir.mk
-include src/db/model/subdir.mk
-include src/db/subdir.mk
-include src/core/subdir.mk
Expand Down
4 changes: 4 additions & 0 deletions symmetric-client-clib/Debug/sources.mk
Expand Up @@ -16,6 +16,10 @@ SUBDIRS := \
src/core \
src/db \
src/db/model \
src/db/platform \
src/db/platform/sqlite \
src/db/sql \
src/db/sqlite \
src/io/data \
src/io/reader \
src/io/writer \
Expand Down
3 changes: 3 additions & 0 deletions symmetric-client-clib/Debug/src/db/model/subdir.mk
Expand Up @@ -4,12 +4,15 @@

# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../src/db/model/Column.c \
../src/db/model/Table.c

OBJS += \
./src/db/model/Column.o \
./src/db/model/Table.o

C_DEPS += \
./src/db/model/Column.d \
./src/db/model/Table.d


Expand Down
33 changes: 33 additions & 0 deletions symmetric-client-clib/Debug/src/db/platform/sqlite/subdir.mk
@@ -0,0 +1,33 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################

# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../src/db/platform/sqlite/SqliteDdlReader.c \
../src/db/platform/sqlite/SqlitePlatform.c \
../src/db/platform/sqlite/SqliteSqlTemplate.c \
../src/db/platform/sqlite/SqliteSqlTransaction.c

OBJS += \
./src/db/platform/sqlite/SqliteDdlReader.o \
./src/db/platform/sqlite/SqlitePlatform.o \
./src/db/platform/sqlite/SqliteSqlTemplate.o \
./src/db/platform/sqlite/SqliteSqlTransaction.o

C_DEPS += \
./src/db/platform/sqlite/SqliteDdlReader.d \
./src/db/platform/sqlite/SqlitePlatform.d \
./src/db/platform/sqlite/SqliteSqlTemplate.d \
./src/db/platform/sqlite/SqliteSqlTransaction.d


# Each subdirectory must supply rules for building sources it contributes
src/db/platform/sqlite/%.o: ../src/db/platform/sqlite/%.c
@echo 'Building file: $<'
@echo 'Invoking: GCC C Compiler'
gcc -I"/home/elong/git/3.7/symmetric-ds/symmetric-client-clib/inc" -O0 -g3 -Wall -c -fmessage-length=0 -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '


0 comments on commit 7daabdd

Please sign in to comment.